From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Suvayu Ali Newsgroups: gmane.emacs.help Subject: Re: Saving "relative point" in a paragraph or line Date: Thu, 12 Sep 2013 15:31:17 +0200 Message-ID: <20130912133117.GA14054@kuru.dyndns-at-home.com> References: <20130912080605.GQ20690@kuru.dyndns-at-home.com> <8761u6e7gn.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1378992701 21650 80.91.229.3 (12 Sep 2013 13:31:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 12 Sep 2013 13:31:41 +0000 (UTC) Cc: Emacs help To: Jambunathan K Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Sep 12 15:31:44 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 1VK6zn-0005EA-LT for geh-help-gnu-emacs@m.gmane.org; Thu, 12 Sep 2013 15:31:43 +0200 Original-Received: from localhost ([::1]:42010 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VK6zn-0000oL-80 for geh-help-gnu-emacs@m.gmane.org; Thu, 12 Sep 2013 09:31:43 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48774) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VK6zW-0000o7-SP for help-gnu-emacs@gnu.org; Thu, 12 Sep 2013 09:31:31 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VK6zS-0004Uz-CE for help-gnu-emacs@gnu.org; Thu, 12 Sep 2013 09:31:26 -0400 Original-Received: from mail-ea0-x22a.google.com ([2a00:1450:4013:c01::22a]:64028) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VK6zS-0004Uo-4z for help-gnu-emacs@gnu.org; Thu, 12 Sep 2013 09:31:22 -0400 Original-Received: by mail-ea0-f170.google.com with SMTP id h14so5468538eak.1 for ; Thu, 12 Sep 2013 06:31:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=vcK9dFhje54Evlzjd50JIANO5qHi8rH2bhHDZitD7RA=; b=IbGNvl4v0AovftZcMrtYRAwGg7RXkXL9d8dU2FQ/tMlkQ/3SRDfOqVAK7DOLkx1J0M i72CYuuz2JyZTI8wPYnh5kpGKwG45yesq065hYf1LdXAENnrNpGhz7Z9ECrEJMbkXrsG ZD7zCoAaYdC8DD+P6OsDAaCnCOqqHWwzO7ZVo4yxXQzcYN9adC3h8xP0KXF6Rfff/Rdk fY/l8PX9SOTeLeCSyfXcMLEJlHoQuz0BzV+iijZPb9071RPa7cEJhCELMsVokfifcii5 Sbbv3ta5PYVXdc5IL5tPGvQS+zbfnJrte3afjawIxMqPe2F9R/n6Emg4W4HrwzxJOyI/ ocBg== X-Received: by 10.15.94.78 with SMTP id ba54mr111829eeb.117.1378992680922; Thu, 12 Sep 2013 06:31:20 -0700 (PDT) Original-Received: from kuru.dyndns-at-home.com ([2001:610:120:3001:f2de:f1ff:fe37:c76c]) by mx.google.com with ESMTPSA id p5sm5947308eeg.5.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 12 Sep 2013 06:31:19 -0700 (PDT) Content-Disposition: inline In-Reply-To: <8761u6e7gn.fsf@gmail.com> User-Agent: Mutt/1.5.21 (2012-12-30) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4013:c01::22a 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:93349 Archived-At: 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 :) -- Suvayu Open source is the future. It sets us free.