GNU bug report logs -
#1948
confusion and bug in dabbrev.el
Previous Next
Reported by: Peter Tury <tury.peter <at> gmail.com>
Date: Sun, 18 Jan 2009 19:45:04 UTC
Severity: normal
Tags: confirmed, fixed, patch
Fixed in version 25.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #25 received at 1948 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Peter Tury said:
> However, the more serious problem is that it "forgets" such
> eliminations when it searches for `old' expansion in case of repeated
> calls of `dabbrev-expand' (i.e. when the check "(eq last-command
> this-command)" in this function results t) what results in weird text
> in some cases.
I think I've got a fix for this.
The problem is that dabbrev--substitute-expansion alters EXPANSION
before using it in the substitution, but dabbrev-expand has no idea that
it's done this, so it assumes the unaltered EXPANSION is still valid and
saves it.
The patch makes dabbrev--substitute-expansion return EXPANSION, and
dabbrev-expand saves that version instead.
I considered making a new function to remove the whitespace and using it
in both dabbrev-expand and dabbrev--substitute-expansion, but returning
the value actually used strikes me as safer, in case anything else is
done to it.
[0001-Always-save-the-actual-expansion.patch (text/plain, inline)]
From 9ef22a911d58f772265bc1fde2608ea135a4dea2 Mon Sep 17 00:00:00 2001
From: Alan Third <alan <at> idiocy.org>
Date: Sat, 30 Jan 2016 00:38:32 +0000
Subject: [PATCH] Always save the actual expansion
lisp/dabbrev.el (dabbrev--substitute-expansion): Return EXPANSION after
any processing.
lisp/dabbrev.el (dabbrev-expand): Set EXPANSION to the return value of
DABBREV--SUBSTITUTE-EXPANSION.
---
lisp/dabbrev.el | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/lisp/dabbrev.el b/lisp/dabbrev.el
index 3557041..d9f36b1 100644
--- a/lisp/dabbrev.el
+++ b/lisp/dabbrev.el
@@ -546,8 +546,8 @@ dabbrev-expand
(copy-marker dabbrev--last-expansion-location)))
;; Success: stick it in and return.
(setq buffer-undo-list (cons orig-point buffer-undo-list))
- (dabbrev--substitute-expansion old abbrev expansion
- record-case-pattern)
+ (setq expansion (dabbrev--substitute-expansion old abbrev expansion
+ record-case-pattern))
;; Save state for re-expand.
(setq dabbrev--last-expansion expansion)
@@ -902,7 +902,9 @@ dabbrev--substitute-expansion
;; and (2) the replacement itself is all lower case.
(dabbrev--safe-replace-match expansion
(not use-case-replace)
- t)))
+ t))
+ ;; Return the expansion actually used.
+ expansion)
;;;----------------------------------------------------------------
--
2.5.4 (Apple Git-61)
[Message part 3 (text/plain, inline)]
--
Alan Third
This bug report was last modified 9 years and 143 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.