Function: evil-ensure-column

evil-ensure-column is a macro defined in evil-common.el.

Signature

(evil-ensure-column &rest BODY)

Documentation

Execute BODY so that column after execution is correct.

If evil-start-of-line is nil, treat BODY as if it were a next-line command. This mostly copies the approach of Emacs' line-move-1, but is modified so it is more compatible with Evil's notion of EOL tracking.

Source Code

;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-common.el
(defmacro evil-ensure-column (&rest body)
  "Execute BODY so that column after execution is correct.
If `evil-start-of-line' is nil, treat BODY as if it were a `next-line' command.
This mostly copies the approach of Emacs' `line-move-1', but is modified
so it is more compatible with Evil's notion of EOL tracking."
  (declare (indent defun) (debug t))
  `(progn
     (unless evil-start-of-line
       (setq this-command 'next-line
             temporary-goal-column
             (cond ((memq last-command '(next-line previous-line))
                    temporary-goal-column)
                   ((and track-eol (eolp) (not (bolp))) most-positive-fixnum)
                   (t (current-column)))))
     ,@body
     (if evil-start-of-line
         (evil-first-non-blank)
       (line-move-to-column
        (or goal-column
            (if (consp temporary-goal-column)
                ;; Guard against a negative value as `temporary-goal-column'
                ;; may have a negative component when both `whitespace-mode'
                ;; and `display-line-numbers-mode' are enabled (#1297).
                (max 0 (+ (truncate (car temporary-goal-column))
                          (cdr temporary-goal-column)))
              temporary-goal-column))))))