Function: evil-visual-pre-command

evil-visual-pre-command is a byte-compiled function defined in evil-states.el.

Signature

(evil-visual-pre-command &optional COMMAND)

Documentation

Run before each COMMAND in Visual state.

Expand the region to the selection unless COMMAND is a motion.

Source Code

;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-states.el
(defun evil-visual-pre-command (&optional command)
  "Run before each COMMAND in Visual state.
Expand the region to the selection unless COMMAND is a motion."
  (when (evil-visual-state-p)
    (setq command (or command this-command))
    (if (and evil-transient-mouse-selection
             evil--region-from-mouse
             (not (rassq command evil-visual-alist)))
        (progn (setq evil--region-from-mouse nil)
               (evil-exit-visual-state))
      (when (and evil-transient-mouse-selection
                 evil--region-from-mouse
                 (rassq command evil-visual-alist))
        (setq evil-visual-selection nil ;; maintain visual state
              evil--region-from-mouse nil))
      (when evil-visual-x-select-timer
        (cancel-timer evil-visual-x-select-timer))
      (unless (evil-get-command-property command :keep-visual)
        (evil-visual-update-x-selection)
        (evil-visual-expand-region
         ;; exclude final newline from linewise selection
         ;; unless the command has real need of it
         (and (eq (evil-visual-type) 'line)
              (evil-get-command-property command :exclude-newline)))))))