From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Damien Wyart Newsgroups: gmane.emacs.help Subject: Re: Saving "relative point" in a paragraph or line Date: Thu, 12 Sep 2013 11:14:26 +0200 Organization: Serveur de News Free Message-ID: <523185f2$0$2294$426a34cc@news.free.fr> References: <20130912080605.GQ20690@kuru.dyndns-at-home.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1378977318 28581 80.91.229.3 (12 Sep 2013 09:15:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 12 Sep 2013 09:15:18 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Sep 12 11:15:19 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VK2zf-0000fu-0g for geh-help-gnu-emacs@m.gmane.org; Thu, 12 Sep 2013 11:15:19 +0200 Original-Received: from localhost ([::1]:40416 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VK2ze-0006qx-FM for geh-help-gnu-emacs@m.gmane.org; Thu, 12 Sep 2013 05:15:18 -0400 X-Received: by 10.180.109.19 with SMTP id ho19mr2689094wib.7.1378977267186; Thu, 12 Sep 2013 02:14:27 -0700 (PDT) Original-Path: usenet.stanford.edu!gn7no7994497wib.1!news-out.google.com!ed8ni165694wic.0!nntp.google.com!proxad.net!feeder1-2.proxad.net!cleanfeed2-a.proxad.net!nnrp3-1.free.fr!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3.50 Original-Lines: 20 Original-NNTP-Posting-Date: 12 Sep 2013 11:14:26 CEST Original-NNTP-Posting-Host: 213.41.244.197 Original-X-Trace: 1378977266 news-4.free.fr 2294 213.41.244.197:40567 Original-X-Complaints-To: abuse@proxad.net Original-Xref: usenet.stanford.edu gnu.emacs.help:201076 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:93345 Archived-At: * Jambunathan K in gnu.emacs.help: > (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. -- DW