From 78a10d17c69970687f8330f6c896170bcf936ef3 Mon Sep 17 00:00:00 2001 From: "Paul H. McClelland" Date: Fri, 15 May 2026 19:02:43 -0400 Subject: [PATCH] Convert outline-search-function to defcustom Make 'outline-search-function' a user option with named choices for its predefined values, so users can configure it via Customize. Preserves existing docstring and runtime semantics (bug#81053). * lisp/outline.el (outline-search-function): Convert to defcustom. * etc/NEWS: Announce it. --- etc/NEWS | 7 +++++++ lisp/outline.el | 16 +++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index b76b18cdc8c..f2005196353 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -126,6 +126,13 @@ Install it with: (setq-local outline-search-function #'outline-search-from-regexp) +--- +*** 'outline-search-function' is now a user option. +Previously a plain variable, it is now a 'defcustom' +with named choices for the predefined search functions +('outline-search-from-regexp' and 'outline-search-level') +as well as the default nil and arbitrary user functions. + * New Modes and Packages in Emacs 32.1 diff --git a/lisp/outline.el b/lisp/outline.el index 3eb354a22ce..4b4f3c2d520 100644 --- a/lisp/outline.el +++ b/lisp/outline.el @@ -61,8 +61,10 @@ The recommended way to set this is with a `Local Variables:' list in the file it applies to.") ;;;###autoload(put 'outline-heading-end-regexp 'safe-local-variable 'stringp) -(defvar outline-search-function nil - "Function to search the next outline heading. +(defcustom outline-search-function nil + "If non-nil, the function to search the next outline heading. +When nil, headings are found by searching for `outline-regexp'. + The function is called with four optional arguments: BOUND, MOVE, BACKWARD, LOOKING-AT. The first two arguments BOUND and MOVE are almost the same as the BOUND and NOERROR arguments of `re-search-forward', with the difference @@ -71,7 +73,15 @@ BACKWARD is non-nil, the search should search backward like `re-search-backward' does. In case of a successful search, the function should return non-nil, move point, and set match-data appropriately. When the argument LOOKING-AT is non-nil, it should -imitate the function `looking-at'.") +imitate the function `looking-at'." + :type '(choice (const :tag "Use `outline-regexp'" nil) + (function-item :tag "Search by `outline-regexp' (regexp-based)" + outline-search-from-regexp) + (function-item :tag "Search by `outline-level' text property" + outline-search-level) + (function :tag "Other function")) + :group 'outlines + :version "32.1") (defvar-keymap outline-mode-prefix-map "@" #'outline-mark-subtree