Function: cider-repl--position-in-history

cider-repl--position-in-history is a byte-compiled function defined in cider-repl.el.

Signature

(cider-repl--position-in-history START-POS DIRECTION REGEXP)

Documentation

Return the position of the history item starting at START-POS.

Search in DIRECTION for REGEXP. Return -1 resp the length of the history if no item matches.

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20260414.1619/cider-repl.el
(defun cider-repl--position-in-history (start-pos direction regexp)
  "Return the position of the history item starting at START-POS.
Search in DIRECTION for REGEXP.
Return -1 resp the length of the history if no item matches."
  ;; Loop through the history list looking for a matching line
  (let* ((step (pcase direction
                 ('forward -1)
                 ('backward 1)
                 (_ (error "Invalid direction: %s" direction))))
         (history cider-repl-input-history)
         (len (length history)))
    (cl-loop for pos = (+ start-pos step) then (+ pos step)
             if (< pos 0) return -1
             if (<= len pos) return len
             if (string-match-p regexp (nth pos history)) return pos)))