From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juanma Barranquero Newsgroups: gmane.emacs.bugs Subject: bug#6032: untabify causes point to move Date: Mon, 26 Apr 2010 01:16:58 +0200 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: dough.gmane.org 1272237944 1035 80.91.229.12 (25 Apr 2010 23:25:44 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 25 Apr 2010 23:25:44 +0000 (UTC) Cc: 6032@debbugs.gnu.org To: Ethan Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Apr 26 01:25:42 2010 connect(): No such file or directory Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1O6BCn-0002R1-Oh for geb-bug-gnu-emacs@m.gmane.org; Mon, 26 Apr 2010 01:25:42 +0200 Original-Received: from localhost ([127.0.0.1]:44478 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O6BCn-0007A9-33 for geb-bug-gnu-emacs@m.gmane.org; Sun, 25 Apr 2010 19:25:41 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O6BCh-00077r-AB for bug-gnu-emacs@gnu.org; Sun, 25 Apr 2010 19:25:35 -0400 Original-Received: from [140.186.70.92] (port=48689 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O6BCf-00075N-Q5 for bug-gnu-emacs@gnu.org; Sun, 25 Apr 2010 19:25:34 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O6BCd-0002Jk-Vk for bug-gnu-emacs@gnu.org; Sun, 25 Apr 2010 19:25:33 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:48333) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O6BCd-0002Je-Tz for bug-gnu-emacs@gnu.org; Sun, 25 Apr 2010 19:25:31 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1O6B5O-000110-Ik; Sun, 25 Apr 2010 19:18:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juanma Barranquero Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 25 Apr 2010 23:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 6032 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 6032-submit@debbugs.gnu.org id=B6032.12722374453892 (code B ref 6032); Sun, 25 Apr 2010 23:18:02 +0000 Original-Received: (at 6032) by debbugs.gnu.org; 25 Apr 2010 23:17:25 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O6B4n-00010j-5z for submit@debbugs.gnu.org; Sun, 25 Apr 2010 19:17:25 -0400 Original-Received: from mail-bw0-f214.google.com ([209.85.218.214]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O6B4l-00010b-3p for 6032@debbugs.gnu.org; Sun, 25 Apr 2010 19:17:23 -0400 Original-Received: by bwz6 with SMTP id 6so781345bwz.39 for <6032@debbugs.gnu.org>; Sun, 25 Apr 2010 16:17:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:cc:content-type; bh=VVVivBeDr9O5znc0I9sCU2ZtmYJ50mCeTerF3iD0EoQ=; b=hwhCzvtPwWNRw1bFzJPxtrAkvql6yF6FBFm4+btbZGmIaucfYN3zwQjEvYpbj+ErHz R1tkRJsxEECXliTxuhx7SQpKE4Ieo1vMGfWPriWinIbZEKia92Z6SFbxn+MG+hYKdrXf d4LJtNKdhFcwPmwrdGp5RPIMEoarFpFEYPyYk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=TEPpjXLIs9byqt0abaNuedo/1qJwTDqwtPOKQJMD7SA/PBs7Jx822wcTNLgcIjbvub h0imY73+V+TzUr3FghAg0RJzJyiBStYf87VG2N2ls8lpz9/F1nSY8CG2G8W/oM3GnPLG adwv4IXWL4dF7+XuvxhLuxbc8mm+/p4pk056g= Original-Received: by 10.204.81.134 with SMTP id x6mr2062598bkk.32.1272237438162; Sun, 25 Apr 2010 16:17:18 -0700 (PDT) Original-Received: by 10.204.81.29 with HTTP; Sun, 25 Apr 2010 16:16:58 -0700 (PDT) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sun, 25 Apr 2010 19:18:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:36505 Archived-At: On Sun, Apr 25, 2010 at 02:01, Ethan wrote: > `untabify' sometimes causes the cursor to jump. If you have a buffer > like this, with (-!-) representing point: > > ^I(-!-)^ISome text some text some text > > And (for example) have a before-save-hook that calls untabify on the > whole buffer, the cursor will jump to the beginning of line. This is a > bit surprising. It can also happen in interactive use. In your example, if you select the first tab, with point just at the second one, and do M-x untabify, the cursor jumps to the beginning of the line. All in all, it is a bit surprising. If you put the cursor at the first t (in text), for example, the cursor does not jump. Why not? `save-excursion' saves the point, but the point was 8 and it is now 22... The problem can be trivially fixed by wrapping the tabify code in (let ((c (current-column))) ;;; tabify (move-to-column c)) as in the following patch, but perhaps there are cleaner ways. (You can do that in an around advice, as a workaround.) Juanma === modified file 'lisp/tabify.el' --- lisp/tabify.el 2010-01-13 08:35:10 +0000 +++ lisp/tabify.el 2010-04-25 22:53:06 +0000 @@ -34,19 +34,21 @@ START and END, rather than by the position of point and mark. The variable `tab-width' controls the spacing of tab stops." (interactive "r") - (save-excursion - (save-restriction - (narrow-to-region (point-min) end) - (goto-char start) - (while (search-forward "\t" nil t) ; faster than re-search - (forward-char -1) - (let ((tab-beg (point)) - (indent-tabs-mode nil) - column) - (skip-chars-forward "\t") - (setq column (current-column)) - (delete-region tab-beg (point)) - (indent-to column)))))) + (let ((c (current-column))) + (save-excursion + (save-restriction + (narrow-to-region (point-min) end) + (goto-char start) + (while (search-forward "\t" nil t) ; faster than re-search + (forward-char -1) + (let ((tab-beg (point)) + (indent-tabs-mode nil) + column) + (skip-chars-forward "\t") + (setq column (current-column)) + (delete-region tab-beg (point)) + (indent-to column))))) + (move-to-column c))) (defvar tabify-regexp " [ \t]+" "Regexp matching whitespace that tabify should consider.