helpful

a fork of Wilfred's helpful
git clone https://git.trogloxene.org/helpful.git
Log | Files | Refs | README

commit c57ff0d284b50ff430fe1f13fd48deaa0d1a910e
parent 56af42b634d1c748eb4e4a03fcbd34a4c9dfaf79
Author: Rahguzar <rahguzar@zohomail.eu>
Date:   Fri,  4 Aug 2023 22:15:25 +0200

Enable outline-support for Emacs 29

Diffstat:
Mhelpful.el | 31+++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+), 0 deletions(-)

diff --git a/helpful.el b/helpful.el @@ -3043,6 +3043,33 @@ See also `helpful-max-buffers'." (defun helpful--org-link-follow (link _) (helpful-symbol (intern link))) +(defun helpful--outline-function (&optional bound move backward looking-at) + "`outline-search-function' for `helpful-mode`. +See documentation of `outline-search-function' for BOUND, MOVE, +BACKWARD and LOOKING-AT." + (if looking-at + (eq 'helpful-heading (get-text-property (point) 'face)) + (let ((heading-found nil) + (bound (if bound bound (if backward (point-min) (point-max))))) + (save-excursion + (when (eq 'helpful-heading (get-text-property (point) 'face)) + (forward-line (if backward -1 1))) + (if backward + (while (not (or (eq (point) bound) + (eq 'helpful-heading (get-text-property (point) 'face)))) + (goto-char (or (previous-single-property-change (point) 'face nil bound) + bound))) + (goto-char (or (text-property-any (point) bound 'face 'helpful-heading) + bound))) + (when (eq 'helpful-heading (get-text-property (point) 'face)) + (setq heading-found (point)))) + (if heading-found + (progn + (goto-char heading-found) + (set-match-data (list heading-found heading-found))) + (when move + (goto-char bound) nil))))) + (define-derived-mode helpful-mode special-mode "Helpful" "Major mode for *Helpful* buffers." (add-hook 'xref-backend-functions #'elisp--xref-backend nil t) @@ -3055,6 +3082,10 @@ See also `helpful-max-buffers'." (set (make-local-variable 'bookmark-make-record-function) #'helpful--bookmark-make-record) + ;; Enable outline support for Emacs 29 and newer + (unless (< emacs-major-version 29) + (setq-local outline-search-function #'helpful--outline-function)) + ;; This function should normally only be called once after Org and ;; helpful are loaded. To avoid using `eval-after-load' (which is ;; only recommended in user init files), the function is called each