help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Transposing words over middle words


From: ken
Subject: Re: Transposing words over middle words
Date: Sat, 18 Nov 2017 21:06:14 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0

On 11/18/2017 02:34 PM, Emanuel Berg wrote:
ken wrote:

I prefer this method because it's
straightforward and easy to understand, plus,
it leaves the mark where it was. However, in
instances in which the middle word is at the
end of the line, the result is unexpected:

With the point after the '3':

1 2 3 4
5 6 7 8

invoking M-a yields this:

1 2 5
4 3 6 7 8
You are right, here the other function is
better

(defun transpose-over-word-2 ()
   (interactive)
   (backward-char 1)
   (push-mark)
   (forward-word 3)
   (backward-char 1)
   (transpose-words 0)
   (forward-word 1) )

(local-set-key (kbd "M-a") #'transpose-over-word-2) ; try it

That's great.  Thanks.  It's  quite nice that the point remains in place.  Is there perhaps a way to return the mark to where it was prior to invoking "M-a" so that it, too, remains in place?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]