1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-21 06:55:39 +00:00

(dabbrev-completion): Fix bug#45768

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.
This commit is contained in:
Stefan Monnier 2022-05-07 10:21:26 -04:00
parent 7e97b33aa6
commit 19d1b9275e
2 changed files with 12 additions and 4 deletions

View File

@ -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,

View 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)