Function: evil--ex-update

evil--ex-update is a byte-compiled function defined in evil-ex.el.

Signature

(evil--ex-update &optional BEG END OLD-LEN)

Documentation

Update Ex variables when the minibuffer changes.

This function is usually called from after-change-functions hook. If BEG is non-nil (which is the case when called from after-change-functions), then an error description is shown in case of incomplete or unknown commands.

Source Code

;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-ex.el
(defun evil--ex-update (&optional beg _end _old-len)
  "Update Ex variables when the minibuffer changes.
This function is usually called from `after-change-functions'
hook. If BEG is non-nil (which is the case when called from
`after-change-functions'), then an error description is shown
in case of incomplete or unknown commands."
  (when (and beg (eq this-command #'self-insert-command))
    (let ((cmd (lookup-key evil-ex-shortcut-map (minibuffer-contents-no-properties))))
      (when (commandp cmd)
        (setq evil--ex-shortcut-command cmd)
        (exit-minibuffer))))

  (setq evil--ex-cmd nil)
  (let ((expr (save-excursion (goto-char (minibuffer-prompt-end))
                              (evil-ex-parse)))
        func handler current-prefix-arg evil-ex-range evil-ex-bang evil-ex-argument)
    (when (eq (car expr) #'evil-ex-call-command)
      (with-current-buffer evil-ex-original-buffer
        (let* ((range (eval (nth 1 expr) t))
               (count (when (integerp range) range)))
          (setq current-prefix-arg count
                evil-ex-range (if count (evil-ex-range count count) range)
                evil--ex-cmd (eval (nth 2 expr) t)
                evil-ex-bang (evil--ex-bang-p evil--ex-cmd)
                evil-ex-argument (eval (nth 3 expr) t))))
      (cond
       ((not beg))
       ;; Test the current command when called from `after-change-functions'
       ((setq func (evil-ex-completed-binding evil--ex-cmd t))
        ;; Update argument handler
        (let ((type (evil-get-command-property func :ex-arg)))
          (when type (setq handler (cdr (assq type evil-ex-argument-types)))))
        (if (eq handler evil--ex-argument-handler)
            (let ((runner (evil-ex-argument-handler-runner handler)))
              (when runner (funcall runner 'update evil-ex-argument)))
          (let ((runner (evil-ex-argument-handler-runner evil--ex-argument-handler)))
            (when runner (funcall runner 'stop)))
          (setq evil--ex-argument-handler handler)
          (let ((runner (evil-ex-argument-handler-runner handler)))
            (when runner (funcall runner 'start evil-ex-argument)))))
       (t (let* ((evil-ex-complete-emacs-commands 'in-turn)
                 (prefix (try-completion evil--ex-cmd (evil-ex-completion-table))))
            (cond ((stringp prefix) (evil-ex-echo "Incomplete command"))
                  ((null prefix) (evil-ex-echo "Unknown command")))))))))