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'."
  (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)))