Function: ebut:search
ebut:search is a byte-compiled function defined in hbut.el.
Signature
(ebut:search STRING OUT-BUF &optional MATCH-PART)
Documentation
Write explicit button lines matching STRING to OUT-BUF.
Search across all files into which the user has previously saved explicit buttons. By default, find matches for whole button labels only; optional MATCH-PART enables partial matches.
Source Code
;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hbut.el
(defun ebut:search (string out-buf &optional match-part)
"Write explicit button lines matching STRING to OUT-BUF.
Search across all files into which the user has previously saved
explicit buttons. By default, find matches for whole button
labels only; optional MATCH-PART enables partial matches."
(let* ((buffers (mapcar (lambda (dir)
(expand-file-name hattr:filename dir))
(hbmap:dir-list)))
(total 0)
(firstmatch))
(with-current-buffer out-buf
(setq buffer-read-only nil)
(widen)
(erase-buffer)
(let (currbuf currfile kill-buf src-matches dir)
(while buffers
(setq currbuf (car buffers)
currfile (if (stringp currbuf) currbuf)
kill-buf (and currfile (not (get-file-buffer currfile)))
buffers (cdr buffers))
(if currfile
(setq currbuf (and (file-readable-p currfile)
(find-file-noselect currfile))
dir (file-name-directory currfile))
(setq currfile (hypb:buffer-file-name currbuf)))
(and currfile currbuf
(unwind-protect
(setq src-matches
(hbdata:search currbuf string match-part))
(if kill-buf (kill-buffer currbuf))))
(if src-matches
(let (elt matches)
(while src-matches
(setq elt (car src-matches))
(if (null elt) nil
(setq src-matches (cdr src-matches)
currfile (expand-file-name (car elt) dir)
matches (cdr elt)
currbuf (get-file-buffer currfile)
kill-buf (not currbuf)
currbuf (or currbuf
(and (file-readable-p currfile)
(find-file-noselect currfile))))
(if (null currbuf)
(progn (set-buffer out-buf)
(insert "ERROR: (ebut:search): \"" currfile
"\" is not readable.\n\n"))
(set-buffer currbuf)
(unwind-protect
(save-excursion
(widen) (goto-char 1)
(let ((case-fold-search t)
(regexp
(ebut:match-regexp matches match-part)))
(setq firstmatch t)
(while (re-search-forward regexp nil t)
(setq total (1+ total))
(let* ((linenum (count-lines (point-min)
(point)))
(tag (format "\n%4d:" linenum))
lns start end)
(setq end (line-end-position)
start (progn
(goto-char (match-beginning 0))
(line-beginning-position))
lns (buffer-substring start end))
(goto-char end)
(with-current-buffer out-buf
(if firstmatch
(progn
(insert hbut:source-prefix "\""
currfile "\"\n")
(setq firstmatch nil)))
(insert tag lns))))
(set-buffer out-buf)
(if (not firstmatch) (insert "\n\n"))))
(if kill-buf (kill-buffer currbuf)))))))))))
total))