[Top][All Lists]

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

Re: Saving "relative point" in a paragraph or line

From: Damien Wyart
Subject: Re: Saving "relative point" in a paragraph or line
Date: Thu, 12 Sep 2013 11:14:26 +0200
User-agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3.50

* Jambunathan K <address@hidden> in
>     (defadvice transpose-lines
>         (around transpose-lines-preserve-context activate)
>       "Transpose lines but preserve the surrounding text context."
>       ;; Add a bookmark at current char.
>       (add-text-properties (point) (1+ (point)) '(bookmark t))
>       ;; Transpose.
>       ad-do-it
>       ;; Visit the bookmark.  Assumes that the bookmark is at a position
>       ;; behind where the cursor is at the end of the transposition.
>       (goto-char (1- (previous-single-property-change (point) 'bookmark)))
>       ;; Remove it.
>       (remove-text-properties (point) (1+ (point)) '(bookmark)))

I was thinking of doing it with saving current-column, transposing,
forward-line to go back 2 lines, and move-to-column, but your approach
looks more elegant.


reply via email to

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