]> git.eshelyaron.com Git - emacs.git/commitdiff
(dabbrev-completion): Fix bug#45768
authorStefan Monnier <monnier@iro.umontreal.ca>
Sat, 7 May 2022 14:21:26 +0000 (10:21 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Sat, 7 May 2022 14:21:26 +0000 (10:21 -0400)
Make `dabbrev-completion` go through `completion-at-point` so that
it interacts correctly with Icomplete.  Export a new
`completion-capf` function while we're at it, since it can be useful
elsewhere.

* lisp/dabbrev.el (dabbrev-capf): New function,
extracted from `dabbrev-completion`.
(dabbrev-completion): Use it.

etc/NEWS
lisp/dabbrev.el

index 671c30772eb0e76dc7b3e489c5a54df50385b9f1..6a60231b3aad69d114931665c373af4223ae28e9 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -742,6 +742,9 @@ this script.
 
 ** dabbrev
 
+---
+*** New function 'dabbrev-capf' for use on 'completion-at-point-functions'
+
 +++
 *** New user option 'dabbrev-ignored-buffer-modes'.
 Buffers with major modes in this list will be ignored.  By default,
index 06a8ead834097daeecc636fcea06d3fe23ba5288..b04128cf6774d9a499f10a34219cd2e227b1da5c 100644 (file)
@@ -392,6 +392,14 @@ If the prefix argument is 16 (which comes from \\[universal-argument] \\[univers
 then it searches *all* buffers."
   (interactive "*P")
   (dabbrev--reset-global-variables)
+  (setq dabbrev--check-other-buffers (and arg t))
+  (setq dabbrev--check-all-buffers
+        (and arg (= (prefix-numeric-value arg) 16)))
+  (let ((completion-at-point-functions '(dabbrev-capf)))
+    (completion-at-point)))
+
+(defun dabbrev-capf ()
+  "Dabbrev completion function for `completion-at-point-functions'."
   (let* ((abbrev (dabbrev--abbrev-at-point))
          (beg (progn (search-backward abbrev) (point)))
          (end (progn (search-forward abbrev) (point)))
@@ -429,10 +437,7 @@ 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)))
+    (list beg end table)))
 
 ;;;###autoload
 (defun dabbrev-expand (arg)