Function: evil-narrow-to-line

evil-narrow-to-line is a macro defined in evil-macros.el.

Signature

(evil-narrow-to-line &rest BODY)

Documentation

Narrow BODY to the current line.

BODY will signal beginning-of-line or end-of-line upon reaching the beginning or end of the current line.

Source Code

;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-macros.el
(defmacro evil-narrow-to-line (&rest body)
  "Narrow BODY to the current line.
BODY will signal `beginning-of-line' or `end-of-line' upon reaching
the beginning or end of the current line."
  (declare (indent defun) (debug t))
  `(cl-destructuring-bind (beg end &rest) (evil-line-expand (point) (point))
     (when (save-excursion (goto-char end) (bolp))
       (setq end (max beg (1- end))))
     ;; Do not include the newline in Normal state
     (or evil-move-beyond-eol
         (evil-visual-state-p) (evil-operator-state-p)
         (setq end (max beg (1- end))))
     (evil-with-restriction beg end
       (condition-case err
           (progn ,@body)
         (beginning-of-buffer
          (signal (if (= (point-min) beg) 'beginning-of-line (car err))
                  (cdr err)))
         (end-of-buffer
          (signal (if (= (point-max) end) 'end-of-line (car err))
                  (cdr err)))))))