Function: ebrowse-find-pattern
ebrowse-find-pattern is a byte-compiled function defined in
ebrowse.el.gz.
Signature
(ebrowse-find-pattern &optional POSITION INFO)
Documentation
Find a pattern.
This is a kluge: Ebrowse allows you to find or view a file containing
a pattern. To be able to do a search in a viewed buffer,
view-mode-hook is temporarily set to this function;
ebrowse-temp-position-to-view holds what to search for.
INFO is a list (TREE-HEADER TREE-OR-MEMBER MEMBER-LIST).
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/ebrowse.el.gz
(cl-defun ebrowse-find-pattern (&optional position info &aux viewing)
"Find a pattern.
This is a kluge: Ebrowse allows you to find or view a file containing
a pattern. To be able to do a search in a viewed buffer,
`view-mode-hook' is temporarily set to this function;
`ebrowse-temp-position-to-view' holds what to search for.
INFO is a list (TREE-HEADER TREE-OR-MEMBER MEMBER-LIST)."
(unless position
(remove-hook 'view-mode-hook #'ebrowse-find-pattern)
(setf viewing t
position ebrowse-temp-position-to-view
info ebrowse-temp-info-to-view))
(widen)
(let* ((pattern (ebrowse-bs-pattern position))
(start (ebrowse-bs-point position))
(offset 100)
found)
(pcase-let ((`(,_header ,class-or-member ,member-list) info))
;; If no pattern is specified, construct one from the member name.
(when (stringp pattern)
(setq pattern (concat "^.*" (regexp-quote pattern))))
;; Construct a regular expression if none given.
(unless pattern
(cl-typecase class-or-member
(ebrowse-ms
(setf pattern
(pcase member-list
((or 'ebrowse-ts-member-variables
'ebrowse-ts-static-variables
'ebrowse-ts-types)
(ebrowse-variable-declaration-regexp
(ebrowse-bs-name position)))
(_
(if (ebrowse-define-p class-or-member)
(ebrowse-pp-define-regexp (ebrowse-bs-name position))
(ebrowse-function-declaration/definition-regexp
(ebrowse-bs-name position)))))))
(ebrowse-cs
(setf pattern (ebrowse-class-declaration-regexp
(ebrowse-bs-name position))))))
;; Begin searching some OFFSET from the original point where the
;; regular expression was found by the parse, and step forward.
;; When there is no regular expression in the database and a
;; member definition/declaration was not seen by the parser,
;; START will be 0.
(when (and (boundp 'ebrowse-debug)
(symbol-value 'ebrowse-debug))
(y-or-n-p (format "start = %d? " start))
(y-or-n-p pattern))
(setf found
(cl-loop do (goto-char (max (point-min) (- start offset)))
when (re-search-forward pattern (+ start offset) t)
return t
never (bobp)
do (cl-incf offset offset)))
(cond (found
(beginning-of-line)
(run-hooks 'ebrowse-view/find-hook))
((numberp (ebrowse-bs-pattern position))
(goto-char start)
(if ebrowse-not-found-hook
(run-hooks 'ebrowse-not-found-hook)
(message "Not found")
(sit-for 2)))
(t
(if ebrowse-not-found-hook
(run-hooks 'ebrowse-not-found-hook)
(unless viewing
(error "Not found"))
(message "Not found")
(sit-for 2)))))))