GNU bug report logs -
#5805
23.1; abbrev-insert does not protext itself with save-excursion
Previous Next
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your bug report
#5805: 23.1; abbrev-insert does not protext itself with save-excursion
which was filed against the emacs package, has been closed.
The explanation is attached below, along with your original report.
If you require more details, please reply to 5805 <at> debbugs.gnu.org.
--
5805: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=5805
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
> --- 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 <monnier <at> iro.umontreal.ca>
+ * 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.
[Message part 3 (message/rfc822, inline)]
Try again...
-----Original Message-----
From: Mail Delivery Subsystem [mailto:Mailer-Daemon <at> Smallworld.co.uk]
Sent: 29 March 2010 13:07
To: andrewma <at> Smallworld.co.uk
Subject: Returned mail: Cannot send message within 3 days
The original message was received at Fri, 26 Mar 2010 12:06:32 +0100
(BST)
from shark [193.128.11.12]
----- The following addresses had permanent fatal errors -----
<bug-gnu-emacs <at> gnu.org>
----- Transcript of session follows -----
... while talking to eggs.gnu.org.:
>>> RCPT To:<bug-gnu-emacs <at> gnu.org>
<<< 451 Could not complete sender verify callout
<bug-gnu-emacs <at> gnu.org>... Deferred: 451 Could not complete sender
verify callout
Message could not be delivered for 3 days
Message will be deleted from queue
----- Original message follows -----
Return-Path: <andrewma <at> Smallworld.co.uk>
Received: from MAGUIRAN-CBG.smallworld.co.uk by
ultimate.Smallworld.co.uk (8.8.8+Sun/SWW-2.8-Gateway)
id MAA03728; Fri, 26 Mar 2010 12:06:32 GMT
Date: Fri, 26 Mar 2010 12:25:49 +0000
Message-Id:
<x768w9fuv5e.fsf <at> MAGUIRAN-CBG.i-did-not-set--mail-host-address--so-tickl
e-me>
From: andrew.maguire <at> ge.com
To: bug-gnu-emacs <at> gnu.org
Subject: 23.1; abbrev-insert does not protext itself with save-excursion
Reply-to: andrew.maguire <at> ge.com
I believe there is a regression/change of behaviour with the lisp
implementation
of the abbrev package compared with earlier Emacsen.
In our code we use abbrev to dynamically expand certain
keywords. However, the new lisp implementation is more
eager in finding things to check, ie. it is able to look back past
non-word characters to see if an abbrev is to be found.
In this situation it is essential to do save-excursion.
Ideally, either insert-abbrev should do a save-excursion itself or all
calls to it should.
In our code, expand-abbrev is call which internally calls abbrev-insert.
Alternatively, is it the recommendation for user code to surround all
"abbrev" calls with save-excursion now?
Thanks for you advice,
Andrwe Maguire
In GNU Emacs 23.1.1 (i386-mingw-nt5.1.2600)
of 2009-07-30 on SOFT-MJASON
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (4.4)'
Important settings:
value of $LC_ALL: nil
value of $LC_COLLATE: nil
value of $LC_CTYPE: nil
value of $LC_MESSAGES: nil
value of $LC_MONETARY: nil
value of $LC_NUMERIC: nil
value of $LC_TIME: nil
value of $LANG: ENG
value of $XMODIFIERS: nil
locale-coding-system: cp1252
default-enable-multibyte-characters: t
Major mode: Gis
Minor modes in effect:
shell-dirtrack-mode: t
diff-auto-refine-mode: t
show-paren-mode: t
mouse-wheel-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
global-auto-composition-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
line-number-mode: t
transient-mark-mode: t
abbrev-mode: t
Recent input:
! C-c C-c C-x C-f c b . e l <return> C-s M-p M-p M-p
M-p M-p M-p M-p M-p M-p M-p C-g C-x 2 C-x b <up> <return>
<prior> <prior> <prior> <prior> <prior> <prior> <prior>
<prior> <down-mouse-1> <mouse-1> <down-mouse-1> <mouse-1>
C-s C-w C-w C-w C-w C-w <help-echo> <down-mouse-1>
<mouse-1> C-s C-s M-x <up> <return> SPC C-x v v SPC
<down> <left> SPC C-k <S-insert> <down> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <backspace> <backspace>
<backspace> <backspace> <backspace> <S-insert> <left>
<left> <backspace> 2 <up> <up> <up> C-a <C-right> <C-left>
<left> C-x o <up> <C-left> <C-left> <left> M-x <up>
<return> <help-echo> <down-mouse-1> <mouse-1> <double-down-mouse-1>
<double-mouse-1> <triple-down-mouse-1> <triple-mouse-1>
<help-echo> <down-mouse-2> <mouse-2> C-k C-k <tab>
<help-echo> <down-mouse-1> <mouse-1> <wheel-down> <help-echo>
<help-echo> <down-mouse-1> <mouse-1> <double-down-mouse-1>
<double-mouse-1> <help-echo> <down-mouse-2> <mouse-2>
<down-mouse-1> <mouse-1> <double-down-mouse-1> <double-mouse-1>
C-w C-x C-s <wheel-up> <wheel-up> <wheel-up> <wheel-up>
<double-wheel-up> <wheel-down> <double-wheel-down>
<wheel-down> <wheel-down> C-x v v C-x b <return> C-M-b
<prior> <prior> <up> <up> <up> <up> C-g C-x o <prior>
<prior> <prior> <prior> M-x <up> <return> C-x v v M-p
<up> <up> <C-right> <right> <right> C-k c b <M-prior>
<M-prior> - m a g i k - e d i f f - m e t h o d s :
SPC r e t a i n SPC w i n d o w SPC c o n f i g u r
a t i o n SPC i f SPC m e t h o d SPC n o t SPC f o
u n d C-c C-c <next> <down-mouse-1> <mouse-1> C-x k
<return> <home> <C-home> <down> <down> <down> M-x e
r a s e <tab> <return> SPC <f4> b C-x k <return> <help-echo>
<help-echo> <help-echo> <help-echo> <help-echo> <help-echo>
<menu-bar> <help-menu> <send-emacs-bug-report>
Recent messages:
Press C-c C-c when you are done editing.
Enter a change comment. Type C-c C-c when done
Quit
Mark set [2 times]
Press C-c C-c when you are done editing.
Enter a change comment. Type C-c C-c when done
Comment 1
Checking in
u:/tools/general/emacs/smallworld_lisp/smallworld/swlisp/cb.el...done
Mark set
Type y, n, ! or SPC (the space bar):
This bug report was last modified 13 years and 322 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.