Function: evil-ex-completion-at-point

evil-ex-completion-at-point is a byte-compiled function defined in evil-ex.el.

Signature

(evil-ex-completion-at-point)

Documentation

Function used for completion-at-point-functions in Ex state.

Aliases

evil-ex-command-completion-at-point (obsolete since 1.15.0)

Source Code

;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-ex.el
(cl-defun evil-ex-completion-at-point ()
  "Function used for `completion-at-point-functions' in Ex state."
  (cl-flet ((fix-beg (b) (min (save-excursion
                                (+ (goto-char b) (skip-chars-forward " \t\n\r")))
                              (point))))
    (pcase (nreverse (evil--ex-syntactic-context))
      ((or (and 'nil (let beg (minibuffer-prompt-end)))
           `((expression) (command . ,beg) . ,_)
           (and `((expression) (line) . ,_)
                (guard (looking-at-p "[ \t\n\r]*\\'"))
                (let beg (point))))
       (list (fix-beg beg) (point) (evil-ex-completion-table)))
      (`((expression) (argument . ,beg))
       (setq beg (fix-beg beg))
       ;; If it's an autoload, load the function; this allows external
       ;; packages to register autoloaded Ex commands which will be
       ;; loaded when ex argument completion is triggered.
       (let ((binding (evil-ex-binding evil--ex-cmd t))) (autoload-do-load binding))

       (let* ((binding (evil-ex-completed-binding evil--ex-cmd))
              (arg-type (evil-get-command-property binding :ex-arg))
              (arg-handler (cdr (assq arg-type evil-ex-argument-types))))
         (pcase (evil-ex-argument-handler-completer arg-handler)
           (`(collection . ,table) (list beg (point-max) table))
           (`(completion-at-point . ,completer)
            (save-restriction (narrow-to-region beg (point-max))
                              (funcall completer))))))
      (`((expression) (sexp . ,_))
       (when (fboundp 'elisp-completion-at-point) (elisp-completion-at-point))))))