Accept optional group in denote-retrieve--search

This commit is contained in:
Protesilaos Stavrou 2022-06-16 08:49:58 +03:00
parent 31fc567702
commit 3654f902e6
No known key found for this signature in database
GPG key ID: 99BD6459CD5CA3EA

View file

@ -56,14 +56,15 @@ group 1.")
(match-string 0 file))
(error "Cannot find `%s' as a file" file)))
(defun denote-retrieve--search (regexp)
"Search for REGEXP in the current buffer."
(defun denote-retrieve--search (regexp &optional group)
"Search for REGEXP in the current buffer.
With optional GROUP match it, else match group 1."
(save-excursion
(save-restriction
(widen)
(goto-char (point-min))
(re-search-forward regexp nil t 1)
(match-string-no-properties 1))))
(match-string-no-properties (or group 1)))))
(defun denote-retrieve--value (file regexp)
"Return REGEXP value from FILE.