mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-06-14 04:21:24 +00:00
Add outline-search-from-regexp generic helper
Add outline-search-from-regexp generic helper (bug#80887) Minor modes and third-party packages that customize 'outline-regexp' typically need an 'outline-search-function' implementation that searches for 'outline-regexp' anchored at beginning of line. Without a generic helper, each such user reinvents the function locally. Add it to outline.el. This pattern has been in production use as a default value of 'outline-search-function' (set via 'setq-default') without issues. * lisp/outline.el (outline-search-from-regexp): New function. * etc/NEWS: Announce it.
This commit is contained in:
parent
b079716674
commit
194c28aaf2
2 changed files with 29 additions and 0 deletions
9
etc/NEWS
9
etc/NEWS
|
|
@ -117,6 +117,15 @@ obsolete.
|
|||
It is bound to 'C-e' and reveals the current entry
|
||||
with its parent hierarchy.
|
||||
|
||||
---
|
||||
*** New function 'outline-search-from-regexp'.
|
||||
A generic 'outline-search-function' implementation driven by
|
||||
'outline-regexp', suitable for modes or minor modes that customize
|
||||
'outline-regexp' but do not need a custom search strategy.
|
||||
Install it with:
|
||||
|
||||
(setq-local outline-search-function #'outline-search-from-regexp)
|
||||
|
||||
|
||||
* New Modes and Packages in Emacs 32.1
|
||||
|
||||
|
|
|
|||
|
|
@ -1550,6 +1550,26 @@ The rest of arguments are described in `outline-search-function'."
|
|||
(when move (goto-char (or bound (if backward (point-min) (point-max)))))
|
||||
nil))))
|
||||
|
||||
|
||||
;;; Search regexp for outline headings
|
||||
|
||||
;;;###autoload
|
||||
(defun outline-search-from-regexp (&optional bound move backward looking-at)
|
||||
"Search for the next heading matching `outline-regexp'.
|
||||
The arguments BOUND, MOVE, BACKWARD, and LOOKING-AT are described
|
||||
in `outline-search-function'. This function is intended to be
|
||||
used in `outline-search-function' by modes and minor modes that
|
||||
customize `outline-regexp' but do not need a custom search strategy.
|
||||
Install it with
|
||||
|
||||
(setq-local outline-search-function #\\='outline-search-from-regexp)"
|
||||
(if looking-at
|
||||
(looking-at outline-regexp)
|
||||
(funcall (if backward #'re-search-backward #'re-search-forward)
|
||||
(concat "^\\(?:" outline-regexp "\\)")
|
||||
bound
|
||||
(if move 'move t))))
|
||||
|
||||
|
||||
(defun outline-headers-as-kill (beg end)
|
||||
"Save the visible outline headers between BEG and END to the kill ring.
|
||||
|
|
|
|||
Loading…
Reference in a new issue