Skip to content

Commit 38ca3c0

Browse files
authored
Merge pull request #936 from rswgnu/rsw
hyrolo.el - Fix hyrolo issues caught by new tests
2 parents ba3fbc7 + b3b9384 commit 38ca3c0

6 files changed

Lines changed: 141 additions & 67 deletions

File tree

ChangeLog

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,37 @@
1+
2026-04-12 Bob Weiner <rsw@gnu.org>
2+
3+
* hyrolo.el (hyrolo-hdr-move-after-p): Fix infinite loop where did not
4+
check that (forward-line 1) actually moved, so just kept looping.
5+
Now it checks that the return value is zero. This fixes the test:
6+
'hyrolo-tests--outline-hide-other'.
7+
8+
2026-04-11 Bob Weiner <rsw@gnu.org>
9+
10+
* hsys-consult.el (hsys-consult-get-exit-value): Use 'hypb:function-p'
11+
instead of 'functionp' so recognizes symbol names of functions too.
12+
13+
* hibtypes.el (man-apropos): Stop matches to (function (pos)) in elisp
14+
by requiring first char in parens to be a 1-9 digit.
15+
16+
* hyrolo.el (hyrolo-outline-level): Remove first cond clause checking
17+
for :hyrolo-level which would return 0 for outline-level in Koutlines
18+
matched in the hyrolo display buffer because the :hyrolo-level property
19+
was not on the first char of the line but indented to the first char
20+
of the cell's relative id. Instead let it fall through to the clause
21+
matching 'hyrolo-entry-group-number'.
22+
(hyrolo--cache-initialize,
23+
hyrolo--cache-major-mode-indexes): Clarified usage in doc string.
24+
Initialize to '(1) instead of '(0) so when point is at position 1 in the
25+
*HyRolo* buffer which matches to the first position in this list. The
26+
'major-mode' lookup table indexes starting with 1, not 0, so using 0 would
27+
return nil for the 'major-mode'.
28+
(hyrolo-outline-backward-same-level,
29+
hyrolo-outline-forward-same-level): Fix so if within a file hdr
30+
moves to the start of the file hdr before trying to move to the next
31+
entry at the same level. Update to treat a nil arg as 1, a 0 arg as a
32+
no-op, negative args move in the opposite direction and return whether
33+
any sibling is found (point moves) or not (point does not move).
34+
135
2026-04-10 Mats Lidell <matsl@gnu.org>
236

337
* test/hyrolo-tests.el (hyrolo-tests--fgrep-move-test): Add more tests for

hibtypes.el

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
;; Author: Bob Weiner
44
;;
55
;; Orig-Date: 19-Sep-91 at 20:45:31
6-
;; Last-Mod: 28-Mar-26 at 13:02:39 by Bob Weiner
6+
;; Last-Mod: 11-Apr-26 at 19:28:10 by Bob Weiner
77
;;
88
;; SPDX-License-Identifier: GPL-3.0-or-later
99
;;
@@ -854,7 +854,7 @@ other buffers."
854854
start
855855
end
856856
topic)
857-
(when (looking-at (concat "\\(" nm "\\)[ \t]*\\(([-0-9a-zA-z]+)\\)"))
857+
(when (looking-at (concat "\\(" nm "\\)[ \t]*\\(([1-9][-0-9a-zA-z]*)\\)"))
858858
(setq start (match-beginning 0)
859859
end (match-end 0))
860860
(require 'man)

hsys-consult.el

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
;; Author: Bob Weiner
33
;;
44
;; Orig-Date: 4-Jul-24 at 09:57:18
5-
;; Last-Mod: 7-Apr-26 at 23:47:23 by Bob Weiner
5+
;; Last-Mod: 11-Apr-26 at 19:35:22 by Bob Weiner
66
;;
77
;; SPDX-License-Identifier: GPL-3.0-or-later
88
;;
@@ -300,7 +300,7 @@ arguments, store and return its result value into `hsys-consult-exit-value',
300300
Otherwise, return the selection from CONSULT-FUNCTION."
301301
(unless hsys-consult-flag
302302
(error "`%s' command requires `hsys-consult-flag' set to t" this-command))
303-
(unless (functionp consult-function)
303+
(unless (hypb:function-p consult-function)
304304
(user-error "(hsys-consult-get-exit-value): First arg must be a function, not `%s'"
305305
consult-function))
306306

hyrolo.el

Lines changed: 81 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
;; Author: Bob Weiner
44
;;
55
;; Orig-Date: 7-Jun-89 at 22:08:29
6-
;; Last-Mod: 8-Apr-26 at 23:12:04 by Bob Weiner
6+
;; Last-Mod: 12-Apr-26 at 09:29:44 by Bob Weiner
77
;;
88
;; SPDX-License-Identifier: GPL-3.0-or-later
99
;;
@@ -2060,8 +2060,8 @@ Return non-nil if point moves, else return nil."
20602060
;; Have to move past end-of-line if have moved
20612061
(when (> (point) opoint)
20622062
(goto-char (1+ (point)))))
2063-
(while (looking-at-p "^[ \t]*$")
2064-
(forward-line 1))
2063+
(while (and (looking-at-p "^[ \t]*$")
2064+
(zerop (forward-line 1))))
20652065
result)
20662066
(goto-char opoint)
20672067
nil)))
@@ -2399,22 +2399,40 @@ Only visible heading lines are considered, unless INVISIBLE-OK is non-nil."
23992399
(hyrolo-funcall-match (lambda () (outline-back-to-heading invisible-ok))))
24002400

24012401
(defun hyrolo-outline-backward-same-level (arg)
2402-
"Move backward to the ARG'th subheading at same level as this one.
2403-
Stop at the first and last subheadings of a superior heading."
2402+
"Move backward to the ARG'th subheading at same level as point.
2403+
Return t if point moves; nil otherwise.
2404+
2405+
File headers and end of buffer are considered level 1. Stop before the
2406+
first and last subheadings of a superior heading. If any predecessor
2407+
siblings are found, leave point at the start of the furthest entry entered;
2408+
otherwise, don't move point."
24042409
(interactive "p")
2405-
(hyrolo-funcall-match
2406-
(lambda ()
2407-
(outline-back-to-heading)
2408-
(while (> arg 0)
2409-
(let ((point-to-move-to (save-excursion
2410-
(hyrolo-outline-get-last-sibling))))
2411-
(if point-to-move-to
2412-
(progn
2413-
(goto-char point-to-move-to)
2414-
(setq arg (1- arg)))
2415-
(setq arg 0)
2416-
(error "No previous same-level heading/header")))))
2417-
nil t))
2410+
(unless arg
2411+
(setq arg 1))
2412+
(cond ((< arg 0)
2413+
(hyrolo-outline-forward-same-level (- arg)))
2414+
((zerop arg)
2415+
nil)
2416+
(t (let ((opoint (point))
2417+
found
2418+
point-to-move-to)
2419+
(hyrolo-funcall-match
2420+
(lambda ()
2421+
(or (hyrolo-hdr-to-first-line-p)
2422+
(outline-back-to-heading))
2423+
(while (> arg 0)
2424+
(if (setq point-to-move-to (save-excursion
2425+
(hyrolo-outline-get-last-sibling)))
2426+
(progn
2427+
(setq found t)
2428+
(goto-char point-to-move-to)
2429+
(setq arg (1- arg)))
2430+
(setq arg 0)))
2431+
(unless found
2432+
(goto-char opoint)
2433+
(error "No previous same-level heading/header")))
2434+
nil t)
2435+
found))))
24182436

24192437
(defun hyrolo-outline-demote (&optional which)
24202438
"Demote headings lower down the tree.
@@ -2433,21 +2451,36 @@ nil for WHICH, or do not pass any argument)."
24332451
(hyrolo-funcall-match (lambda () (outline-demote which)) t))
24342452

24352453
(defun hyrolo-outline-forward-same-level (arg)
2436-
"Move forward to the ARG'th subheading at same level as this one.
2437-
Stop at the first and last subheadings of a superior heading."
2454+
"Move forward to the positive ARG'th subheading at same level as point.
2455+
File headers are considered level 1. Stop before the first and last
2456+
subheadings of a superior heading. If any siblings are found, leave point
2457+
at the start of the furthest entry entered; otherwise, don't move point."
24382458
(interactive "p")
2439-
(hyrolo-funcall-match
2440-
(lambda ()
2441-
(outline-back-to-heading)
2442-
(while (> arg 0)
2443-
(let ((point-to-move-to (save-excursion
2444-
(hyrolo-outline-get-next-sibling))))
2445-
(if point-to-move-to
2446-
(progn
2447-
(goto-char point-to-move-to)
2448-
(setq arg (1- arg)))
2449-
(setq arg 0)
2450-
(error "No following same-level heading/header")))))))
2459+
(unless arg
2460+
(setq arg 1))
2461+
(cond ((< arg 0)
2462+
(hyrolo-outline-backward-same-level (- arg)))
2463+
((zerop arg)
2464+
nil)
2465+
(t (let ((opoint (point))
2466+
found
2467+
point-to-move-to)
2468+
(hyrolo-funcall-match
2469+
(lambda ()
2470+
(outline-back-to-heading)
2471+
(while (> arg 0)
2472+
(if (setq point-to-move-to (save-excursion
2473+
(hyrolo-outline-get-next-sibling)))
2474+
(progn
2475+
(setq found t)
2476+
(goto-char point-to-move-to)
2477+
(setq arg (1- arg)))
2478+
;; If on last entry of the buffer, move to (point-max)
2479+
(setq arg 0)))
2480+
(unless found
2481+
(goto-char opoint)
2482+
(error "No following same-level heading/header"))))
2483+
found))))
24512484

24522485
(defun hyrolo-outline-get-last-sibling ()
24532486
"Move to previous heading of the same level, and return point.
@@ -3400,20 +3433,21 @@ Return final point."
34003433

34013434
(defun hyrolo-outline-level ()
34023435
"Return the depth to which an entry is nested in the *HyRolo* buffer.
3436+
File headers are considered level 1.
3437+
34033438
This is actually either the level specified in `outline-heading-alist'
34043439
or else the number of characters matched by `outline-regexp' minus
34053440
trailing periods and whitespace.
34063441

34073442
Point must be at the beginning of a heading line.
34083443

3409-
This function is used for every file-type major-mode supported by HyRolo."
3444+
This function is used for every file-type `major-mode' supported by HyRolo."
34103445

34113446
(or (and outline-heading-alist (looking-at outline-regexp)
34123447
(cdr (assoc (match-string-no-properties 0) outline-heading-alist)))
3413-
(cond ((hproperty:length-p :hyrolo-level t))
3414-
((derived-mode-p 'kotl-mode)
3448+
(cond ((derived-mode-p 'kotl-mode)
34153449
(kcell-view:level))
3416-
;; ((hyrolo-hdr-in-p) 1)
3450+
((hyrolo-hdr-in-p) 1)
34173451
((looking-at hyrolo-hdr-and-entry-regexp)
34183452
(length (match-string hyrolo-entry-group-number)))
34193453
(t 0))))
@@ -3425,16 +3459,22 @@ This function is used for every file-type major-mode supported by HyRolo."
34253459
(defvar hyrolo--cache-loc-match-bounds '(1)
34263460
"Ordered list of the bounds of each matched buffer in Hyrolo display buffer.
34273461
First entry represents the start of the first matched buffer and the
3428-
remaining entries are the end points of each matched buffer with the
3429-
HyRolo display matches buffer.")
3462+
remaining entries are the end points of each matched buffer within the
3463+
HyRolo match display buffer.")
34303464

34313465
;; Next line prevents `kill-all-local-variables' run on each major
34323466
;; mode change in the HyRolo display buffer from removing the given
34333467
;; cache variable.
34343468
(put 'hyrolo--cache-loc-match-bounds 'permanent-local t)
34353469

3436-
(defvar hyrolo--cache-major-mode-indexes '(0)
3437-
"Ordered list of major-mode-indexes `hyrolo--cache-loc-match-bounds' positions.")
3470+
(defvar hyrolo--cache-major-mode-indexes '(1)
3471+
"Ordered keys to select major modes in `hyrolo--cache-major-mode-indexes'.
3472+
Keys may be repeated as multiple files matched in the HyRolo display buffer
3473+
may share the same `major-mode'.
3474+
3475+
Key ordering matches the ordering of position entries in
3476+
`hyrolo--cache-loc-match-bounds' so that a position in the HyRolo match
3477+
display buffer can be connected to its source buffer `major-mode'.")
34383478
(put 'hyrolo--cache-major-mode-indexes 'permanent-local t)
34393479

34403480
(defvar hyrolo--cache-major-mode-index 1
@@ -3609,7 +3649,7 @@ Call whenever `hyrolo-display-buffer' is changed."
36093649

36103650
;; Don't use '(1) on the next line or the code will not initialize properly
36113651
hyrolo--cache-loc-match-bounds (list 1)
3612-
hyrolo--cache-major-mode-indexes (list 0)
3652+
hyrolo--cache-major-mode-indexes (list 1)
36133653
hyrolo--cache-major-mode-index 1)))
36143654

36153655
(defun hyrolo--cache-major-mode (src-buf)

kotl/kotl-mode.el

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
;; Author: Bob Weiner
44
;;
55
;; Orig-Date: 6/30/93
6-
;; Last-Mod: 29-Mar-26 at 12:53:49 by Bob Weiner
6+
;; Last-Mod: 11-Apr-26 at 19:38:12 by Bob Weiner
77
;;
88
;; SPDX-License-Identifier: GPL-3.0-or-later
99
;;
@@ -3703,6 +3703,7 @@ but always operates upon the current view."
37033703
(put 'outline 'reveal-toggle-invisible 'kotl-mode:reveal-toggle-invisible)
37043704
(defun kotl-mode:isearch-open-invisible (_overlay)
37053705
(kotl-mode:show-tree))
3706+
37063707
;; Adapted from outline-reveal-toggle-invisible; called by isearch.
37073708
(defun kotl-mode:reveal-toggle-invisible (o hidep)
37083709
(if (not (derived-mode-p 'kotl-mode))

test/hyrolo-tests.el

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
;; Author: Mats Lidell <matsl@gnu.org>
44
;;
55
;; Orig-Date: 19-Jun-21 at 22:42:00
6-
;; Last-Mod: 8-Apr-26 at 23:14:30 by Bob Weiner
6+
;; Last-Mod: 11-Apr-26 at 19:28:11 by Bob Weiner
77
;;
88
;; SPDX-License-Identifier: GPL-3.0-or-later
99
;;
@@ -461,7 +461,6 @@ Match a string in the second cell."
461461

462462
(ert-deftest hyrolo-tests--fgrep-move-test ()
463463
"Verify different move commands after `hyrolo-fgrep'."
464-
:expected-result :failed
465464
(let* ((kotl-file1 (hyrolo-tests--gen-kotl-outline "heading" "foo bar" 1))
466465
(kotl-file2 (hyrolo-tests--gen-kotl-outline "heading" "foo bar" 1))
467466
(hyrolo-file-list (list kotl-file1 kotl-file2))
@@ -472,9 +471,27 @@ Match a string in the second cell."
472471
(hyrolo-fgrep "bar")
473472
(should (string= hyrolo-display-buffer (buffer-name)))
474473

475-
(ert-info ("Hide first header and move down using ?n")
474+
(ert-info ("Hide first header move down using ?f")
476475
(should (looking-at-p "==="))
477476
(execute-kbd-macro (kbd "h"))
477+
(execute-kbd-macro (kbd "f"))
478+
(should (looking-at-p "==="))
479+
(execute-kbd-macro (kbd "f"))
480+
(should (looking-at-p h1_str))
481+
(let ((err (should-error (execute-kbd-macro (kbd "f")))))
482+
(should (string-match-p "No following same-level heading/header" (cadr err)))))
483+
484+
(ert-info ("With hidden first header move up using ?b")
485+
(execute-kbd-macro (kbd "b"))
486+
(should (looking-at-p "==="))
487+
(execute-kbd-macro (kbd "b"))
488+
(should (looking-at-p "==="))
489+
(should (bobp))
490+
(let ((err (should-error (execute-kbd-macro (kbd "b")))))
491+
(should (string-match-p "No previous same-level heading/header" (cadr err)))))
492+
493+
(ert-info ("With hidden first header and move down using ?n")
494+
(should (looking-at-p "==="))
478495
(execute-kbd-macro (kbd "n"))
479496
(should (looking-at-p "==="))
480497
(execute-kbd-macro (kbd "n"))
@@ -495,24 +512,6 @@ Match a string in the second cell."
495512
(should (looking-at-p "==="))
496513
(should (bobp)))
497514

498-
(ert-info ("With hidden first header move down using ?f")
499-
(should (looking-at-p "==="))
500-
(execute-kbd-macro (kbd "f"))
501-
(should (looking-at-p "==="))
502-
(execute-kbd-macro (kbd "f"))
503-
(should (looking-at-p h1_str))
504-
(let ((err (should-error (execute-kbd-macro (kbd "f")))))
505-
(should (string-match-p "No following same-level heading/header" (cadr err)))))
506-
507-
(ert-info ("With hidden first header move up using ?b")
508-
(execute-kbd-macro (kbd "b"))
509-
(should (looking-at-p "==="))
510-
(execute-kbd-macro (kbd "b"))
511-
(should (looking-at-p "==="))
512-
(should (bobp))
513-
(let ((err (should-error (execute-kbd-macro (kbd "b")))))
514-
(should-not (equal '(void-function nil) err)))) ;FIXME: No error message but void-function!?
515-
516515
(outline-show-all)
517516

518517
(ert-info ("Move down using ?n")

0 commit comments

Comments
 (0)