Function: dabbrev-capf
dabbrev-capf is a byte-compiled function defined in dabbrev.el.gz.
Signature
(dabbrev-capf)
Documentation
Dabbrev completion function for completion-at-point-functions.
This function has :around advice: dabbrev-capf@git-commit.
Probably introduced at or before Emacs version 29.1.
Source Code
;; Defined in /usr/src/emacs/lisp/dabbrev.el.gz
(defun dabbrev-capf ()
"Dabbrev completion function for `completion-at-point-functions'."
;; Don't reset the vars if we're in the "same" completion, especially since
;; they may have been set to different values, e.g. if the user passes
;; a non-nil ARG to `dabbrev-completion'.
(unless (and (markerp dabbrev--last-abbrev-location)
(eq (current-buffer)
(marker-buffer dabbrev--last-abbrev-location))
(= (point) dabbrev--last-abbrev-location))
(dabbrev--reset-global-variables)
;; FIXME: Contrary to `dabbrev-completion', the CAPF protocol doesn't
;; have a way to control the scope of the search. We just default
;; to confine it to the current buffer.
(setq dabbrev--check-other-buffers nil)
(setq dabbrev--check-all-buffers nil)
(setq dabbrev--last-abbrev-location (point-marker)))
(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))
(list 'uninitialized)
(table
(lambda (s p a)
(if (eq a 'metadata)
`(metadata (cycle-sort-function . ,#'identity)
(category . dabbrev))
(when (eq list 'uninitialized)
(save-excursion
;;--------------------------------
;; New abbreviation to expand.
;;--------------------------------
(setq dabbrev--last-abbreviation abbrev)
;; Find all expansion
(let ((completion-list
(dabbrev--find-all-expansions abbrev ignore-case-p))
(completion-ignore-case ignore-case-p))
(or (consp completion-list)
(user-error "No dynamic expansion for \"%s\" found%s"
abbrev
(if dabbrev--check-other-buffers
"" " in this-buffer")))
(setq list
(cond
((not (and ignore-case-p dabbrev-case-replace))
completion-list)
((string= abbrev (upcase abbrev))
(mapcar #'upcase completion-list))
((string= (substring abbrev 0 1)
(upcase (substring abbrev 0 1)))
(mapcar #'capitalize completion-list))
(t
(mapcar #'downcase completion-list)))))))
(complete-with-action a list s p)))))
(list beg end table)))