summaryrefslogtreecommitdiff
path: root/lisp/dabbrev.el
diff options
context:
space:
mode:
authorAlan Third <alan@idiocy.org>2019-12-05 13:14:00 +0000
committerAlan Third <alan@idiocy.org>2019-12-10 20:38:21 +0000
commit33a37360defdc08a5d8eeabffef96f8571d3b608 (patch)
tree6fe807ff4f3c2cdc644d836f58df228145606b36 /lisp/dabbrev.el
parentfbf9fea4fdad467429058077b8087dbd0758b964 (diff)
downloademacs-33a37360defdc08a5d8eeabffef96f8571d3b608.tar.gz
Fix dabbrev-completion (bug#17899)
* lisp/dabbrev.el (dabbrev--check-all-buffers): Add new variable. (dabbrev-completion): Lexical scoping means we can't use let to override global variables, so use setq. (dabbrev--reset-global-variables): Reset new variable. (dabbrev--make-friend-buffer-list): Use new variable. * test/lisp/dabbrev-tests.el (dabbrev-completion-test): (dabbrev-completion-test-with-argument): New tests.
Diffstat (limited to 'lisp/dabbrev.el')
-rw-r--r--lisp/dabbrev.el16
1 files changed, 10 insertions, 6 deletions
diff --git a/lisp/dabbrev.el b/lisp/dabbrev.el
index 23abe7ae165..0cb9b0b824a 100644
--- a/lisp/dabbrev.el
+++ b/lisp/dabbrev.el
@@ -323,6 +323,9 @@ this list."
;; Same as dabbrev-check-other-buffers, but is set for every expand.
(defvar dabbrev--check-other-buffers dabbrev-check-other-buffers)
+;; Same as dabbrev-check-all-buffers, but is set for every expand.
+(defvar dabbrev--check-all-buffers dabbrev-check-all-buffers)
+
;; The regexp for recognizing a character in an abbreviation.
(defvar dabbrev--abbrev-char-regexp nil)
@@ -380,10 +383,7 @@ If the prefix argument is 16 (which comes from \\[universal-argument] \\[univers
then it searches *all* buffers."
(interactive "*P")
(dabbrev--reset-global-variables)
- (let* ((dabbrev-check-other-buffers (and arg t))
- (dabbrev-check-all-buffers
- (and arg (= (prefix-numeric-value arg) 16)))
- (abbrev (dabbrev--abbrev-at-point))
+ (let* ((abbrev (dabbrev--abbrev-at-point))
(beg (progn (search-backward abbrev) (point)))
(end (progn (search-forward abbrev) (point)))
(ignore-case-p (dabbrev--ignore-case-p abbrev))
@@ -420,6 +420,9 @@ then it searches *all* buffers."
(t
(mapcar #'downcase completion-list)))))))
(complete-with-action a list s p)))))
+ (setq dabbrev--check-other-buffers (and arg t))
+ (setq dabbrev--check-all-buffers
+ (and arg (= (prefix-numeric-value arg) 16)))
(completion-in-region beg end table)))
;;;###autoload
@@ -623,7 +626,8 @@ all skip characters."
dabbrev--last-buffer-found nil
dabbrev--abbrev-char-regexp (or dabbrev-abbrev-char-regexp
"\\sw\\|\\s_")
- dabbrev--check-other-buffers dabbrev-check-other-buffers))
+ dabbrev--check-other-buffers dabbrev-check-other-buffers
+ dabbrev--check-all-buffers dabbrev-check-all-buffers))
(defun dabbrev--select-buffers ()
"Return a list of other buffers to search for a possible abbrev.
@@ -772,7 +776,7 @@ of the start of the occurrence."
;; If dabbrev-check-all-buffers, tack on all the other
;; buffers at the end of the list, except those which are
;; specifically to be ignored.
- (if dabbrev-check-all-buffers
+ (if dabbrev--check-all-buffers
(setq list
(append list
(dabbrev-filter-elements