branch: externals/hyperbole
commit a86a629e865daf6dd71b3a16737bf09da6bf5c71
Author: bw <[email protected]>
Commit: bw <[email protected]>
text-toc ibtype and actype - Allow # entries and diff TOC chars
- text-toc ibtype - Update doc to reflect different leader chars that can
start a TOC entry. The section an entry matches to must start with the
same number of * or # chars.
- text-toc actype - Add support for section entries using # as their
leading delimiter, i.e. Markdown files. Fix to translate leader char
to either * or #. Change so cannot have any leading spaces, as mentioned
in the ibtype doc string.
---
ChangeLog | 8 ++++++++
hactypes.el | 35 ++++++++++++++++++++++-------------
hibtypes.el | 19 ++++++++++---------
3 files changed, 40 insertions(+), 22 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 31a6a6251a8..6f037ad58a7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2026-10-22 Bob Weiner <[email protected]>
+* hibtypes.el (text-toc): Update doc to reflect different leader
+ chars that can start a TOC entry. The section an entry
+ matches to must start with the same number of * or # chars.
+ hactypes.el (text-toc): Add support for section entries using #
+ as their leading delimiter, i.e. Markdown files. Fix to translate
+ leader char to either * or #. Change so cannot have any leading
+ spaces, as mentioned in the ibtype doc string.
+
* HY-NEWS (V9.3.1): Finish writeup on items back through 9.2.0.
* HY-ANNOUNCE: In-progress.
diff --git a/hactypes.el b/hactypes.el
index e72053203e0..377c538ffd8 100644
--- a/hactypes.el
+++ b/hactypes.el
@@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 23-Sep-91 at 20:34:36
-;; Last-Mod: 21-Oct-26 at 10:58:06 by Bob Weiner
+;; Last-Mod: 22-Oct-26 at 01:46:46 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -837,18 +837,27 @@ Optional SECTIONS-START limits toc entries to those after
that point."
SECTION is a string and can be just the leading part of a section heading."
(interactive "sGo to section named: ")
(when (stringp section)
- (setq section (string-trim section))
- (if (string-match "\\`\\(\\*+\\)[ \t]*" section)
- (actypes::link-to-regexp-match
- (concat "^[ \t]*" (regexp-quote (match-string 1 section))
- "[ \t]*" (regexp-quote (substring section (match-end 0))))
- 2 (current-buffer) t)
- (actypes::link-to-regexp-match (concat "^[ \t]*" (regexp-quote section))
- 2 (current-buffer) t))
- (while (and (= (forward-line -1) 0)
- (looking-at "[ \t]*[-=][-=]")))
- (forward-line 1)
- (recenter 0)))
+ (let (leader-chars)
+ ;; Move past the ibtype matched TOC entry so searches herein skip it
+ (forward-line 1)
+ (setq section (string-trim section))
+ (if (string-match "\\`\\([-+*o]+\\)[ \t]*" section)
+ (progn
+ (setq leader-chars (match-string 1 section))
+ (actypes::link-to-regexp-match
+ (concat "^[ \t]*\\("
+ (regexp-quote (make-string (length leader-chars) ?*))
+ "\\|"
+ (regexp-quote (make-string (length leader-chars) ?#))
+ "\\)[ \t]*"
+ (regexp-quote (substring section (match-end 0))))
+ 1 (current-buffer) t))
+ (actypes::link-to-regexp-match (concat "^[ \t]*" (regexp-quote
section))
+ 1 (current-buffer) t))
+ (while (and (= (forward-line -1) 0)
+ (looking-at "[ \t]*[-=][-=]")))
+ (forward-line 1)
+ (recenter 0))))
(defun hactypes:buffer-button-list ()
"Return buttons available in current buffer."
diff --git a/hibtypes.el b/hibtypes.el
index 6a46008d6f4..9e98a505644 100644
--- a/hibtypes.el
+++ b/hibtypes.el
@@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 19-Sep-91 at 20:45:31
-;; Last-Mod: 18-Oct-26 at 09:12:52 by Bob Weiner
+;; Last-Mod: 22-Oct-26 at 01:53:38 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -812,14 +812,15 @@ anything."
(defib text-toc ()
"Jump to the text file section referenced by a table of contents entry at
point.
-Buffer must be in a text mode or must contain DEMO, README or
-TUTORIAL and there must be a `Table of Contents' or `Contents'
-label on a line by itself (it optionally may begin with an
-asterisk), preceding the table of contents. Each toc entry must
-begin with optional whitespace followed by one or more asterisks.
-Each section header linked to by the toc must start with optional
-whitespace and then one or more asterisks at the beginning of the
-line."
+Buffer must be in a text mode or must contain DEMO, README or TUTORIAL
+and there must be a `Table of Contents' or `Contents' label on a line by
+itself (it optionally may begin with an asterisk), preceding the table
+of contents. Each toc entry must begin with optional whitespace
+followed by one or more asterisks, +, -, or the letter `o' (the leader
+character) followed by whitespace. Each section header linked to by the
+toc must start with optional whitespace and then one or more asterisks
+at the beginning of the line matching the number of leader characters
+matched in the toc."
(let (section)
(when (and (or (derived-mode-p 'text-mode)
(string-match "DEMO\\|README\\|TUTORIAL" (buffer-name)))