Function: dabbrev-completion

dabbrev-completion is an autoloaded, interactive and byte-compiled function defined in dabbrev.el.gz.

Signature

(dabbrev-completion &optional ARG)

Documentation

Completion on current word.

Like M-/ (dabbrev-expand) but finds all expansions in the current buffer and presents suggestions for completion.

With a prefix argument ARG, it searches all buffers accepted by the function pointed out by dabbrev-friend-buffer-function to find the completions.

If the prefix argument is 16 (which comes from C-u (universal-argument) C-u (universal-argument)), then it searches *all* buffers.

Probably introduced at or before Emacs version 19.29.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/dabbrev.el.gz
;;;###autoload
(defun dabbrev-completion (&optional arg)
  "Completion on current word.
Like \\[dabbrev-expand] but finds all expansions in the current buffer
and presents suggestions for completion.

With a prefix argument ARG, it searches all buffers accepted by the
function pointed out by `dabbrev-friend-buffer-function' to find the
completions.

If the prefix argument is 16 (which comes from \\[universal-argument] \\[universal-argument]),
then it searches *all* buffers."
  (interactive "*P")
  (dabbrev--reset-global-variables)
  (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)))))
    (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)))