2

If I have phrases of the form:

  • blood oranges, green grapes, and Arkansas Black apples
  • tigers and bears and lions
  • paper or plastic
  • curly, moe, and larry

Is there a library or tweak to transpose multiple words around the or/and/comma:

  • blood oranges, Arkansas Black apples, and <Meta-t> green grapes
  • plastic <Meta-t> or paper

I use Emacs to draft written communications, and it would be very helpful to be able to switch clauses around quickly when evaluating readability. Something that mostly does the job correctly would be fine, it doesn't have to work perfectly in all cases.

1

You can code up such a command using (1) the basic workhorse function, transpose-subr or (2) function transpose-regions.

For #1, you need a helper function that moves forward to the end of the next phrase. Searching forward for punctuation syntax might help with that.

For #2, you need to "parse" your sentence (or whatever) into its phrases, to get their start and end positions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.