Function: evil--get-block-range

evil--get-block-range is a byte-compiled function defined in evil-common.el.

Signature

(evil--get-block-range OP CL SELECTION-TYPE)

Documentation

Return the exclusive range of a visual selection.

OP and CL are pairs of buffer positions for the opening and closing delimiter of a range. SELECTION-TYPE is the desired type of selection. It is a symbol that determines which parts of the block are selected. If it is inclusive or t the returned range is (cons (car OP) (cdr CL)). If it is exclusive or nil the returned range is (cons (cdr OP) (car CL)). If it is exclusive-line the returned range will skip whitespace at the end of the line of OP and at the beginning of the line of CL.

Source Code

;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-common.el
(defun evil--get-block-range (op cl selection-type)
  "Return the exclusive range of a visual selection.
OP and CL are pairs of buffer positions for the opening and
closing delimiter of a range. SELECTION-TYPE is the desired type
of selection.  It is a symbol that determines which parts of the
block are selected.  If it is `inclusive' or t the returned range
is \(cons (car OP) (cdr CL)). If it is `exclusive' or nil the
returned range is (cons (cdr OP) (car CL)).  If it is
`exclusive-line' the returned range will skip whitespace at the
end of the line of OP and at the beginning of the line of CL."
  (cond
   ((memq selection-type '(inclusive t)) (cons (car op) (cdr cl)))
   ((memq selection-type '(exclusive nil)) (cons (cdr op) (car cl)))
   ((eq selection-type 'exclusive-line)
    (let ((beg (cdr op))
          (end (car cl)))
      (save-excursion
        (goto-char beg)
        (when (and (eolp) (not (eobp)))
          (setq beg (line-beginning-position 2)))
        (goto-char end)
        (skip-chars-backward " \t")
        (when (bolp)
          (setq end (point))
          (goto-char beg)
          (when (and (not (bolp)) (< beg end))
            (setq end (1- end)))))
      (cons beg end)))
   (t (user-error "Unknown selection-type `%s'" selection-type))))