occur is an interactive compiled Lisp function in ‘replace.el’.
The definition is as follows:
(defun occur (regexp &optional nlines region) (interactive (nconc (occur-read-primary-args) (and (use-region-p) (list (region-bounds))))) (let* ((start (and (caar region) (max (caar region) (point-min)))) (end (and (cdar region) (min (cdar region) (point-max)))) (in-region-p (or start end))) (when in-region-p (or start (setq start (point-min))) (or end (setq end (point-max)))) (let ((occur--region-start start) (occur--region-end end) (occur--matches-threshold (and in-region-p (line-number-at-pos (min start end)))) (occur--orig-line (line-number-at-pos (point))) (occur--orig-line-str (buffer-substring-no-properties (line-beginning-position) (line-end-position)))) (save-excursion ; If no matches `occur-1' doesn't restore the point. (and in-region-p (narrow-to-region start end)) (occur-1 regexp nlines (list (current-buffer))) (and in-region-p (widen))))))
When the above function is invoked, the user is prompted to input a regexp for searching.
What I want is to make a new function
myoccur by hard-coding a regexp in the above function and make it non-interactive, so that I can conveniently invoke it. If a wrapper over the original
occur can make it non-interactive, that would also be great.
How should I do?