[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: Suvayu Ali
Subject: Re: Saving "relative point" in a paragraph or line
Date: Thu, 12 Sep 2013 15:31:17 +0200
User-agent: Mutt/1.5.21 (2012-12-30)

On Thu, Sep 12, 2013 at 02:34:56PM +0530, Jambunathan K wrote:
>     (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 adapted this to my needs; works great!

Thank you :)


Open source is the future. It sets us free.

reply via email to

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