aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorAlan Third2019-12-05 13:14:00 +0000
committerAlan Third2019-12-10 20:38:21 +0000
commit33a37360defdc08a5d8eeabffef96f8571d3b608 (patch)
tree6fe807ff4f3c2cdc644d836f58df228145606b36 /lisp
parentfbf9fea4fdad467429058077b8087dbd0758b964 (diff)
downloademacs-33a37360defdc08a5d8eeabffef96f8571d3b608.tar.gz
emacs-33a37360defdc08a5d8eeabffef96f8571d3b608.zip
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')
-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."
323;; Same as dabbrev-check-other-buffers, but is set for every expand. 323;; Same as dabbrev-check-other-buffers, but is set for every expand.
324(defvar dabbrev--check-other-buffers dabbrev-check-other-buffers) 324(defvar dabbrev--check-other-buffers dabbrev-check-other-buffers)
325 325
326;; Same as dabbrev-check-all-buffers, but is set for every expand.
327(defvar dabbrev--check-all-buffers dabbrev-check-all-buffers)
328
326;; The regexp for recognizing a character in an abbreviation. 329;; The regexp for recognizing a character in an abbreviation.
327(defvar dabbrev--abbrev-char-regexp nil) 330(defvar dabbrev--abbrev-char-regexp nil)
328 331
@@ -380,10 +383,7 @@ If the prefix argument is 16 (which comes from \\[universal-argument] \\[univers
380then it searches *all* buffers." 383then it searches *all* buffers."
381 (interactive "*P") 384 (interactive "*P")
382 (dabbrev--reset-global-variables) 385 (dabbrev--reset-global-variables)
383 (let* ((dabbrev-check-other-buffers (and arg t)) 386 (let* ((abbrev (dabbrev--abbrev-at-point))
384 (dabbrev-check-all-buffers
385 (and arg (= (prefix-numeric-value arg) 16)))
386 (abbrev (dabbrev--abbrev-at-point))
387 (beg (progn (search-backward abbrev) (point))) 387 (beg (progn (search-backward abbrev) (point)))
388 (end (progn (search-forward abbrev) (point))) 388 (end (progn (search-forward abbrev) (point)))
389 (ignore-case-p (dabbrev--ignore-case-p abbrev)) 389 (ignore-case-p (dabbrev--ignore-case-p abbrev))
@@ -420,6 +420,9 @@ then it searches *all* buffers."
420 (t 420 (t
421 (mapcar #'downcase completion-list))))))) 421 (mapcar #'downcase completion-list)))))))
422 (complete-with-action a list s p))))) 422 (complete-with-action a list s p)))))
423 (setq dabbrev--check-other-buffers (and arg t))
424 (setq dabbrev--check-all-buffers
425 (and arg (= (prefix-numeric-value arg) 16)))
423 (completion-in-region beg end table))) 426 (completion-in-region beg end table)))
424 427
425;;;###autoload 428;;;###autoload
@@ -623,7 +626,8 @@ all skip characters."
623 dabbrev--last-buffer-found nil 626 dabbrev--last-buffer-found nil
624 dabbrev--abbrev-char-regexp (or dabbrev-abbrev-char-regexp 627 dabbrev--abbrev-char-regexp (or dabbrev-abbrev-char-regexp
625 "\\sw\\|\\s_") 628 "\\sw\\|\\s_")
626 dabbrev--check-other-buffers dabbrev-check-other-buffers)) 629 dabbrev--check-other-buffers dabbrev-check-other-buffers
630 dabbrev--check-all-buffers dabbrev-check-all-buffers))
627 631
628(defun dabbrev--select-buffers () 632(defun dabbrev--select-buffers ()
629 "Return a list of other buffers to search for a possible abbrev. 633 "Return a list of other buffers to search for a possible abbrev.
@@ -772,7 +776,7 @@ of the start of the occurrence."
772 ;; If dabbrev-check-all-buffers, tack on all the other 776 ;; If dabbrev-check-all-buffers, tack on all the other
773 ;; buffers at the end of the list, except those which are 777 ;; buffers at the end of the list, except those which are
774 ;; specifically to be ignored. 778 ;; specifically to be ignored.
775 (if dabbrev-check-all-buffers 779 (if dabbrev--check-all-buffers
776 (setq list 780 (setq list
777 (append list 781 (append list
778 (dabbrev-filter-elements 782 (dabbrev-filter-elements