From: Alan Third <alan@idiocy.org>
To: 1948@debbugs.gnu.org
Cc: Lars Ingebrigtsen <larsi@gnus.org>
Subject: bug#1948: [PATCH] Always save the actual expansion (bug#1948)
Date: Tue, 1 Mar 2016 18:19:42 +0000 [thread overview]
Message-ID: <20160301181942.GA98050@galloway.idiocy.org> (raw)
In-Reply-To: <b5accf970901181137g45f24159pa31b6b0b7a8c0fec@mail.gmail.com>
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.
test/automated/dabbrev-tests.el (dabbrev-expand-test): Test for bug#1948.
---
lisp/dabbrev.el | 8 +++++---
test/automated/dabbrev-tests.el | 42 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+), 3 deletions(-)
create mode 100644 test/automated/dabbrev-tests.el
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)
;;;----------------------------------------------------------------
diff --git a/test/automated/dabbrev-tests.el b/test/automated/dabbrev-tests.el
new file mode 100644
index 0000000..9c7a838
--- /dev/null
+++ b/test/automated/dabbrev-tests.el
@@ -0,0 +1,42 @@
+;;; dabbrev-tests.el --- Test suite for dabbrev.
+
+;; Copyright (C) 2016 Free Software Foundation, Inc.
+
+;; Author: Alan Third <alan@idiocy.org>
+;; Keywords: dabbrev
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;; Code:
+
+(require 'ert)
+(require 'dabbrev)
+
+(ert-deftest dabbrev-expand-test ()
+ "Test for bug#1948.
+When DABBREV-ELIMINATE-NEWLINES is non-nil (the default),
+repeated calls to DABBREV-EXPAND can result in the source of
+first expansion being replaced rather than the destination."
+ (with-temp-buffer
+ (insert "ab x\na\nab y")
+ (goto-char 8)
+ (save-window-excursion
+ (set-window-buffer nil (current-buffer))
+ ;; M-/ SPC M-/ M-/
+ (execute-kbd-macro "\257 \257\257"))
+ (should (string= (buffer-string) "ab x\nab y\nab y"))))
--
Hope I've put the test file in the right place.
--
Alan Third
next prev parent reply other threads:[~2016-03-01 18:19 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-18 19:37 bug#1948: confusion and bug in dabbrev.el Peter Tury
2012-09-12 19:22 ` Fred
2016-01-09 23:36 ` Alan J Third
2016-01-10 13:41 ` Alan J Third
2016-01-30 1:01 ` Alan Third
2016-01-30 2:00 ` Drew Adams
2016-01-30 11:59 ` Alan Third
2016-01-30 12:25 ` Eli Zaretskii
2016-01-30 17:37 ` Drew Adams
2016-02-29 4:18 ` Lars Ingebrigtsen
2016-02-29 4:18 ` Lars Ingebrigtsen
2016-03-01 3:16 ` Glenn Morris
2016-03-01 3:16 ` Glenn Morris
2016-03-01 3:27 ` Lars Ingebrigtsen
2016-01-30 1:01 ` Alan Third
2016-03-01 18:19 ` Alan Third [this message]
2016-03-02 17:25 ` bug#1948: [PATCH] Always save the actual expansion (bug#1948) Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160301181942.GA98050@galloway.idiocy.org \
--to=alan@idiocy.org \
--cc=1948@debbugs.gnu.org \
--cc=larsi@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.