branch: externals/hyperbole commit ca3cf8e42784c25ba8ffa6dc9520bd0f78c309c4 Author: bw <r...@gnu.org> Commit: bw <r...@gnu.org>
hyrolo.el - Fix {t} and {o} commands Disable reveal-mode until can get it to work properly with outline-minor-mode. Fix hyrolo-tests.el tests that prompt to re-read-in files. --- ChangeLog | 66 ++++++++++--- HY-NEWS | 2 +- hib-doc-id.el | 4 +- hyrolo-logic.el | 2 +- hyrolo.el | 265 +++++++++++++++++++++++++++++++-------------------- kotl/kimport.el | 6 +- kotl/kotl-mode.el | 10 +- man/hyperbole.html | 8 +- man/hyperbole.info | Bin 618111 -> 618127 bytes man/hyperbole.pdf | Bin 1372120 -> 1372135 bytes man/hyperbole.texi | 6 +- test/hyrolo-tests.el | 42 ++++---- 12 files changed, 254 insertions(+), 157 deletions(-) diff --git a/ChangeLog b/ChangeLog index 14128fd64b..06bd7e6f06 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,46 @@ +2023-12-26 Bob Weiner <r...@gnu.org> + +* test/hyrolo-tests.el: Fix with-simulated-input where prompting for 'y'. + +* hyrolo.el (hyrolo-map-matches, hyrolo-funcall-match): Ensure point ends up + on a visible point so that reveal-mode does not force and unhide of the entry. + Remove the above logic from 'hyrolo-show-levels' since it calls + 'hyrolo-map-matches'. + (hyrolo-mode): For now, stop enabling 'reveal-mode' until can get it + working right with the enabling of 'outline-minor-mode' when switch major modes + in "*HyRolo*", typically using 'hyrolo-funcall-match' or 'hyrolo-map-matches'. + +* test/hyrolo-tests.el (hyrolo-sort-test): Enable this test. + hyrolo.el (hyrolo-add): Fix this function to insert sub-entries in the right + location so 'hyrolo-sort-test' passes. + 2023-12-25 Bob Weiner <r...@gnu.org> +* hyrolo.el (hyrolo-entry-regexp): Rename to 'hyrolo-hdr-and-entry-regexp' and + in 'hyrolo-mode' extend its value to include all multiple trailing whitespace + chars after the entry delimiter. + Add new variable `hyrolo-entry-regexp' which does not match to file headers. + +* hyrolo.el (require 'reveal): Add since overload its functions now. + +* kotl/kotl-mode.el (kotl-mode:reveal-toggle-invisible): Fix by adding + 'get-buffer' call around 'hyrolo-display-buffer'. Otherwise, the buffer + comparison would always fail. + * hyrolo.el (hyrolo-hdr-move-after-p): Modify to handle when point is not at the start of but is on a hdr separator or loc line. - (hyrolo-to-entry-beginning): Fix to move past any file hdr. + (hyrolo-to-entry-beginning): Fix to move past any file hdr. + (hyrolo-map-matches): Fix calls to this that are mode-specific by adding + second arg of t. + (hyrolo-show-levels): Rewrite so handles all behavior for {t} and {o} + key bindings. + (hyrolo-overview, hyrolo-top-level): Simplify for new version of + 'hyrolo-show-levels'. + (outline-mode-hook): Fix to apture only one whitespace char in + 'outline-regexp' so 'hyrolo-outline-level' function works properly. + (hyrolo-grep-file): Require a final blank line so that + 'outline-hide-sublevels' won't hide it and combine with any next file header. + (hyrolo-min-matched-level): Fix to start with max val rather than min val. * man/hyperbole.texi (HyRolo Keys): Document [ and ] keys to move to prev and next buffer/file @loc> line. @@ -20,7 +58,7 @@ (outline-mode-hook): Add to configure outline-mode for use with HyRolo. (hyrolo-org-mode): Update to set all local hyrolo variables. -* kotl/kotl-mode.el (kotl-mode): Set 'outline-regexp' to match 'hyrolo-entry-regexp' +* kotl/kotl-mode.el (kotl-mode): Set 'outline-regexp' to match 'hyrolo-hdr-and-entry-regexp' to account for file headers in 'hyrolo-mode' (multi-format major-mode). 2023-12-24 Bob Weiner <r...@gnu.org> @@ -77,7 +115,7 @@ * kotl/kotl-mode.el (kotl-mode): Disable 'change-major-mode-hook' addition of 'kotl-mode:show-all' if in the HyRolo display buffer. -* hyrolo.el (hyrolo-entry-regexp): Add 'hyrolo-hdr-regexp' and 'hbut:source-prefix' +* hyrolo.el (hyrolo-hdr-and-entry-regexp): Add 'hyrolo-hdr-regexp' and 'hbut:source-prefix' so are not skipped during hide/show operations. Also do this in 'markdown-mode-hook' and 'kotl-mode'. @@ -237,7 +275,7 @@ in HyRolo display match buffer when displaying parts of Koutlines. * hyrolo.el (hyrolo-cache-set-major-mode): Move to this function the - addition of 'hyrolo-hdr-regexp' to both 'hyrolo-entry-regexp' and + addition of 'hyrolo-hdr-regexp' to both 'hyrolo-hdr-and-entry-regexp' and 'outline-regexp' within the *HyRolo* display match buffer. (hyrolo-markdown-outline-level, hyrolo-cache-set-major-mode): Fix markdown 'outline-level' function to always return a non-nil level. @@ -293,7 +331,7 @@ (hyrolo-grep-file): Add call to 'hyrolo--cache-locals'. (hyrolo-grep): Remove concatenated 'outline-regexps' and 'hyrolo-entry-regexps'. They are no longer used. Move header matching in `outline-regexp' and - `hyrolo-entry-regexp' to 'hyrolo--cache-matched-buffer'. + `hyrolo-hdr-and-entry-regexp' to 'hyrolo--cache-matched-buffer'. 2023-12-07 Mats Lidell <ma...@gnu.org> @@ -548,7 +586,7 @@ (hyrolo-find-file): Improve 'outline-regexp' handling and set 'outline-level' function if an Emacs outline. (hyrolo-add): Compare entry-regexp against default-value of - 'hyrolo-entry-regexp' rather than a literal string. + 'hyrolo-hdr-and-entry-regexp' rather than a literal string. 2023-11-14 Bob Weiner <r...@gnu.org> @@ -3170,7 +3208,7 @@ name with 'name' and 'name-key'. hyrolo-google-contacts-grep, hyrolo-grep-file, hyrolo-display-to-entry-end, hyrolo-name-at): kotl/kimport.el (kimport:star-entries): Don't fold case when searching - for 'hyrolo-entry-regexp'. + for 'hyrolo-hdr-and-entry-regexp'. (hyrolo-isearch-for-regexp): Add 2nd parameter, 'fold-search-flag' used to set 'case-fold-search'. @@ -3229,11 +3267,11 @@ name with 'name' and 'name-key'. * hyrolo.el (hyrolo-grep): Add support for 'outline-regexp' and 'outline-level' variables from multiple file types. This includes - adding 'hyrolo-hdr-regexp' to both 'hyrolo-entry-regexp' and + adding 'hyrolo-hdr-regexp' to both 'hyrolo-hdr-and-entry-regexp' and 'outline-regexp' within the *HyRolo* match buffer. (hyrolo-mode): Set local value of 'outline-level' to 'hyrolo-mode-outline-level' and define that function to support - star outlines and Koutlines. Also, make 'hyrolo-entry-regexp' + star outlines and Koutlines. Also, make 'hyrolo-hdr-and-entry-regexp' local and set it to its default value, after which it may be modified. (hyrolo-previous-match): Change so can be used in a @@ -3241,7 +3279,7 @@ name with 'name' and 'name-key'. (hyrolo-mode-outline-level): Add and use in 'hyrolo-mode'. * kotl/kotl-mode.el (kotl-mode): Add local settings of: - 'hyrolo-entry-regexp', 'outline-level', and 'outline-regexp' + 'hyrolo-hdr-and-entry-regexp', 'outline-level', and 'outline-regexp' specific to Koutlines. kotl/kview.el (kview:outline-regexp): Regexp quote use of 'kview:default-label-separator'. @@ -6436,7 +6474,7 @@ Delete knode.el and integrate functionality into kcell.el. This makes behavior across magit lines consistent and pathnames can still be displayed using the Assist Key (invokes magit {RET} key). -* hyrolo.el (hyrolo-to-entry-end): Default to using entire hyrolo-entry-regexp +* hyrolo.el (hyrolo-to-entry-end): Default to using entire hyrolo-hdr-and-entry-regexp to determine the outline depth when no hyrolo-entry-group-number is included in the expression. Fixes issue that could call (goto-char nil). @@ -7643,7 +7681,7 @@ V7.1.0 test release changes ^^^^: using {q} to quit from the hyrolo match buffer. * hyrolo-logic.el (hyrolo-map-logic): Fixed function call. - Changed: (match-string-no-properties hyrolo-entry-regexp + Changed: (match-string-no-properties hyrolo-hdr-and-entry-regexp To: (match-string-no-properties hyrolo-entry-group-number) * hsys-org.el (inhibit-hsys-org): Added customization to allow disabling all Smart Key support when in an @@ -7675,7 +7713,7 @@ V7.1.0 test release changes ^^^^: (hyrolo-to): (hyrolo-to-entry-end): Fixed bug that caused addition of new entries at the end of the hyrolo file, rather than in sorted order. Also caused hyrolo-logic functions to fail. - The issue was that 'hyrolo-entry-regexp' had been updated to include the whitespace following the entry prefix + The issue was that 'hyrolo-hdr-and-entry-regexp' had been updated to include the whitespace following the entry prefix and this whitespace was improperly included when computing the hierarchy level of the entry. Also, changed 'curr-entry-level' parameter from a string to an integer to reduce length comparisons. (hyrolo-r-not): Fixed typo 'path' should be 'pat'. @@ -8380,7 +8418,7 @@ for expanded Org mode reference handling. 2019-06-16 Bob Weiner <r...@gnu.org> * hyrolo.el: Replaced buffer-substring-no-properties with match-string-no-properties where possible. - (hyrolo-entry-regexp): Changed to require whitespace following the entry prefix. + (hyrolo-hdr-and-entry-regexp): Changed to require whitespace following the entry prefix. (hyrolo-entry-group-number): Added. 2019-06-12 Bob Weiner <r...@gnu.org> diff --git a/HY-NEWS b/HY-NEWS index d5aceac2d9..5ea5c7929c 100644 --- a/HY-NEWS +++ b/HY-NEWS @@ -486,7 +486,7 @@ (hyrolo-mode): Set the local value of `outline-level' to `hyrolo-mode-outline-level' and define that function to support star - outlines and Koutlines. Also, made `hyrolo-entry-regexp' local and set + outlines and Koutlines. Also, made `hyrolo-hdr-and-entry-regexp' local and set it to its default value, after which it may be modified. *** (hyrolo-fgrep-file, hyrolo-grep-file, hyrolo-fgrep, hyrolo-grep, diff --git a/hib-doc-id.el b/hib-doc-id.el index 3f321d740b..55043eab0e 100644 --- a/hib-doc-id.el +++ b/hib-doc-id.el @@ -134,7 +134,7 @@ an error." (delim-doc-id (concat doc-id-start doc-id doc-id-end))) (cond ((null doc-id-indices) (error "(doc-id-index-entry): You must set the `doc-id-indices' variable first")) - ((let ((hyrolo-entry-regexp doc-id-index-entry-regexp)) + ((let ((hyrolo-hdr-and-entry-regexp doc-id-index-entry-regexp)) (zerop (hyrolo-grep (funcall doc-id-match doc-id) 1 doc-id-indices nil nil 'no-display))) (error "(doc-id-index-entry): %s not found in document index" @@ -175,7 +175,7 @@ match the function stored in `doc-id-p'." (defun doc-id:help (but) "Display site-specific document index entry given by doc-id BUT. Also display standard Hyperbole help for implicit button BUT." - (let ((hyrolo-entry-regexp doc-id-index-entry-regexp) + (let ((hyrolo-hdr-and-entry-regexp doc-id-index-entry-regexp) (hyrolo-display-buffer (hypb:help-buf-name "Doc ID")) (doc-id (hbut:key-to-label (hattr:get but 'lbl-key)))) (cond ((null doc-id-indices) diff --git a/hyrolo-logic.el b/hyrolo-logic.el index 833bb9ce32..097efd474a 100644 --- a/hyrolo-logic.el +++ b/hyrolo-logic.el @@ -246,7 +246,7 @@ SEXP that match entries." (end) (end-entry-hdr) (num-found 0)) - (while (re-search-forward hyrolo-entry-regexp nil t) + (while (re-search-forward hyrolo-hdr-and-entry-regexp nil t) (setq end-entry-hdr (match-end hyrolo-entry-group-number) start (match-beginning hyrolo-entry-group-number) end (hyrolo-to-entry-end include-sub-entries)) diff --git a/hyrolo.el b/hyrolo.el index dc5f03626b..8b9866f41f 100644 --- a/hyrolo.el +++ b/hyrolo.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 7-Jun-89 at 22:08:29 -;; Last-Mod: 25-Dec-23 at 03:05:40 by Bob Weiner +;; Last-Mod: 26-Dec-23 at 01:45:22 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -34,6 +34,7 @@ (require 'hypb) ;; For 'hypb:mail-address-regexp'. (require 'outline) (require 'package) +(require 'reveal) (require 'set) (require 'sort) (require 'xml) @@ -144,7 +145,7 @@ A hyrolo-file consists of: (1) an optional header beginning with and ending with a line which matches `hyrolo-hdr-regexp'; (2) one or more rolo entries which each begin with - `hyrolo-entry-regexp' and may be nested." + `hyrolo-hdr-and-entry-regexp' and may be nested." :type '(repeat file) :initialize #'custom-initialize-default :set #'hyrolo-set-file-list @@ -175,20 +176,19 @@ file are added.") (defvar hyrolo-entry-group-number 1 "Group number whose length represents the level of any entry matched. -See `hyrolo-entry-regexp'") +See `hyrolo-hdr-and-entry-regexp'") (defvar hyrolo-entry-trailing-space-group-number 2 - "Group number within `hyrolo-entry-regexp' containing trailing space.") + "Group number within `hyrolo-hdr-and-entry-regexp' containing trailing space.") (defvar hyrolo-hdr-prefix-regexp (concat hyrolo-hdr-regexp "\\|^" (if (boundp 'hbut:source-prefix) hbut:source-prefix "@loc> ") "\\|") - "Regular expression to prefix to `hyrolo-entry-regexp' and `outline-regexp'. + "Regular expression to prefix to `hyrolo-hdr-and-entry-regexp' and `outline-regexp'. It must not contain any parenthesized match groupings.") -(defvar hyrolo-entry-regexp - (concat hyrolo-hdr-prefix-regexp "^\\(\\*+\\)\\([ \t]+\\)") +(defvar hyrolo-entry-regexp "^\\([*\^L]+\\)\\([ \t\n\r]+\\)" "Regular expression to match the beginning of a HyRolo entry. This pattern must match the beginning of a line. `hyrolo-entry-group-number' must capture the entry's level in the @@ -196,10 +196,16 @@ hierarchy. `hyrolo-entry-trailing-space-group-number' must capture the entire single line whitespace following the entry hierarchy level.") +(defvar hyrolo-hdr-and-entry-regexp + (concat hyrolo-hdr-prefix-regexp hyrolo-entry-regexp) + "Regular expression to match the beginning of a HyRolo file header or entry. +This pattern must match the beginning of a line.") + ;; Support hyrolo searches in markdown files (add-hook 'markdown-mode-hook (lambda () - (setq-local hyrolo-entry-regexp (concat hyrolo-hdr-prefix-regexp "^\\(#+\\)\\([ \t\n\r]+\\)") + (setq-local hyrolo-entry-regexp "^\\(#+\\)\\([ \t\n\r]+\\)" + hyrolo-hdr-and-entry-regexp (concat hyrolo-hdr-prefix-regexp hyrolo-entry-regexp) hyrolo-entry-group-number 1 ;; `hyrolo-add' handles removing # prefix from ;; trailing-space grouping below @@ -210,12 +216,13 @@ level.") ;; Support hyrolo searches in Emacs outline files (add-hook 'outline-mode-hook (lambda () - (setq-local hyrolo-entry-regexp (concat hyrolo-hdr-prefix-regexp "^\\([*\^L]+\\)\\([ \t\n\r]+\\)") + (setq-local hyrolo-entry-regexp "^\\([*\^L]+\\)\\([ \t\n\r]+\\)" + hyrolo-hdr-and-entry-regexp (concat hyrolo-hdr-prefix-regexp hyrolo-entry-regexp) hyrolo-entry-group-number 1 ;; `hyrolo-add' handles removing # prefix from ;; trailing-space grouping below hyrolo-entry-trailing-space-group-number 2 - outline-regexp hyrolo-entry-regexp + outline-regexp (concat hyrolo-hdr-prefix-regexp "^\\([*\^L]+\\)\\([ \t\n\r]\\)") outline-level #'hyrolo-outline-level))) (defcustom hyrolo-date-format "%m/%d/%Y" @@ -241,7 +248,7 @@ It must contain a %s indicating where to put the entry name and a second :group 'hyperbole-hyrolo) (defvar hyrolo-entry-name-regexp "[-_a-zA-Z0-9@.]+\\( ?, ?[-_a-zA-Z0-9@.]+\\)?" - "*Regexp matching a hyrolo entry name after matching to `hyrolo-entry-regexp'.") + "*Regexp matching a hyrolo entry name after matching to `hyrolo-hdr-and-entry-regexp'.") (defconst hyrolo-markdown-suffix-regexp "md\\|markdown\\|mkd\\|mdown\\|mkdn\\|mdwn" "Regexp matching Markdown file suffixes.") @@ -408,7 +415,7 @@ entry which begins with the parent string." (message "Locating insertion point for `%s'..." name)) (let ((parent "") (level "") - (entry-regexp (default-value 'hyrolo-entry-regexp)) + (entry-regexp hyrolo-entry-regexp) end) (hyrolo-widen) (goto-char (point-min)) @@ -420,7 +427,8 @@ entry which begins with the parent string." name (substring name (min (1+ end) (length name)))) (if (re-search-forward (concat entry-regexp (regexp-quote parent) "\\s-") nil t) - (setq level (match-string-no-properties hyrolo-entry-group-number)) + (progn (setq level (match-string-no-properties hyrolo-entry-group-number)) + (goto-char (match-beginning 0))) (error "(hyrolo-add): Insertion failed, `%s' parent entry not found in \"%s\"" parent file))) (when (looking-at hyrolo-entry-regexp) @@ -437,7 +445,7 @@ entry which begins with the parent string." ;; entry by moving to an entry with the same (or nearest) first character ;; to that of `name'. (if (and (= level-len 1) - (equal entry-regexp (default-value 'hyrolo-entry-regexp))) + (equal entry-regexp hyrolo-entry-regexp)) (let ((case-fold-search)) (goto-char (point-min)) (if (re-search-forward (concat entry-regexp @@ -474,7 +482,7 @@ entry which begins with the parent string." (save-excursion (re-search-forward hyrolo-entry-name-regexp nil t) (point)))) - (when (and (eq major-mode 'markdown-mode) + (when (and (derived-mode-p 'markdown-mode) (string-match "\\`.*#+" entry-spc)) (setq entry-spc (substring entry-spc (length (match-string 0 entry-spc))))) (cond ((string-lessp entry name) @@ -852,7 +860,7 @@ Return t if entry is killed, nil otherwise." (case-fold-search) start end level-len) (setq buffer-read-only nil) - (re-search-backward hyrolo-entry-regexp nil t) + (re-search-backward hyrolo-hdr-and-entry-regexp nil t) (setq end (match-end 0)) (setq start (line-beginning-position) level-len (length (buffer-substring-no-properties start end))) @@ -880,7 +888,7 @@ Return t if entry is killed, nil otherwise." "Interactively search for an entry beginning with a set of search characters." (interactive) (hyrolo-funcall-match - (lambda () (hyrolo-isearch-for-regexp hyrolo-entry-regexp nil)))) + (lambda () (hyrolo-isearch-for-regexp hyrolo-hdr-and-entry-regexp nil)))) (defun hyrolo-mail-to () "Start composing mail addressed to the first e-mail address at or after point." @@ -914,22 +922,18 @@ Raise an error if a match is not found." (error (substitute-command-keys "(hyrolo-next-match): Use {\\[hyrolo-grep-or-fgrep]} to do a search first")))))) (defun hyrolo-overview (levels-to-show) - "Show the first line of all levels of rolo matches. + "Show the first line of all levels of HyRolo matches. With a prefix argument of LEVELS-TO-SHOW > 0, show the first -lines of entries only to that depth." +lines of entries only to that depth relative to the first level +of matches for the file of matches at point." (interactive "P") - (hyrolo-verify) - ;; Use {t} to display top-level cells only. - (hyrolo-map-matches - (lambda () - (if (or (null levels-to-show) - (if (called-interactively-p 'interactive) - (progn (setq levels-to-show (prefix-numeric-value current-prefix-arg)) - (<= levels-to-show 0)) - (not (integerp levels-to-show)))) - (setq levels-to-show 100)) - (outline-hide-subtree) ;; Ensure reveal-mode does not expand current entry. - (hyrolo-show-levels levels-to-show)))) + (when (or (null levels-to-show) + (if (called-interactively-p 'interactive) + (progn (setq levels-to-show (prefix-numeric-value current-prefix-arg)) + (<= levels-to-show 0)) + (not (integerp levels-to-show)))) + (setq levels-to-show 100)) + (hyrolo-show-levels levels-to-show)) (defun hyrolo-previous-match () "Move point back to the start of the previous rolo search match. @@ -1116,8 +1120,8 @@ Useful when bound to a mouse key." (if (buffer-narrowed-p) (hyrolo-widen) (let (case-fold-search) - (when (or (looking-at hyrolo-entry-regexp) - (re-search-backward hyrolo-entry-regexp nil t)) + (when (or (looking-at hyrolo-hdr-and-entry-regexp) + (re-search-backward hyrolo-hdr-and-entry-regexp nil t)) (forward-char) (narrow-to-region (1- (point)) (hyrolo-display-to-entry-end))))) (hyrolo-shrink-window) @@ -1128,11 +1132,7 @@ Useful when bound to a mouse key." Top-level matches are those with the lowest outline level among the matched entries." (interactive) - (hyrolo-verify) - (hyrolo-map-matches - (lambda () - (outline-hide-subtree) - (hyrolo-show-levels 1)))) + (hyrolo-show-levels 1)) (defun hyrolo-verify () "Verify point is in a HyRolo or HyNote match buffer." @@ -1221,7 +1221,7 @@ Output looks like so: (interactive "P") (require 'bbdb) (let ((hyrolo-file-list (list bbdb-file)) - (hyrolo-entry-regexp "^\\[") + (hyrolo-hdr-and-entry-regexp "^\\[") (hyrolo-display-format-function #'hyrolo-bbdb-entry-format) ;; Kill the bbdb file after use if it is not already in a buffer. (hyrolo-kill-buffers-after-use @@ -1243,7 +1243,7 @@ but omit file headers, negative values mean find up to the inverse of that number of entries and omit file headers. Optional COUNT-ONLY non-nil means don't retrieve matching entries. Return number of matching entries found." - (let ((hyrolo-entry-regexp "^\\[") + (let ((hyrolo-hdr-and-entry-regexp "^\\[") (hyrolo-display-format-function #'hyrolo-bbdb-entry-format) ;; Kill the bbdb file after use if it is not already in a buffer. (hyrolo-kill-buffers-after-use @@ -1286,7 +1286,7 @@ Output looks like so: (call-interactively (if arg 'hyrolo-fgrep 'hyrolo-grep)) (read-only-mode 0) (let ((case-fold-search t)) - (re-search-forward hyrolo-entry-regexp nil t)) + (re-search-forward hyrolo-hdr-and-entry-regexp nil t)) (beginning-of-line) (set-buffer-modified-p nil) (read-only-mode 1))) @@ -1696,16 +1696,16 @@ Return number of matching entries found." (setq hdr-pos (cons (point-min) (point)))) (let* ((case-fold-search t) match-end) - (re-search-forward hyrolo-entry-regexp nil t) + (re-search-forward hyrolo-hdr-and-entry-regexp nil t) (while (and (or (null max-matches) (< num-found max-matches)) (funcall hyrolo-next-match-function pattern headline-only)) (setq match-end (point)) ;; If no entry delimiters found, just return ;; the line of the match alone. - (unless (re-search-backward hyrolo-entry-regexp nil t) + (unless (re-search-backward hyrolo-hdr-and-entry-regexp nil t) (goto-char (line-beginning-position))) (setq entry-start (point)) - (unless (re-search-forward hyrolo-entry-regexp nil t) + (unless (re-search-forward hyrolo-hdr-and-entry-regexp nil t) (goto-char (line-end-position))) (unless (hyrolo-to-entry-end t) ;; If at the end of a line, move to the next line; @@ -1743,6 +1743,12 @@ Return number of matching entries found." (hyrolo-add-match pattern entry-start (point))))))) num-found)) (when (and (> num-found 0) (not count-only)) + ;; Require a final blank line so that `outline-hide-sublevels' won't hide + ;; it and combine with any next file header. + (when (/= (char-after (1- (point-max))) ?\n) + (save-excursion + (goto-char (point-max)) + (insert "\n"))) (hyrolo--cache-major-mode (current-buffer))) (when (< stuck-negative-point 0) (pop-to-buffer (current-buffer)) @@ -1822,20 +1828,24 @@ This mode does not add any outline-related font-locking. See the command `outline-mode' for more information on this mode." nil " Outl" nil (if hyrolo-outline-minor-mode + ;; enable minor mode (progn - ;; Turn off this mode if we change major modes. + ;; Add hook to turn off this mode when we change major modes. (add-hook 'change-major-mode-hook - (lambda () (hyrolo-outline-minor-mode -1)) + (lambda () + (unless (derived-mode-p 'hyrolo-mode 'kotl-mode 'markdown-mode 'org-mode 'outline-mode) + (hyrolo-outline-minor-mode -1))) nil t) (setq-local line-move-ignore-invisible t) ;; Cause use of ellipses for invisible text. (add-to-invisibility-spec '(outline . t))) + ;; disable minor mode (when outline-minor-mode-cycle (remove-overlays nil nil 'outline-overlay t)) (setq line-move-ignore-invisible nil) - ;; Cause use of ellipses for invisible text. + ;; Disable use of ellipses for invisible text. (remove-from-invisibility-spec '(outline . t)) - ;; When turning off outline mode, get rid of any outline hiding. + ;; Get rid of any outline hiding. (hyrolo-outline-show-all))) (defun hyrolo-mode () @@ -1851,29 +1861,36 @@ Calls the functions given by `hyrolo-mode-hook'. 1) outline-heading-alist) ;; This next local value is dynamically overridden in `hyrolo-grep'. - (setq-local hyrolo-entry-regexp (default-value 'hyrolo-entry-regexp) + (setq-local outline-regexp "\\([*\^L]+\\)\\([ \t\n\r]\\)" + hyrolo-entry-regexp (concat "^" "\\([*\^L]+\\)\\([ \t\n\r]+\\)") + hyrolo-hdr-and-entry-regexp (default-value 'hyrolo-hdr-and-entry-regexp) ;; In `outline-regexp', prevent matching to *word* ;; at the beginning of lines and hanging hyrolo ;; search functions by adding a whitespace char at ;; the end of the match. Note this change adds one ;; level to the level count, so `hyrolo-outline-level' ;; decrements it by one. -- rsw, 2023-11-17 - outline-regexp "\\([*\^L]+\\)\\([ \t\n\r]\\)" outline-level #'hyrolo-outline-level ;; Can't cycle because {TAB} moves to next match outline-minor-mode-cycle nil ;; For speed reasons, don't want to ever font-lock ;; in this mode - outline-minor-mode-highlight nil) + outline-minor-mode-highlight nil)) - (reveal-mode 1)) ;; Expose hidden text as move into it. - (setq major-mode 'hyrolo-mode - mode-name "HyRolo") (use-local-map hyrolo-mode-map) - ;; (set-syntax-table hyrolo-mode-syntax-table) - ;; (hyrolo-outline-minor-mode 1) ;; no keymap + + ;; !! TODO: Disable this until can get it working right with the + ;; enabling of outline-minor-mode when switch major modes in *HyRolo* + ;; typically using hyrolo-funcall-match or hyrolo-map-matches. + ;; (unless (eq major-mode 'hyrolo-mode) + ;; (reveal-mode 1)) ;; Expose hidden text as move into it. + + ;; Do this after reveal-mode is enabled. + (setq major-mode 'hyrolo-mode + mode-name "HyRolo") + (run-mode-hooks 'hyrolo-mode-hook)) (defun hyrolo-next-regexp-match (regexp headline-only) @@ -1932,7 +1949,7 @@ Stop at the first and last subheadings of a superior heading." "Hide all body lines in buffer, leaving all headings visible. Note that this does not hide the lines preceding the first heading line." (interactive) - (hyrolo-map-matches #'outline-hide-body)) + (hyrolo-map-matches #'outline-hide-body t)) (defun hyrolo-outline-hide-entry () "Hide the body directly following this heading." @@ -1964,7 +1981,7 @@ of the current heading, or to 1 if the current line is not a heading." (looking-at outline-regexp)) (funcall outline-level)) (t 1)))) - (hyrolo-map-matches (lambda () (outline-hide-sublevels levels)))) + (hyrolo-map-matches (lambda () (outline-hide-sublevels levels)) t)) (defun hyrolo-outline-hide-subtree () "Move back to the start of current subtree and hide everything after the heading. @@ -2115,7 +2132,7 @@ nil if not found." (while (and (not level) (search-forward parent nil t)) (save-excursion (forward-line 0) - (when (looking-at (concat hyrolo-entry-regexp (regexp-quote parent))) + (when (looking-at (concat hyrolo-hdr-and-entry-regexp (regexp-quote parent))) (setq level (match-string-no-properties hyrolo-entry-group-number))))) level)) ((equal name real-name)) ;; Try next file-or-buf. @@ -2310,7 +2327,7 @@ HYROLO-BUF may be a file-name, `buffer-name', or buffer." (defun hyrolo-display-to-entry-end () "Go to end of current entry, ignoring sub-entries." (let (case-fold-search) - (if (re-search-forward hyrolo-entry-regexp nil t) + (if (re-search-forward hyrolo-hdr-and-entry-regexp nil t) (progn (beginning-of-line) (point)) (goto-char (point-max))))) @@ -2417,8 +2434,8 @@ Any non-nil value returned is a cons of (<entry-name> . <entry-source>)." (save-excursion (forward-line 0) (let (case-fold-search) - (if (and (or (looking-at hyrolo-entry-regexp) - (re-search-backward hyrolo-entry-regexp nil t)) + (if (and (or (looking-at hyrolo-hdr-and-entry-regexp) + (re-search-backward hyrolo-hdr-and-entry-regexp nil t)) (save-match-data (not (looking-at hyrolo-hdr-regexp)))) (progn (goto-char (match-end 0)) (skip-chars-forward " \t") @@ -2443,7 +2460,8 @@ Any non-nil value returned is a cons of (<entry-name> . <entry-source>)." ;; set its parent mode property to org-mode so can `derived-mode-p' ;; checks will pass. (put 'hyrolo-org-mode 'derived-mode-parent 'org-mode) - (setq-local hyrolo-entry-regexp (concat hyrolo-hdr-prefix-regexp "^\\(\\*+\\)\\([ ]+\\)") + (setq-local hyrolo-entry-regexp "^\\(\\*+\\)\\([ ]+\\)" + hyrolo-hdr-and-entry-regexp (concat hyrolo-hdr-prefix-regexp hyrolo-entry-regexp) hyrolo-entry-group-number 1 ;; `hyrolo-add' handles removing # prefix from ;; trailing-space grouping below @@ -2506,7 +2524,7 @@ The date format is determined by the setting, `hyrolo-date-format'." "Return the minimum HyRolo level within a single file of matches." (save-excursion (goto-char (point-min)) - (let ((min-level 1)) + (let ((min-level 1000)) (when (looking-at outline-regexp) (funcall outline-level)) (while (outline-next-heading) @@ -2520,45 +2538,32 @@ The date format is determined by the setting, `hyrolo-date-format'." (let ((hyrolo-file-list (hypb:filter-directories file-regexp dirs))) (call-interactively search-cmd))) -(defun hyrolo-show-levels (num-levels) - "Show only the first line of up to NUM-LEVELS of HyRolo matches. -NUM-LEVELS must be 1 or greater and is relative to the first -level of matches, so if NUM-LEVELS is 2 and the first level +(defun hyrolo-show-levels (levels-to-show) + "Show only the first line of up to LEVELS-TO-SHOW of HyRolo matches. +LEVELS-TO-SHOW must be 1 or greater and is relative to the first +level of matches, so if LEVELS-TO-SHOW is 2 and the first level matched from an outline is level 3, then levels 3 and 4 will be shown. Any call to this function should be wrapped in a call to `hyrolo-map-matches'." + (hyrolo-verify) (outline-show-all) - (save-excursion - (goto-char (point-min)) - (if (not (hyrolo-hdr-move-after-p)) - (outline-hide-sublevels num-levels) - (goto-char (point-min)) - (let (start - end - max-level-to-show) - (while (re-search-forward hyrolo-hdr-regexp nil t 2) - (forward-line) - (setq start (point) - end (if (re-search-forward hyrolo-hdr-regexp nil t) - (progn (beginning-of-line) (point)) - (goto-char (point-max)))) - (save-restriction - (narrow-to-region start end) - (if (> num-levels 20) - (setq max-level-to-show num-levels) - (setq max-level-to-show (+ (hyrolo-min-matched-level) - (1- num-levels)))) - (outline-hide-sublevels max-level-to-show))))) - (goto-char (point-min)) - ;; This pause forces a window redisplay that maximizes the - ;; entries displayed for any final location of point. - (sit-for 0.001)) - ;; Need to leave point on a visible character or since - ;; hyrolo uses reveal-mode, redisplay will rexpand - ;; hidden entries to make point visible. - (hyrolo-back-to-visible-point)) + (hyrolo-outline-hide-subtree) ;; Ensure reveal-mode does not expand current entry. + ;; Use {t} to display top-level cells only. + (hyrolo-map-matches + (lambda () + (save-excursion + (save-restriction + (goto-char (point-min)) + (hyrolo-hdr-move-after-p) + ;; Prevent collapsing of initial file header + (narrow-to-region (point) (point-max)) + (let ((max-level-to-show (+ (hyrolo-min-matched-level) + (1- levels-to-show)))) + (outline-hide-sublevels max-level-to-show) + (goto-char (point-min)))))) + t)) (defun hyrolo-shrink-window () (let* ((lines (count-lines (point-min) (point-max))) @@ -2700,7 +2705,14 @@ prior to applying FUNC." (font-lock-mode (if ofont-lock 1 0)) (when (fboundp 'orgtbl-mode) ;; Disable as overrides single letter keys - (orgtbl-mode 0)))) + (orgtbl-mode 0)) + ;; This pause forces a window redisplay that maximizes the + ;; entries displayed for any final location of point. + (sit-for 0.001) + ;; Need to leave point on a visible character or since + ;; hyrolo uses reveal-mode, redisplay will rexpand + ;; hidden entries to make point visible. + (hyrolo-back-to-visible-point))) (save-excursion (funcall func))))) @@ -2742,7 +2754,14 @@ prior to applying FUNC." (font-lock-mode (if ofont-lock 1 0)) (when (fboundp 'orgtbl-mode) ;; Disable as overrides single letter keys - (orgtbl-mode 0)))))) + (orgtbl-mode 0)) + ;; This pause forces a window redisplay that maximizes the + ;; entries displayed for any final location of point. + (sit-for 0.001) + ;; Need to leave point on a visible character or since + ;; hyrolo uses reveal-mode, redisplay will rexpand + ;; hidden entries to make point visible. + (hyrolo-back-to-visible-point))))) (funcall func)))) (defun hyrolo-cache-location-start-and-end () @@ -2819,10 +2838,10 @@ Ensure MATCHED-BUF's `major-mode' is stored in the hash table." (defun hyrolo-cache-set-major-mode (pos) "Set the `major-mode' for POS in the current HyRolo display buffer. -Add `hyrolo-hdr-regexp' to `hyrolo-entry-regexp' and `outline-regexp'." +Add `hyrolo-hdr-regexp' to `hyrolo-hdr-and-entry-regexp' and `outline-regexp'." (funcall (hyrolo-cache-get-major-mode-from-pos pos)) - (unless (string-prefix-p hyrolo-hdr-regexp hyrolo-entry-regexp) - (setq-local hyrolo-entry-regexp (concat hyrolo-hdr-prefix-regexp hyrolo-entry-regexp))) + (unless (string-prefix-p hyrolo-hdr-regexp hyrolo-hdr-and-entry-regexp) + (setq-local hyrolo-hdr-and-entry-regexp (concat hyrolo-hdr-prefix-regexp hyrolo-hdr-and-entry-regexp))) (unless (string-prefix-p hyrolo-hdr-regexp outline-regexp) (setq-local outline-regexp (concat hyrolo-hdr-prefix-regexp outline-regexp))) (when (eq outline-level #'markdown-outline-level) @@ -2881,6 +2900,48 @@ Add `hyrolo-hdr-regexp' to `hyrolo-entry-regexp' and `outline-regexp'." (substitute-key-definition otl-cmd hyrolo-cmd hyrolo-mode-map))) outline-mode-prefix-map))) +;;; Integrate reveal-mode with HyRolo. + +;; Note that `outline-reveal-toggle-invisible' is the function +;; stored in the `outline' `reveal-toggle-invisible' property. It +;; is called from `reveal-open-new-overlays' and - +;; `reveal-close-old-overlays' which are called from within +;; `reveal-post-command' on `post-command-hook'. Below we update +;; `reveal-post-command' to work with HyRolo. + +(defun reveal-post-command () + ;; Refresh the spots that might have changed. + ;; `Refreshing' here means to try and re-hide the corresponding text. + ;; We don't refresh everything correctly: + ;; - we only refresh spots in the current window. + ;; FIXME: do we actually know that (current-buffer) = (window-buffer) ? + (with-local-quit + (with-demoted-errors "Reveal: %s" + (let ((old-ols + (delq nil + (mapcar + (lambda (x) + ;; We refresh any spot in the current window as well + ;; as any spots associated with a dead window or + ;; a window which does not show this buffer any more. + (cond + ((eq (car x) (selected-window)) (cdr x)) + ((not (and (window-live-p (car x)) + (eq (window-buffer (car x)) + (current-buffer)))) + ;; Adopt this since it's owned by a window that's + ;; either not live or at least not showing this + ;; buffer any more. + (setcar x (selected-window)) + (cdr x)))) + reveal-open-spots)))) + (hyrolo-funcall-match + (lambda () + (setq old-ols (reveal-open-new-overlays old-ols)) + (when reveal-auto-hide + (reveal-close-old-overlays old-ols))) + t))))) + (provide 'hyrolo) ;;; hyrolo.el ends here diff --git a/kotl/kimport.el b/kotl/kimport.el index 1a5333cc04..d90df7b391 100644 --- a/kotl/kimport.el +++ b/kotl/kimport.el @@ -673,19 +673,19 @@ IMPORT-FROM so far (initially 0). Return a cons of MAX-POS and COUNT." (set-buffer import-from) (let ((start (point)) - (hyrolo-entry-regexp kimport:star-heading) + (hyrolo-hdr-and-entry-regexp kimport:star-heading) (case-fold-search) max-pos-and-count subtree-p end contents node-level child-label) ;; While find cells at import-level or deeper ... - (while (and (re-search-forward hyrolo-entry-regexp nil t) + (while (and (re-search-forward hyrolo-hdr-and-entry-regexp nil t) (<= import-level (setq node-level (length (match-string 1))))) (skip-chars-forward " \t") (setq start (point) end (hyrolo-to-entry-end) - subtree-p (if (looking-at hyrolo-entry-regexp) + subtree-p (if (looking-at hyrolo-hdr-and-entry-regexp) (< node-level (length (match-string 1))))) (skip-chars-backward "\n\r") diff --git a/kotl/kotl-mode.el b/kotl/kotl-mode.el index 96cab5192b..4972c6b5dc 100644 --- a/kotl/kotl-mode.el +++ b/kotl/kotl-mode.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 6/30/93 -;; Last-Mod: 25-Dec-23 at 00:22:31 by Bob Weiner +;; Last-Mod: 25-Dec-23 at 23:33:09 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -103,6 +103,7 @@ It provides the following keys: (interactive) (mapc #'make-local-variable '(hyrolo-entry-regexp + hyrolo-hdr-and-entry-regexp hyrolo-entry-group-number hyrolo-entry-trailing-space-group-number indent-line-function @@ -149,7 +150,8 @@ It provides the following keys: (unless (and (boundp 'kotl-previous-mode) kotl-previous-mode (eq kotl-previous-mode #'kotl-mode) (not (string-prefix-p hyrolo-display-buffer (buffer-name)))) - (setq hyrolo-entry-regexp (concat hyrolo-hdr-prefix-regexp "^" kview:outline-regexp) + (setq hyrolo-entry-regexp (concat "^" kview:outline-regexp) + hyrolo-hdr-and-entry-regexp (concat hyrolo-hdr-prefix-regexp hyrolo-entry-regexp) hyrolo-entry-group-number 2 hyrolo-entry-trailing-space-group-number 3 @@ -168,7 +170,7 @@ It provides the following keys: mode-line-format (copy-sequence mode-line-format) mode-line-format (set:remove "%n" mode-line-format) outline-level #'kcell-view:level - outline-regexp hyrolo-entry-regexp)) + outline-regexp hyrolo-hdr-and-entry-regexp)) ;; (when (fboundp 'add-to-invisibility-spec) (add-to-invisibility-spec '(outline . t))) @@ -3422,7 +3424,7 @@ but always operates upon the current view." ;; Adapted from outline-reveal-toggle-invisible; called by isearch. (defun kotl-mode:reveal-toggle-invisible (o hidep) (if (not (derived-mode-p 'kotl-mode)) - (if (and (eq (current-buffer) hyrolo-display-buffer) + (if (and (eq (current-buffer) (get-buffer hyrolo-display-buffer)) (eq (hyrolo-cache-get-major-mode-from-pos (point)) 'kotl-mode)) (hyrolo-funcall-match diff --git a/man/hyperbole.html b/man/hyperbole.html index 60f037e3e0..027b53f4d2 100644 --- a/man/hyperbole.html +++ b/man/hyperbole.html @@ -7745,11 +7745,11 @@ is "^===". This allows lines of all equal signs to visually separate matching entries retrieved from multiple files during a single search. </p> </dd> -<dt><code>hyrolo-entry-regexp</code> -<a name="index-hyrolo_002dentry_002dregexp"></a> +<dt><code>hyrolo-hdr-and-entry-regexp</code> +<a name="index-hyrolo_002dhdr_002dand_002dentry_002dregexp"></a> </dt> <dd><p>The rolo entry start delimiter is given by the regular expression -variable, <code>hyrolo-entry-regexp</code>, whose default value is "^\*+", i.e. +variable, <code>hyrolo-hdr-and-entry-regexp</code>, whose default value is "^\*+", i.e. one or more asterisks at the beginning of a line. </p> </dd> @@ -14570,7 +14570,6 @@ Next: <a href="#Concept-Index" accesskey="n" rel="next">Concept Index</a>, Previ <tr><td></td><td valign="top"><a href="#index-hyrolo_002dedit_002dhook">hyrolo-edit-hook</a>:</td><td> </td><td valign="top"><a href="#HyRolo-Keys">HyRolo Keys</a></td></tr> <tr><td></td><td valign="top"><a href="#index-hyrolo_002dedit_002dhook-1">hyrolo-edit-hook</a>:</td><td> </td><td valign="top"><a href="#Hook-Variables">Hook Variables</a></td></tr> <tr><td></td><td valign="top"><a href="#index-hyrolo_002demail_002dformat">hyrolo-email-format</a>:</td><td> </td><td valign="top"><a href="#HyRolo-Settings">HyRolo Settings</a></td></tr> -<tr><td></td><td valign="top"><a href="#index-hyrolo_002dentry_002dregexp">hyrolo-entry-regexp</a>:</td><td> </td><td valign="top"><a href="#HyRolo-Settings">HyRolo Settings</a></td></tr> <tr><td></td><td valign="top"><a href="#index-hyrolo_002dfgrep"><code>hyrolo-fgrep</code></a>:</td><td> </td><td valign="top"><a href="#HyRolo-Menu">HyRolo Menu</a></td></tr> <tr><td></td><td valign="top"><a href="#index-hyrolo_002dfile_002dlist">hyrolo-file-list</a>:</td><td> </td><td valign="top"><a href="#HyRolo-Concepts">HyRolo Concepts</a></td></tr> <tr><td></td><td valign="top"><a href="#index-hyrolo_002dfile_002dlist-1">hyrolo-file-list</a>:</td><td> </td><td valign="top"><a href="#HyRolo-Settings">HyRolo Settings</a></td></tr> @@ -14579,6 +14578,7 @@ Next: <a href="#Concept-Index" accesskey="n" rel="next">Concept Index</a>, Previ <tr><td></td><td valign="top"><a href="#index-hyrolo_002dgoogle_002dcontacts_002dflag">hyrolo-google-contacts-flag</a>:</td><td> </td><td valign="top"><a href="#HyRolo-Settings">HyRolo Settings</a></td></tr> <tr><td></td><td valign="top"><a href="#index-hyrolo_002dgoogle_002dcontacts_002dgrep"><code>hyrolo-google-contacts-grep</code></a>:</td><td> </td><td valign="top"><a href="#HyRolo-Settings">HyRolo Settings</a></td></tr> <tr><td></td><td valign="top"><a href="#index-hyrolo_002dgrep"><code>hyrolo-grep</code></a>:</td><td> </td><td valign="top"><a href="#HyRolo-Menu">HyRolo Menu</a></td></tr> +<tr><td></td><td valign="top"><a href="#index-hyrolo_002dhdr_002dand_002dentry_002dregexp">hyrolo-hdr-and-entry-regexp</a>:</td><td> </td><td valign="top"><a href="#HyRolo-Settings">HyRolo Settings</a></td></tr> <tr><td></td><td valign="top"><a href="#index-hyrolo_002dhdr_002dregexp">hyrolo-hdr-regexp</a>:</td><td> </td><td valign="top"><a href="#HyRolo-Settings">HyRolo Settings</a></td></tr> <tr><td></td><td valign="top"><a href="#index-hyrolo_002dhelm_002dorg_002drifle"><code>hyrolo-helm-org-rifle</code></a>:</td><td> </td><td valign="top"><a href="#HyRolo-Menu">HyRolo Menu</a></td></tr> <tr><td></td><td valign="top"><a href="#index-hyrolo_002dhelm_002dorg_002drifle-1"><code>hyrolo-helm-org-rifle</code></a>:</td><td> </td><td valign="top"><a href="#Glossary">Glossary</a></td></tr> diff --git a/man/hyperbole.info b/man/hyperbole.info index c28b93dc06..8d541e8b06 100644 Binary files a/man/hyperbole.info and b/man/hyperbole.info differ diff --git a/man/hyperbole.pdf b/man/hyperbole.pdf index 81d83e3c11..607290901b 100644 Binary files a/man/hyperbole.pdf and b/man/hyperbole.pdf differ diff --git a/man/hyperbole.texi b/man/hyperbole.texi index 5e2cca6020..e94569e7f2 100644 --- a/man/hyperbole.texi +++ b/man/hyperbole.texi @@ -7,7 +7,7 @@ @c Author: Bob Weiner @c @c Orig-Date: 6-Nov-91 at 11:18:03 -@c Last-Mod: 25-Dec-23 at 02:39:36 by Bob Weiner +@c Last-Mod: 25-Dec-23 at 22:39:22 by Bob Weiner @c %**start of header (This is for running Texinfo on a region.) @setfilename hyperbole.info @@ -6504,9 +6504,9 @@ regular expression variable, @code{hyrolo-hdr-regexp}, whose default value is "^===". This allows lines of all equal signs to visually separate matching entries retrieved from multiple files during a single search. -@item hyrolo-entry-regexp +@item hyrolo-hdr-and-entry-regexp The rolo entry start delimiter is given by the regular expression -variable, @code{hyrolo-entry-regexp}, whose default value is "^\*+", i.e.@: +variable, @code{hyrolo-hdr-and-entry-regexp}, whose default value is "^\*+", i.e.@: one or more asterisks at the beginning of a line. @item hyrolo-display-format-function diff --git a/test/hyrolo-tests.el b/test/hyrolo-tests.el index 6e989e486f..d34dd6512a 100644 --- a/test/hyrolo-tests.el +++ b/test/hyrolo-tests.el @@ -3,7 +3,7 @@ ;; Author: Mats Lidell <ma...@gnu.org> ;; ;; Orig-Date: 19-Jun-21 at 22:42:00 -;; Last-Mod: 23-Dec-23 at 01:25:40 by Bob Weiner +;; Last-Mod: 26-Dec-23 at 01:57:38 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -23,6 +23,7 @@ (require 'hyrolo) (require 'hyrolo-demo) (require 'hy-test-helpers "test/hy-test-helpers") +(require 'hib-kbd) (require 'with-simulated-input) (declare-function hy-test-helpers:consume-input-events "hy-test-helpers") @@ -214,7 +215,6 @@ and {b} the previous same level cell." (ert-deftest hyrolo-sort-test () "HyRolo files can be sorted." - :expected-result :failed (let ((hyrolo-file (make-temp-file "hypb" nil ".otl"))) (unwind-protect (let ((hyrolo-file-list (list hyrolo-file)) @@ -316,10 +316,10 @@ and {b} the previous same level cell." (should (looking-at-p "===")) (hyrolo-next-visible-heading 1) (should (looking-at-p "* heading"))) - (with-simulated-input "y RET" ; Do you want to revisit the file normally now? - (action-key) - (should (equal (current-buffer) (find-buffer-visiting org-file))) - (should (looking-at-p "* heading")))) + (kbd-key:key-series-to-events "y C-f") + (action-key) + (should (equal (current-buffer) (find-buffer-visiting org-file))) + (should (looking-at-p "* heading"))) (hy-delete-file-and-buffer org-file) (kill-buffer "*HyRolo*") (delete-directory temporary-file-directory)))) @@ -343,7 +343,7 @@ and {b} the previous same level cell." (should (looking-at-p "===")) (hyrolo-next-visible-heading 1) (should (looking-at-p ".*1\\. heading"))) - (with-simulated-input "y RET" ; Do you want to revisit the file normally now? + (with-simulated-input "y C-f" ; Do you want to revisit the file normally now? (action-key) (should (equal (current-buffer) (find-buffer-visiting kotl-file))) (should (looking-at-p "heading")))) @@ -364,10 +364,9 @@ and {b} the previous same level cell." (should (looking-at-p "===")) (hyrolo-next-visible-heading 1) (should (looking-at-p "* heading"))) - (with-simulated-input "y RET" ; Do you want to revisit the file normally now? - (action-key) - (should (equal (current-buffer) (find-buffer-visiting outl-file))) - (should (looking-at-p "* heading")))) + (action-key) + (should (equal (current-buffer) (find-buffer-visiting outl-file))) + (should (looking-at-p "* heading"))) (hy-delete-file-and-buffer outl-file) (kill-buffer "*HyRolo*") (delete-directory temporary-file-directory)))) @@ -385,10 +384,9 @@ and {b} the previous same level cell." (should (looking-at-p "===")) (hyrolo-next-visible-heading 1) (should (looking-at-p "# heading"))) - (with-simulated-input "y RET" ; Do you want to revisit the file normally now? - (action-key) - (should (equal (current-buffer) (find-buffer-visiting md-file))) - (should (looking-at-p "# heading")))) + (action-key) + (should (equal (current-buffer) (find-buffer-visiting md-file))) + (should (looking-at-p "# heading"))) (hy-delete-file-and-buffer md-file) (kill-buffer "*HyRolo*") (delete-directory temporary-file-directory)))) @@ -415,10 +413,9 @@ Match a string in a level 2 child cell." (should (looking-at-p "===")) (hyrolo-next-visible-heading 1) (should (looking-at-p ".*1a\\. heading"))) - (with-simulated-input "y RET" ; Do you want to revisit the file normally now? - (action-key) - (should (equal (current-buffer) (find-buffer-visiting kotl-file))) - (should (looking-at-p "heading")))) + (action-key) + (should (equal (current-buffer) (find-buffer-visiting kotl-file))) + (should (looking-at-p "heading"))) (hy-delete-file-and-buffer kotl-file) (kill-buffer "*HyRolo*") (delete-directory temporary-file-directory)))) @@ -445,10 +442,9 @@ Match a string in the second cell." (should (looking-at-p "===")) (hyrolo-next-visible-heading 1) (should (looking-at-p ".*2\\. heading"))) - (with-simulated-input "y RET" ; Do you want to revisit the file normally now? - (action-key) - (should (equal (current-buffer) (find-buffer-visiting kotl-file))) - (should (looking-at-p "heading")))) + (action-key) + (should (equal (current-buffer) (find-buffer-visiting kotl-file))) + (should (looking-at-p "heading"))) (hy-delete-file-and-buffer kotl-file) (kill-buffer "*HyRolo*") (delete-directory temporary-file-directory))))