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+
34033438This is actually either the level specified in `outline-heading-alist'
34043439or else the number of characters matched by `outline-regexp' minus
34053440trailing periods and whitespace.
34063441
34073442Point 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.
34273461First 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 )
0 commit comments