From 19d1b9275e7565fb67fd9e0587f08837ba8a3220 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Sat, 7 May 2022 10:21:26 -0400 Subject: [PATCH] (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. --- etc/NEWS | 3 +++ lisp/dabbrev.el | 13 +++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 671c30772eb..6a60231b3aa 100644 --- 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, diff --git a/lisp/dabbrev.el b/lisp/dabbrev.el index 06a8ead8340..b04128cf677 100644 --- a/lisp/dabbrev.el +++ b/lisp/dabbrev.el @@ -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) -- 2.39.2