Function: evil-ex-search-goto-offset

evil-ex-search-goto-offset is a byte-compiled function defined in evil-search.el.

Signature

(evil-ex-search-goto-offset OFFSET)

Documentation

Move point according to search OFFSET and set evil-this-type accordingly.

This function assumes that the current match data represents the current search result.

Source Code

;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-search.el
(defun evil-ex-search-goto-offset (offset)
  "Move point according to search OFFSET and set `evil-this-type' accordingly.
This function assumes that the current match data represents the
current search result."
  (unless (zerop (length offset))
    (let ((beg (match-beginning 0))
          (end (match-end 0)))
      (save-match-data
        (unless (string-match
                 "^\\([esb]\\)?\\(\\([-+]\\)?\\([0-9]*\\)\\)$"
                 offset)
          (user-error "Invalid search offset: %s" offset))
        (let ((count (if (= (match-beginning 4) (match-end 4))
                         (cond
                          ((not (match-beginning 3)) 0)
                          ((= (aref offset (match-beginning 3)) ?+) +1)
                          (t -1))
                       (string-to-number (match-string 2 offset)))))
          (cond
           ((not (match-beginning 1))
            (setq evil-this-type 'line)
            (forward-line count))
           ((= (aref offset (match-beginning 1)) ?e)
            (goto-char (+ end count -1))
            (setq evil-this-type 'inclusive))
           ((memq (aref offset (match-beginning 1)) '(?s ?b))
            (goto-char (+ beg count))
            (setq evil-this-type 'inclusive))))))))