From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#5805: 23.3 abbrev-insert needs a limited save-excursion Date: Fri, 08 Jul 2011 10:43:18 -0400 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1310136274 23552 80.91.229.12 (8 Jul 2011 14:44:34 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 8 Jul 2011 14:44:34 +0000 (UTC) Cc: 5805-done@debbugs.gnu.org To: Bob Nnamtrop Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jul 08 16:44:29 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QfCI8-00065B-Cg for geb-bug-gnu-emacs@m.gmane.org; Fri, 08 Jul 2011 16:44:28 +0200 Original-Received: from localhost ([::1]:42582 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QfCI7-0001t8-AI for geb-bug-gnu-emacs@m.gmane.org; Fri, 08 Jul 2011 10:44:27 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:53653) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QfCHk-0001sY-V1 for bug-gnu-emacs@gnu.org; Fri, 08 Jul 2011 10:44:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QfCHj-00065q-3C for bug-gnu-emacs@gnu.org; Fri, 08 Jul 2011 10:44:04 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:43133) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QfCHi-00065h-Rp for bug-gnu-emacs@gnu.org; Fri, 08 Jul 2011 10:44:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1QfCHi-0001Ux-Cl for bug-gnu-emacs@gnu.org; Fri, 08 Jul 2011 10:44:02 -0400 Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Fri, 08 Jul 2011 14:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 5805 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Mail-Followup-To: 5805@debbugs.gnu.org, monnier@iro.umontreal.ca Original-Received: via spool by 5805-done@debbugs.gnu.org id=D5805.13101362145713 (code D ref 5805); Fri, 08 Jul 2011 14:44:02 +0000 Original-Received: (at 5805-done) by debbugs.gnu.org; 8 Jul 2011 14:43:34 +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 1QfCHF-0001U5-WB for submit@debbugs.gnu.org; Fri, 08 Jul 2011 10:43:34 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QfCHD-0001Tt-HI for 5805-done@debbugs.gnu.org; Fri, 08 Jul 2011 10:43:32 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EAFgXF05MCqt8/2dsb2JhbABTp0V4y2qGOASefYQv X-IronPort-AV: E=Sophos;i="4.65,499,1304308800"; d="scan'208";a="123777448" Original-Received: from 76-10-171-124.dsl.teksavvy.com (HELO pastel.home) ([76.10.171.124]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 08 Jul 2011 10:43:18 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 29BFE59160; Fri, 8 Jul 2011 10:43:18 -0400 (EDT) In-Reply-To: (Bob Nnamtrop's message of "Thu, 7 Jul 2011 08:48:36 -0600") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Fri, 08 Jul 2011 10:44:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.43 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: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:48249 Archived-At: > --- 23.3/abbrev.el 2011-07-07 08:16:16.000000000 -0600 > +++ 23.3.fix/abbrev.el 2011-07-07 08:43:24.000000000 -0600 > @@ -713,6 +713,7 @@ > ;; If this abbrev has an expansion, delete the abbrev > ;; and insert the expansion. > (when (stringp (symbol-value abbrev)) > + (save-excursion > (goto-char wordstart) > ;; Insert at beginning so that markers at the end (e.g. point) > ;; are preserved. > @@ -741,7 +742,7 @@ > (skip-syntax-forward "^w" (1- end)) > ;; Change just that. > (upcase-initials-region (point) (1+ (point))) > - (goto-char end)))))) > + (goto-char end))))))) > ;; Now point is at the end of the expansion and the beginning is > ;; in last-abbrev-location. This can't be right, as can be seen in the comment right here: after this (goto-char end), the rest of the code expects point to be "at the end of the expansion". I installed the ugly patch below instead. Stefan === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-07-08 14:25:25 +0000 +++ lisp/ChangeLog 2011-07-08 14:41:48 +0000 @@ -5,6 +5,8 @@ 2011-07-08 Stefan Monnier + * abbrev.el (expand-abbrev): Try to preserve point (bug#5805). + * vc/vc-bzr.el (vc-bzr-revision-keywords): Remove svn, it's only provided by a particular plugin. === modified file 'lisp/abbrev.el' --- lisp/abbrev.el 2011-07-05 15:31:22 +0000 +++ lisp/abbrev.el 2011-07-08 14:41:16 +0000 @@ -814,6 +814,8 @@ (destructuring-bind (&optional sym name wordstart wordend) (abbrev--before-point) (when sym + (let ((startpos (copy-marker (point) t)) + (endmark (copy-marker wordend t))) (unless (or ;; executing-kbd-macro noninteractive (window-minibuffer-p (selected-window))) @@ -826,7 +828,14 @@ (setq last-abbrev-location wordstart) ;; If this abbrev has an expansion, delete the abbrev ;; and insert the expansion. - (abbrev-insert sym name wordstart wordend))))) + (prog1 + (abbrev-insert sym name wordstart wordend) + ;; Yuck!! If expand-abbrev is called with point slightly + ;; further than the end of the abbrev, move point back to + ;; where it started. + (if (and (> startpos endmark) + (= (point) endmark)) ;Obey skeletons that move point. + (goto-char startpos)))))))) (defun unexpand-abbrev () "Undo the expansion of the last abbrev that expanded.