Function: isearch-fail-pos

isearch-fail-pos is a byte-compiled function defined in isearch.el.gz.

Signature

(isearch-fail-pos &optional MSG)

Documentation

Return position of first mismatch in search string, or nil if none.

If MSG is non-nil, use variable isearch-message(var)/isearch-message(fun), otherwise isearch-string.

Source Code

;; Defined in /usr/src/emacs/lisp/isearch.el.gz
(defun isearch-fail-pos (&optional msg)
  "Return position of first mismatch in search string, or nil if none.
If MSG is non-nil, use variable `isearch-message', otherwise `isearch-string'."
  (let ((cmds isearch-cmds)
	(curr-msg (if msg isearch-message isearch-string))
	succ-msg)
    (when (or (not isearch-success) isearch-error)
      (while (and cmds
		  (or (not (isearch--state-success (car cmds)))
		      (isearch--state-error (car cmds))))
        (pop cmds))
      (setq succ-msg (and cmds (if msg (isearch--state-message (car cmds))
				 (isearch--state-string (car cmds)))))
      (if (and (stringp succ-msg)
	       (< (length succ-msg) (length curr-msg))
	       (equal succ-msg
		      (substring curr-msg 0 (length succ-msg))))
	  (length succ-msg)
	0))))