branch: externals/hyperbole commit ea8dc8dd6921cf47136acb47e882a09cf1c48dbf Merge: 14707845db 4a576b4e7d Author: Robert Weiner <r...@gnu.org> Commit: GitHub <nore...@github.com>
Merge pull request #747 from rswgnu/rsw hyrolo.el, hsys-consult.el - Fix/extend HyRolo cmd consult support --- ChangeLog | 54 ++++++++++++++++++++++++- hpath.el | 39 +++++++++++------- hsys-consult.el | 51 ++++++++++++++++++++++-- hui-mini.el | 17 ++++---- hyrolo.el | 120 +++++++++++++++++++++++++++++++++----------------------- 5 files changed, 207 insertions(+), 74 deletions(-) diff --git a/ChangeLog b/ChangeLog index 056274193d..a4e3ac9799 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,57 @@ +2025-06-15 Bob Weiner <r...@gnu.org> + +* hsys-consult.el (hsys-consult--grep-paths): Fix to ensure any env or lisp + variables in paths are replaced so grep does not ignore them. + (hsys-consult-flag): Add this customization, set to t by default, i.e. + use and install the 'custom' package when needed by Hyperbole. + (hsys-consult-get-exit-value, hsys-consult--org-roam-call-function, + hsys-consult-grep, hsys-consult-grep-headlines-read-regexp, + hsys-consult--grep-paths): Conditionalize these calls based on the value + of the above flag. + +* hpath.el (hpath:expand-list): Fix 'hpath:expand' call so it does not require + existing paths since its first arg may contain wildcards. Simplify code + and expand all readable, non-symlink directories recursively. If a string + is mistakenly sent instead of a list, make it a list. + (hpath:expand-with-variable): Fix so does not prepend + 'hpath:auto-variable-alist' to paths with wildcards in them when + 'find-file-wildcards' is non-nil. This expands such paths in the + 'default-directory' properly. + +* hyrolo.el (hyrolo-org, hyrolo-org-roam): Fix in interactive call to expand + filenames in 'org-directory' and 'org-roam-directory' respectively. + (hyrolo-file-list): Instead of leaving this nil by default, set + it to a list of the default .rolo file. + (hyrolo-mode-map): Since the *HyRolo* match buffer is read-only, + rebind RET to be the 'action-key', so a simple press edits the current + record in its source file. + (hyrolo-find-file): If reading the file triggers an error, simply + log it to the *Messages* buffer and ignore that file so does not get in + the way of searching others. + (hyrolo-to): Fix so when 'hyrolo-name-entry' has been set + if the first line of an entry contains slashes, these are treatee + as part of a literal string to find the source match, rather than + than as a parent/child delimiter. + +2025-06-12 Bob Weiner <r...@gnu.org> + +* hyrolo.el (hyrolo-tags-view): Fix error triggered by 'org-tags-view' call + when send non .org file in 'org-agenda-files'. Fix by filtering out + non-org files which can't have tags in them anyway. + (hyrolo-refresh-file-list): Ensure 'hyrolo-file-list' is set + to default file if nil. + 2025-06-08 Bob Weiner <r...@gnu.org> +* hsys-consult.el (hsys-consult-apropos): Add and autoload for interactive + selection of apropos symbols. + +* hui-mini.el (hui:menu-rolo): Remove "HelmFind" as is outdated; use "ConsultFind" + instead. + +* hpath.el (hpath:auto-completing-read-modes): Add 'consult-org-roam-mode', + 'icomplete-mode', 'org-roam-mode', and 'vertico-mode'. + * hyrolo.el (hyrolo-consult-fgrep): Add and use in 'hyrolo-grep-input' when 'read-function' argument is 'read-string'. @@ -2115,7 +2167,7 @@ value to be [[WikiWord]] not [[file:WikiWord.org][WikiWord]]. hywiki-maybe-highlight-off-page-name, hywiki-maybe-highlight-on-page-name): Add for use in 'post-self-insert-hook' idle HyWikiWord highlighter (setup from - 'hywiki-buttonize-character-commands'. + 'hywiki-buttonize-character-commands'). (hywiki-maybe-dehighlight-between-page-names, hywiki-maybe-dehighlight-off-page-name, hywiki-maybe-dehighlight-on-page-name): Add for use in diff --git a/hpath.el b/hpath.el index 7d26b0a19b..b05aa1dde3 100644 --- a/hpath.el +++ b/hpath.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 1-Nov-91 at 00:44:23 -;; Last-Mod: 27-May-25 at 00:41:20 by Bob Weiner +;; Last-Mod: 15-Jun-25 at 12:03:03 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -39,7 +39,10 @@ ;;; Public Variables ;;; ************************************************************************ -(defcustom hpath:auto-completing-read-modes '(helm-mode ivy-mode selectrum-mode) +(defcustom hpath:auto-completing-read-modes '(consult-org-roam-mode helm-mode + icomplete-mode ivy-mode + org-roam-mode vertico-mode + selectrum-mode) "*List of boolean mode variables whose modes automatically list completions. These are modes where completions are listed without the need for pressing the ? key." @@ -1276,19 +1279,22 @@ only if it exists, otherwise, return nil." (defun hpath:expand-list (paths &optional match-regexp filter) "Return expansions of PATHS, a list of dirs or wildcarded file patterns. -PATHS expansion recursively walks directory trees to include +PATHS expansion recursively walks readable directory trees to include files with names matching optional MATCH-REGEXP (otherwise, all files), filters out non-strings and any filenames not matching the optional predicate FILTER, expands file wildcards when `find-file-wildcards' is non-nil (the default), substitutes for multiple $var environment variables, and substitutes up to one ${variable} per path." + ;; Handle when caller sends a string, forgetting to make it a list. + (when (stringp paths) + (setq paths (list paths))) ;; Previously `filter' was a flag which when t, invoked ;; `file-exists-p'; maintain this backward compatibility. (when (eq filter t) (setq filter #'file-exists-p)) (setq paths (mapcan (lambda (path-pat-or-list) - (setq path-pat-or-list (hpath:expand path-pat-or-list filter)) + (setq path-pat-or-list (hpath:expand path-pat-or-list)) (when (setq path-pat-or-list (or (when (and path-pat-or-list find-file-wildcards) (file-expand-wildcards path-pat-or-list)) @@ -1296,13 +1302,14 @@ ${variable} per path." (when (and path-pat-or-list (funcall filter path-pat-or-list)) (list path-pat-or-list)) (list path-pat-or-list)))) - (if (= (length path-pat-or-list) 1) - (setq path-pat-or-list (car path-pat-or-list)) - (setq paths (nconc (cdr path-pat-or-list) paths) - path-pat-or-list (car path-pat-or-list))) - (if (and path-pat-or-list (file-directory-p path-pat-or-list)) - (directory-files-recursively path-pat-or-list (or match-regexp "")) - (list path-pat-or-list)))) + (when path-pat-or-list + (mapcan (lambda (path) + (if (and (file-directory-p path) + (not (file-symlink-p path)) + (file-readable-p path)) + (directory-files-recursively path (or match-regexp "")) + (list path))) + path-pat-or-list)))) (seq-filter #'stringp paths))) (if filter (seq-filter filter paths) @@ -1359,9 +1366,13 @@ If PATH is absolute, return it unchanged." regexp variable variable-name) - (if (file-exists-p path) - ;; Path is either absolute or relative to current directory - ;; so don't expand into hpath:auto-variable-alist paths. + (if (or (file-exists-p path) + (and find-file-wildcards + (not (file-name-quoted-p path)) + (string-match "[[*?]" path))) + ;; Path is either absolute, contains wildcards or is + ;; relative to the current directory, so don't expand + ;; into `hpath:auto-variable-alist' paths. (setq path (expand-file-name path)) (unless (or (file-name-absolute-p path) (hpath:url-p path) diff --git a/hsys-consult.el b/hsys-consult.el index 17d5c82c4c..b2ab810ad2 100644 --- a/hsys-consult.el +++ b/hsys-consult.el @@ -2,7 +2,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 4-Jul-24 at 09:57:18 -;; Last-Mod: 10-Jun-25 at 17:44:05 by Mats Lidell +;; Last-Mod: 15-Jun-25 at 18:59:52 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -66,10 +66,39 @@ (defvar hsys-consult-exit-value nil "Value from a user-defined exit-hook sent to `hsys-consult-get-exit-value'.") +(defcustom hsys-consult-flag t + "Non-nil means use the consult package with vertico for filtering searches. +When non-nil and interactively calling non-consult-specific +Hyperbole search and yank commands, if consult is installed it +will be used to filter to matching file lines. For Hyperbole +consult-specific commands, when this is non-nil and consult is +not installed, automatically install it and then run the command. +When nil, trigger an error that consult is not installed." + :type 'boolean + :group 'hyperbole-commands) + ;;; ************************************************************************ ;;; Public functions ;;; ************************************************************************ +;;;###autoload +(defun hsys-consult-apropos (&optional include-all-flag) + "Summarize all meaningful symbols matching interactively chosen terms. +With optional INCLUDE-ALL-FLAG (prefix arg interactively) non-nil, +include all bound symbols. + +Requires use of `vertico' for completions." + (interactive "P") + (apropos + (split-string + (hsys-consult-get-exit-value + '(car vertico--input) + #'consult--read + obarray + :prompt "Consult Apropos: ") + "[ \t]+" t) + include-all-flag)) + ;;;###autoload (defun hsys-consult-get-version () "Return the string version of the installed consult package or nil." @@ -97,9 +126,12 @@ per file to the absolute value of MAX-MATCHES, if given and not 0. If With optional PROMPT string, use this as the first part of the grep prompt; omit any trailing colon and space in the prompt." + (unless hsys-consult-flag + (error "`%s' command requires `hsys-consult-flag' set to t" this-command)) (unless (package-installed-p 'consult) (package-install 'consult)) (require 'consult) + (let ((consult-version (hsys-consult-get-version))) ;; Multi-file support added after consult version "0.32" (when (not (and consult-version (string-greaterp consult-version "0.32"))) @@ -144,7 +176,7 @@ and return the selected \"file:line:line-contents\". GREP-FUNCTION must take these arguments: regexp max-matches path-list prompt. Without `consult', just read a REGEXP with PROMPT." - (if (fboundp 'consult-grep) + (if (and hsys-consult-flag (fboundp 'consult-grep)) (substring-no-properties (hsys-consult-get-exit-value nil @@ -163,7 +195,7 @@ The function determines the org files searched for matches and is given two arguments when called: a regexp of tags to match and a 0 max-count which finds all matches within headlines only." (interactive) - (when (hsys-org-at-tags-p) + (when (and hsys-consult-flag (hsys-org-at-tags-p)) (funcall org-consult-grep-function (hsys-consult--org-grep-tags-string) 0))) (defun hsys-consult-hyrolo-grep-tags () @@ -246,9 +278,12 @@ that start with the '^[*#]+[ \t]*' regexp)." If EXIT-VALUE is non-nil, i.e. an sexpression or function of no arguments, store and return its result value into `hsys-consult-exit-value', Otherwise, return the selection from CONSULT-FUNCTION." + (unless hsys-consult-flag + (error "`%s' command requires `hsys-consult-flag' set to t" this-command)) (unless (functionp consult-function) (user-error "(hsys-consult-get-exit-value): First arg must be a function, not `%s'" consult-function)) + (save-excursion (save-window-excursion (if exit-value @@ -282,6 +317,8 @@ start of headline text only (lines that start with a '^[*#]+[ With optional PROMPT string, use this as the first part of the grep prompt; omit any trailing colon and space in the prompt." + (unless hsys-consult-flag + (error "`%s' command requires `hsys-consult-flag' set to t" this-command)) (unless (package-installed-p 'consult) (package-install 'consult)) (require 'consult) @@ -310,6 +347,11 @@ grep prompt; omit any trailing colon and space in the prompt." (concat consult-ripgrep-args (format " -m %d" (abs max-matches)))) consult-ripgrep-args))) + + ;; Ensure any env or lisp variables in paths are replaced so + ;; grep does not ignore them. + (setq paths (mapcar #'hpath:expand paths)) + ;; Consult split style usually uses '#' as a separator char but ;; that interferes with matching to Markdown # chars at the start ;; of a line in the regexp, so disable the separator char as it is @@ -346,6 +388,8 @@ tag around point." (defun hsys-consult--org-roam-call-function (func) "Install Org Roam if necessary and then call an Org Roam FUNC." + (unless hsys-consult-flag + (error "`%s' command requires `hsys-consult-flag' set to t" this-command)) (unless (package-installed-p 'org-roam) (package-install 'org-roam)) (require 'org-roam) @@ -353,6 +397,7 @@ tag around point." (make-directory org-roam-directory)) (unless org-roam-db-autosync-mode (org-roam-db-autosync-mode)) + (if (file-readable-p org-roam-directory) (funcall func) (error "`org-roam-directory', \"%s\", does not exist" org-roam-directory))) diff --git a/hui-mini.el b/hui-mini.el index 9727874ece..4daa3a3398 100644 --- a/hui-mini.el +++ b/hui-mini.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 15-Oct-91 at 20:13:17 -;; Last-Mod: 22-Feb-25 at 22:15:38 by Bob Weiner +;; Last-Mod: 8-Jun-25 at 12:38:22 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -1084,8 +1084,8 @@ support underlined faces as well." '("Display" hyrolo-display-matches "Display last found rolo matches again.") '("Edit" hyrolo-edit "Edit an existing rolo entry.") '("FileFind" hyrolo-find-file "Find an existing rolo file.") - (when (fboundp 'helm-org-rifle-files) ;; allow for autoloading - '("HelmFind" hyrolo-helm-org-rifle "Interactively narrow HyRolo matches using Helm.")) + ;; (when (fboundp 'helm-org-rifle-files) ;; allow for autoloading + ;; '("HelmFind" hyrolo-helm-org-rifle "Interactively narrow HyRolo matches using Helm.")) '("Info" (id-info "(hyperbole)HyRolo") "Display manual section on HyRolo.") '("Kill" hyrolo-kill "Kill an existing rolo entry.") '("Mail" hyrolo-mail-to "Mail to address following point.") @@ -1112,7 +1112,8 @@ support underlined faces as well." ("Calendar" calendar) ("Directories" hui:menu-to-personal-section) ;; ("E") - ("recent-Files" recentf-open-files) + ("org-roam-Find" hyrolo-org-roam) + ;; ("recent-Files" recentf-open-files) ("Global-Buttons" (find-file (expand-file-name hbmap:filename hbmap:dir-user))) ;; ("Helm" (menu . helm) "Display Hyperbole helm control menu") ;; ("I") @@ -1120,8 +1121,8 @@ support underlined faces as well." ("Koutlines" hui:menu-to-personal-section) ;; ("L") ("buffer-Menu-Filter") - ("Notes" hyrolo-org) - ("Org-Search" helm-org-rifle-org-directory) + ;; ("Notes" hynote-find) + ("Org-Find" hyrolo-org) ("Projects" hui:menu-to-personal-section) ("Rolo" hyrolo-fgrep) ;; ("<Quit-Menu>") @@ -1146,7 +1147,7 @@ support underlined faces as well." (defcustom hui:doc-a-z '(("a-Z>") - ("Apropos-Symbol" hypb:helm-apropos) + ("Apropos-Symbol" hsys-consult-apropos) ;; ("B") ;; ("C") ("Devdocs-Lookup" hypb:devdocs-lookup) @@ -1154,7 +1155,7 @@ support underlined faces as well." ;; ("F") ;; ("G") ;; ("H") - ("Info-Search" hypb:helm-info) + ("Info-Search" consult-info) ;; ("J") ;; ("K") ;; ("L") diff --git a/hyrolo.el b/hyrolo.el index 662dedb0cf..99c54d9827 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: 8-Jun-25 at 01:26:42 by Bob Weiner +;; Last-Mod: 15-Jun-25 at 18:17:10 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -196,7 +196,9 @@ executable must be found as well (for Oauth security)." :type 'boolean :group 'hyperbole-hyrolo) -(defcustom hyrolo-file-list nil +(defcustom hyrolo-file-list (list (if (file-readable-p "~/.rolo.org") + "~/.rolo.org" + "~/.rolo.otl")) "List of files containing hyrolo entries. The first file should be a user-specific hyrolo file, typically in the home directory and must have a suffix of either .org (Org mode) or .otl (Emacs @@ -574,7 +576,8 @@ omit any trailing colon and space in the prompt." " --include *.org --include *.otl --include *.outl")) (ripgrep-globs "--glob *.{kot,kotl,md,markdown,mkd,mdown,mkdn,mdwn,org,otl,outl}")) (hsys-consult-grep grep-includes ripgrep-globs - regexp max-matches (or path-list hyrolo-file-list) + regexp max-matches + (or path-list hyrolo-file-list) (or prompt (if (eq max-matches 0) "Grep HyRolo headlines" "Grep HyRolo files"))))) @@ -755,7 +758,8 @@ on the logical sexpression matching." (hyrolo-grep-input #'read-string "Find rolo string"))) (list (car input-and-matching-files) current-prefix-arg - (cadr input-and-matching-files)))) + (mapcar #'expand-file-name + (cadr input-and-matching-files))))) (setq string (string-trim string "\"" "\"")) (let ((total-matches 0)) (if (string-match-p "\(\\(r-\\)?\\(and\\|or\\|xor\\|not\\)\\>" string) @@ -795,18 +799,21 @@ select it." (mapcar #'list all-files))))) (when (stringp file) (let (buf) - (prog1 (setq buf (apply (or find-function hyrolo-find-file-function) file args)) - (when buf - (with-current-buffer buf - (when (equal outline-regexp (default-value 'outline-regexp)) - ;; Prevent matching to *word* at the beginning of - ;; lines and hanging hyrolo search functions. Note this - ;; change adds one to the default `outline-level' function, - ;; so `hyrolo-outline-level' overrides that as well - ;; to get the correct calculation. -- rsw, 2023-11-17 - (setq-local outline-regexp "\\([*\^L]+\\)\\([ \t\n\r]\\)" - outline-level #'hyrolo-outline-level)) - (setq buffer-read-only nil)))))))) + (condition-case-unless-debug err + (prog1 (setq buf (apply (or find-function hyrolo-find-file-function) file args)) + (when buf + (with-current-buffer buf + (when (equal outline-regexp (default-value 'outline-regexp)) + ;; Prevent matching to *word* at the beginning of + ;; lines and hanging hyrolo search functions. Note this + ;; change adds one to the default `outline-level' function, + ;; so `hyrolo-outline-level' overrides that as well + ;; to get the correct calculation. -- rsw, 2023-11-17 + (setq-local outline-regexp "\\([*\^L]+\\)\\([ \t\n\r]\\)" + outline-level #'hyrolo-outline-level)) + (setq buffer-read-only nil)))) + (error (progn (message "(hyrolo-find-file): Error reading \"%s\": %s" file err) + nil))))))) ;;;###autoload (defun hyrolo-find-file-noselect (&optional file) @@ -866,7 +873,8 @@ variable `hyrolo-file-list'." "Find rolo regular expression"))) (list (car input-and-matching-files) current-prefix-arg - (cadr input-and-matching-files)))) + (mapcar #'expand-file-name + (cadr input-and-matching-files))))) (unless (or (integerp max-matches) (memq max-matches '(nil t))) (setq max-matches (prefix-numeric-value max-matches))) (let ((files-or-bufs @@ -1352,7 +1360,10 @@ Raise an error if a match is not found." (defun hyrolo-refresh-file-list () "Refresh from disk the internal list of files given by `hyrolo-file-list'." - (setq hyrolo--expanded-file-list (hyrolo-expand-path-list hyrolo-file-list)) + (if hyrolo-file-list + (setq hyrolo--expanded-file-list (hyrolo-expand-path-list hyrolo-file-list)) + (setq hyrolo-file-list (hyrolo-expand-path-list nil) + hyrolo--expanded-file-list hyrolo-file-list)) (when (hyrolo-any-file-type-problem-p) (error "(HyRolo): Invalid files used in `hyrolo-file-list'; see the *HyRolo Errors* buffer"))) @@ -1373,9 +1384,10 @@ Raise an error if a match is not found." ;;;###autoload (defun hyrolo-set-file-list (symbol value) - (set-default symbol value) (setq hyrolo--expanded-file-list (hyrolo-expand-path-list value)) - (unless (symbol-value symbol) + (if value + (set-default symbol value) + (setq value hyrolo--expanded-file-list) (set-default symbol hyrolo--expanded-file-list)) (when (hyrolo-any-file-type-problem-p) (error "(HyRolo): Invalid files used in `hyrolo-file-list'; see the *HyRolo Errors* buffer")) @@ -1480,7 +1492,9 @@ optional VIEW-BUFFER-NAME, use that rather than the default, \"*HyRolo Tags*\"." (interactive "P") (require 'org-agenda) - (let* ((org-agenda-files (hyrolo-get-file-list)) + (let* ((org-agenda-files (seq-filter (lambda (f) + (string-suffix-p ".org" f t)) + (hyrolo-get-file-list))) (org-agenda-buffer-name (or view-buffer-name "*HyRolo Tags*")) ;; `org-tags-view' is mis-written to require setting this next ;; tmp-name or it will not properly name the displayed buffer. @@ -1571,7 +1585,8 @@ Return number of entries matched. See also documentation for the variable (hyrolo-grep-input #'read-string "Find rolo whole word matches of"))) (list (car input-and-matching-files) current-prefix-arg - (cadr input-and-matching-files)))) + (mapcar #'expand-file-name + (cadr input-and-matching-files))))) (let ((total-matches (hyrolo-grep (format "\\b%s\\b" (regexp-quote string)) max-matches hyrolo-files-or-bufs count-only headline-only no-display))) @@ -1937,7 +1952,8 @@ Interactively, MAX-MATCHES is the prefix argument." (list (expand-file-name "*.org" org-directory))))) (list (car input-and-matching-files) current-prefix-arg - (cadr input-and-matching-files)))) + (mapcar (lambda (f) (expand-file-name f org-directory)) + (cadr input-and-matching-files))))) (require 'org) (unless (file-readable-p org-directory) (make-directory org-directory)) @@ -1959,7 +1975,8 @@ returned to the number given." (list (expand-file-name "*.org" org-roam-directory))))) (list (car input-and-matching-files) current-prefix-arg - (cadr input-and-matching-files)))) + (mapcar (lambda (f) (expand-file-name f org-roam-directory)) + (cadr input-and-matching-files))))) (hsys-consult--org-roam-call-function (lambda () (let ((hyrolo-file-list @@ -2777,28 +2794,33 @@ begins or nil if not found." (when (search-forward name nil t) (move-to-column col-num) (setq found (point))) - (while (string-match "\\`[^\]\[<>{}\"]*/" name) - (setq end (1- (match-end 0)) - level nil - parent (substring name 0 end) - name (substring name (min (1+ end) (length name)))) - (cond ((progn - (while (and (not level) (search-forward parent nil t)) - (save-excursion - (forward-line 0) - (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. - (t ;; Found parent but not child - (setq buffer-read-only nil) - (hyrolo-to-buffer (current-buffer)) - (error "(hyrolo-to): `%s' part of name not found in \"%s\"" - parent file-or-buf))) - (when level - (narrow-to-region (point) - (save-excursion - (hyrolo-to-entry-end t) (point))))) + ;; If this is the first line of an entry, then don't treat + ;; '/' characters as parent/child delimiters but just as + ;; part of the entry first line text. + (unless (setq line-and-col (get-text-property 0 'hyrolo-name-entry name)) + ;; Otherwise, navigate through parent-child records. + (while (string-match "\\`[^\]\[<>{}\"]*/" name) + (setq end (1- (match-end 0)) + level nil + parent (substring name 0 end) + name (substring name (min (1+ end) (length name)))) + (cond ((progn + (while (and (not level) (search-forward parent nil t)) + (save-excursion + (forward-line 0) + (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. + (t ;; Found parent but not child + (setq buffer-read-only nil) + (hyrolo-to-buffer (current-buffer)) + (error "(hyrolo-to): `%s' part of name not found in \"%s\"" + parent file-or-buf))) + (when level + (narrow-to-region (point) + (save-excursion + (hyrolo-to-entry-end t) (point)))))) (goto-char (point-min)) (while (and ;; Search for just the leaf part of a name @@ -2812,7 +2834,8 @@ begins or nil if not found." ;; Jump to non-first line within an entry (progn (back-to-indentation) (looking-at (regexp-quote name)))) - (when (setq line-and-col (get-text-property 0 'hyrolo-name-entry name)) + (when (or line-and-col + (setq line-and-col (get-text-property 0 'hyrolo-name-entry name))) ;; this is a whole line to find except for leading whitespace (setq line (car line-and-col) col-num (cdr line-and-col)) @@ -3632,6 +3655,7 @@ Push (point-max) of `hyrolo-display-buffer' onto (define-key hyrolo-mode-map "p" 'hyrolo-outline-previous-visible-heading) (define-key hyrolo-mode-map "q" 'hyrolo-quit) (define-key hyrolo-mode-map "r" 'hyrolo-grep-or-fgrep) + (define-key hyrolo-mode-map [return] 'action-key) (define-key hyrolo-mode-map "s" 'hyrolo-outline-show-subtree) (define-key hyrolo-mode-map "\M-s" 'hyrolo-isearch) (define-key hyrolo-mode-map "t" 'hyrolo-top-level) @@ -3823,7 +3847,7 @@ that text." (defun hyrolo-show-post-command () "Post command hook function to expand subtree if point is in invisible text. -Used in *HyRolo* match buffer." +Used in the *HyRolo* display match buffer." (when (outline-invisible-p) (hyrolo-outline-show-subtree)))