From 0e2d7348f29ce2c4d6d4177472103560b68bfbed Mon Sep 17 00:00:00 2001 From: bw Date: Sun, 17 May 2026 11:24:17 -0400 Subject: [PATCH 1/5] hyrolo-default-file - Add customization to set default search file hyrolo-expand-path-list - Don't filter out non-existent files hyrolo-file-suffix-regexp): Change from a defcustom to a defconst --- ChangeLog | 10 ++++++++++ hyrolo.el | 38 +++++++++++++++++++------------------- man/hyperbole.texi | 21 ++++++++++++--------- 3 files changed, 41 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index 85c48f2a..7db8e85b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2026-05-16 Bob Weiner +* hyrolo.el (hyrolo-default-file): Add customization for default HyRolo full + path to search if none are provided. Use "~/.rolo.org" if none exist. + (hyrolo-expand-path-list): Change filter from 'file-readable-p' + to 'identity' since want to keep non-existent files so 'hyrolo-add' can + create them when an initial entry is added. An internal filter will + continue to remove any non-string entries. + (hyrolo-file-suffix-regexp): Change from a defcustom to a defconst + since editing this is not sufficient to change supported file types since + the types are manually set in one of the grep functions as well. + * man/hyperbole.texi (Default Hyperbole Bindings): Update doc for {M-w} to copy things, not just delimited things. (Koutliner Keys): Update doc for {C-w} to kill/copy things, diff --git a/hyrolo.el b/hyrolo.el index 2bc46fd2..775667a3 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: 10-May-26 at 11:09:23 by Bob Weiner +;; Last-Mod: 16-May-26 at 22:50:04 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -151,11 +151,9 @@ See usage in `hyrolo-any-file-type-problem-p'.") (defconst hyrolo-markdown-suffix-regexp "md\\|markdown\\|mkd\\|mdown\\|mkdn\\|mdwn" "Regexp matching Markdown file suffixes.") -(defcustom hyrolo-file-suffix-regexp (concat "\\.\\(kotl?\\|org\\|ou?tl\\|" +(defconst hyrolo-file-suffix-regexp (concat "\\.\\(kotl?\\|org\\|ou?tl\\|" hyrolo-markdown-suffix-regexp "\\)$") - "File suffix regexp used to select files to search with HyRolo." - :type 'string - :group 'hyperbole-hyrolo) + "File suffix regexp used to select files to search with HyRolo.") (defvar hyrolo-auto-mode-alist (list (cons (format "\\.\\(%s\\)$" hyrolo-markdown-suffix-regexp) @@ -167,6 +165,13 @@ Typically, these specialized modes speed loading of files used solely for HyRolo text matches by avoiding the time-consuming initializations their standard major modes perform.") +(defcustom hyrolo-default-file (if (file-readable-p "~/.rolo.otl") + "~/.rolo.otl" + "~/.rolo.org") + "Full path of default HyRolo file if none are added to `hyrolo-file-list'." + :type 'file + :group 'hyperbole-hyrolo) + (defvar hyrolo-display-buffer "*HyRolo*" "Buffer used to display set of last matching rolo entries.") @@ -188,9 +193,7 @@ executable must be found as well (for Oauth security)." :type 'boolean :group 'hyperbole-hyrolo) -(defcustom hyrolo-file-list (list (if (file-readable-p "~/.rolo.org") - "~/.rolo.org" - "~/.rolo.otl")) +(defcustom hyrolo-file-list (list hyrolo-default-file) "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 @@ -710,17 +713,14 @@ they contain that match `hyrolo-file-suffix-regexp'. Then, if `find-file-wildcards' is non-nil (the default), any files containing [char-matches] or * wildcards are expanded to their matches." - (let ((default-file (if (file-readable-p "~/.rolo.org") - "~/.rolo.org" - "~/.rolo.otl"))) - (unless paths - (setq paths - (delq nil - (list default-file - (if (and (boundp 'bbdb-file) (stringp bbdb-file)) bbdb-file) - (when (hyrolo-google-contacts-p) google-contacts-buffer-name))))) - (or (hpath:expand-list paths hyrolo-file-suffix-regexp #'file-readable-p) - (list (expand-file-name default-file))))) + (unless paths + (setq paths + (delq nil + (list hyrolo-default-file + (if (and (boundp 'bbdb-file) (stringp bbdb-file)) bbdb-file) + (when (hyrolo-google-contacts-p) google-contacts-buffer-name))))) + (or (hpath:expand-list paths hyrolo-file-suffix-regexp #'identity) + (list (expand-file-name hyrolo-default-file)))) ;;;###autoload (defun hyrolo-fgrep (string &optional max-matches hyrolo-files-or-bufs count-only headline-only no-display) diff --git a/man/hyperbole.texi b/man/hyperbole.texi index 425348c1..9bfa829b 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: 16-May-26 at 17:20:08 by Bob Weiner +@c Last-Mod: 16-May-26 at 22:48:38 by Bob Weiner @c %**start of header (This is for running Texinfo on a region.) @setfilename hyperbole.info @@ -7054,14 +7054,17 @@ current frame to its state prior to the rolo search. @node HyRolo Settings, , HyRolo Keys, HyRolo @section HyRolo Settings +@vindex hyrolo-default-file @vindex hyrolo-file-list @cindex rolo, personal The files used in any rolo search are given by the -@code{hyrolo-file-list} variable, whose default value is typically -@code{"~/.rolo.otl"}, in which case, searches scan only your personal -rolo file. But you can customize this to include files with variables -in them, wildcard patterns and directories, as explained below. Any -paths added to this list should be absolute. +@code{hyrolo-file-list} variable, whose default first value is given +by the variable, @code{hyrolo-default-file} originally set to +@code{"~/.rolo.org"}, unless the older @code{~/.rolo.otl} exists when +Hyperbole is loaded. You can customize @code{hyrolo-file-list} to +include files with variables in them, wildcard patterns and +directories, as explained below. Any paths added to this list should +be absolute. If you include file wildcards in paths for this variable and @code{find-file-wildcards} is non-nil (the default), then any files @@ -7078,9 +7081,9 @@ that matches. If you include an existing directory (invalid ones are ignored) in your @code{hyrolo-file-list}, HyRolo will expand it recursively across -all of its files that match @code{hyrolo-file-suffix-regexp}. By -default, this is Org files (.org), Emacs outlines (.otl), Koutlines -(.kotl), or Markdown files (.md). See @file{hpath.el#hpath:expand-list}. +all of its files that match @code{hyrolo-file-suffix-regexp}. This +matches to Org files (.org), Emacs outlines (.otl), Koutlines (.kotl), +and Markdown files (.md). See @file{hpath.el#hpath:expand-list}. Once expanded, if a file in the list does not exist or is not readable, it is dropped. Paths are searched in the order in which From 03cbbab8d524ae77b6e06e1a76587467662ca535 Mon Sep 17 00:00:00 2001 From: bw Date: Sun, 17 May 2026 11:27:08 -0400 Subject: [PATCH 2/5] hyrolo.py - Expand commentary on priority order of file search --- ChangeLog | 4 ++++ hyrolo.py | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7db8e85b..5e2c0661 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2026-05-17 Bob Weiner + +* hyrolo.py: Expand commentary on priority order of file search. + 2026-05-16 Bob Weiner * hyrolo.el (hyrolo-default-file): Add customization for default HyRolo full diff --git a/hyrolo.py b/hyrolo.py index dfd06187..541895db 100755 --- a/hyrolo.py +++ b/hyrolo.py @@ -8,7 +8,7 @@ # Author: Bob Weiner # # Orig-Date: 1-Apr-24 at 01:45:27 -# Last-Mod: 30-Nov-25 at 12:44:05 by Bob Weiner +# Last-Mod: 17-May-26 at 00:10:02 by Bob Weiner # # SPDX-License-Identifier: GPL-3.0-or-later # @@ -27,7 +27,12 @@ # subtree of matching entries. # # This outputs a file header only if there is a matching entry in that file. - +# +# Files searched are used in this order of priority (only one option is used per run): +# 1. Files listed on the command-line +# 2. A single file set in the environment variable, HYROLO. +# 3. The file "~/.rolo.org" if it exists. +# 4. The file "~/.rolo.otl" if it exists. # Code: import argparse From ac3cab188e68850ca96032e612c2c9b193a0f2c8 Mon Sep 17 00:00:00 2001 From: bw Date: Sun, 17 May 2026 12:17:04 -0400 Subject: [PATCH 3/5] hyrolo-tests--expand-path-list) - Fix to use identity filter --- ChangeLog | 3 +++ test/hyrolo-tests.el | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5e2c0661..da3be263 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2026-05-17 Bob Weiner +* test/hyrolo-tests.el (hyrolo-tests--expand-path-list): Fix to use + identity filter instead of file-read-p. + * hyrolo.py: Expand commentary on priority order of file search. 2026-05-16 Bob Weiner diff --git a/test/hyrolo-tests.el b/test/hyrolo-tests.el index 4234552e..70858ed5 100644 --- a/test/hyrolo-tests.el +++ b/test/hyrolo-tests.el @@ -3,7 +3,7 @@ ;; Author: Mats Lidell ;; ;; Orig-Date: 19-Jun-21 at 22:42:00 -;; Last-Mod: 12-Apr-26 at 15:11:30 by Bob Weiner +;; Last-Mod: 17-May-26 at 12:15:26 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -1848,14 +1848,14 @@ match (mocklet (((hpath:expand-list '("/file1") "\\.\\(kotl?\\|org\\|ou?tl\\|md\\|markdown\\|mkd\\|mdown\\|mkdn\\|mdwn\\)$" - #'file-readable-p) + #'identity) => (list "/file1"))) (should (equal (hyrolo-expand-path-list '("/file1")) '("/file1"))))) (let ((bbdb-file nil)) (mocklet (((hpath:expand-list '("/file1") "\\.\\(kotl?\\|org\\|ou?tl\\|md\\|markdown\\|mkd\\|mdown\\|mkdn\\|mdwn\\)$" - #'file-readable-p) + #'identity) => (list "/file1"))) (should (equal (hyrolo-expand-path-list '("/file1")) '("/file1")))))) From 3a035531b0f8a12ad4051598a35e5a17029d0a74 Mon Sep 17 00:00:00 2001 From: bw Date: Wed, 20 May 2026 16:15:08 -0400 Subject: [PATCH 4/5] hpath:expand - Change to expand non-existing paths --- ChangeLog | 5 +++++ hpath.el | 25 +++++++++++++------------ hyrolo.el | 4 ++-- test/hpath-tests.el | 14 +++++++------- test/hyrolo-tests.el | 6 ++---- 5 files changed, 29 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index da3be263..ff3dcbca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2026-05-20 Bob Weiner + +* hpath.el (hpath:expand): Change to expand non-existing paths as they may + be created after expansion. Update doc string to reflect the new behavior. + 2026-05-17 Bob Weiner * test/hyrolo-tests.el (hyrolo-tests--expand-path-list): Fix to use diff --git a/hpath.el b/hpath.el index d895a15e..1643416e 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: 12-Apr-26 at 12:59:52 by Bob Weiner +;; Last-Mod: 20-May-26 at 15:53:30 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -1252,13 +1252,12 @@ Any single ${variable} within PATH is resolved. Then PATH is expanded from the first file matching regexp in `hpath:auto-variable-alist'. -Return expanded path if it exists or it contains file wildcards of -'[]', '*', or '?'. - -Return any absolute or invalid PATH unchanged unless optional -EXISTS-FLAG is non-nil in which case, return the expanded path -only if it exists, otherwise, return nil." +With optional EXISTS-FLAG non-nil, return the expanded path if it exists or +if it contains file wildcards of '[]', '*', or '?'; if neither of those +cases, return nil. +Without EXISTS-FLAG, return the expanded path if it is a string else the +original path." (when (stringp path) (unless (string-match-p hpath:variable-regexp path) ;; Replace any $VAR environment variable references @@ -1293,11 +1292,13 @@ only if it exists, otherwise, return nil." (when page-file (setq substituted-path (expand-file-name page-file hywiki-directory)))))) (t (expand-file-name substituted-path)))) - (if (and (stringp expanded-path) - (or (file-exists-p expanded-path) - (string-match "[[*?]" (file-local-name expanded-path)))) - expanded-path - (unless exists-flag + (if exists-flag + (when (and (stringp expanded-path) + (or (file-exists-p expanded-path) + (string-match "[[*?]" (file-local-name expanded-path)))) + expanded-path) + (if (stringp expanded-path) + expanded-path path))))) (defun hpath:expand-list (paths &optional match-regexp filter) diff --git a/hyrolo.el b/hyrolo.el index 775667a3..2483d6c0 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: 16-May-26 at 22:50:04 by Bob Weiner +;; Last-Mod: 20-May-26 at 15:59:37 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -719,7 +719,7 @@ matches." (list hyrolo-default-file (if (and (boundp 'bbdb-file) (stringp bbdb-file)) bbdb-file) (when (hyrolo-google-contacts-p) google-contacts-buffer-name))))) - (or (hpath:expand-list paths hyrolo-file-suffix-regexp #'identity) + (or (hpath:expand-list paths hyrolo-file-suffix-regexp) (list (expand-file-name hyrolo-default-file)))) ;;;###autoload diff --git a/test/hpath-tests.el b/test/hpath-tests.el index 08e0b99f..71b5d88c 100644 --- a/test/hpath-tests.el +++ b/test/hpath-tests.el @@ -3,7 +3,7 @@ ;; Author: Mats Lidell ;; ;; Orig-Date: 28-Feb-21 at 23:26:00 -;; Last-Mod: 12-Apr-26 at 15:11:31 by Bob Weiner +;; Last-Mod: 20-May-26 at 16:01:46 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -423,7 +423,7 @@ (hy-delete-file-and-buffer file)))) (ert-deftest hpath--expand-variations-non-existing-path () - "Verify expand non existing paths." + "Verify expanding non-existing paths." (should (string= (hpath:expand "/not/existing/file") "/not/existing/file")) (should-not (hpath:expand "/not/existing/file" t)) (should (string= (hpath:expand "/not/existing/file*" t) "/not/existing/file*")) @@ -435,18 +435,18 @@ (let ((hyperb-no-trailing-slash (substring hyperb:dir 0 -1))) (should (string= (hpath:expand "${hyperb:dir}") hyperb-no-trailing-slash)) (should (string= (hpath:expand "${hyperb:dir}" t) hyperb-no-trailing-slash)) - (should (string= (hpath:expand "${hyperb:dir}/notexisting") "${hyperb:dir}/notexisting")) + (should (string= (hpath:expand "${hyperb:dir}/notexisting") + (expand-file-name "notexisting" hyperb-no-trailing-slash))) (should-not (hpath:expand "${hyperb:dir}/notexisting" t)))) (ert-deftest hpath--expand-environment-variable () - "Verify that a $VAR environment is expanded." + "Verify that a $VAR environment variable is expanded." (let ((envvar "hpath_test")) (unwind-protect (progn (setenv "HPATH" envvar) - (should (string= (hpath:expand "$HPATH") envvar)) - ; Should next not work? See below where is works - ;(should (string= (hpath:expand "${HPATH}") envvar)) + (should (string= (hpath:expand "$HPATH") (expand-file-name envvar))) + (should (string= (hpath:expand "${HPATH}") (expand-file-name envvar))) (should-not (hpath:expand "$HPATH" t)) (should-not (hpath:expand "${HPATH}" t))) (setenv "HPATH"))) diff --git a/test/hyrolo-tests.el b/test/hyrolo-tests.el index 70858ed5..26122782 100644 --- a/test/hyrolo-tests.el +++ b/test/hyrolo-tests.el @@ -1847,15 +1847,13 @@ match (let ((bbdb-file nil)) (mocklet (((hpath:expand-list '("/file1") - "\\.\\(kotl?\\|org\\|ou?tl\\|md\\|markdown\\|mkd\\|mdown\\|mkdn\\|mdwn\\)$" - #'identity) + "\\.\\(kotl?\\|org\\|ou?tl\\|md\\|markdown\\|mkd\\|mdown\\|mkdn\\|mdwn\\)$") => (list "/file1"))) (should (equal (hyrolo-expand-path-list '("/file1")) '("/file1"))))) (let ((bbdb-file nil)) (mocklet (((hpath:expand-list '("/file1") - "\\.\\(kotl?\\|org\\|ou?tl\\|md\\|markdown\\|mkd\\|mdown\\|mkdn\\|mdwn\\)$" - #'identity) + "\\.\\(kotl?\\|org\\|ou?tl\\|md\\|markdown\\|mkd\\|mdown\\|mkdn\\|mdwn\\)$") => (list "/file1"))) (should (equal (hyrolo-expand-path-list '("/file1")) '("/file1")))))) From 64b488048efd7b7135e6dff21fc2b88a3e1dd1ef Mon Sep 17 00:00:00 2001 From: bw Date: Wed, 20 May 2026 17:44:56 -0400 Subject: [PATCH 5/5] hpath:expand-with-variable Fix to match doc; don't expand abs paths --- ChangeLog | 2 ++ hpath.el | 11 ++++++----- test/hyrolo-tests.el | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1f844a47..3e4d34f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ * hpath.el (hpath:expand): Change to expand non-existing paths as they may be created after expansion. Update doc string to reflect the new behavior. + (hpath:expand-with-variable): Fix to match doc and don't expand + absolute paths like "~/.bashrc". 2026-05-19 Mats Lidell diff --git a/hpath.el b/hpath.el index 1643416e..728ae2c4 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: 20-May-26 at 15:53:30 by Bob Weiner +;; Last-Mod: 20-May-26 at 17:41:19 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -1248,9 +1248,8 @@ Optionally use symbol DISPLAY-WHERE or `hpath:display-where'." (defun hpath:expand (path &optional exists-flag) "Expand relative PATH using match in `hpath:auto-variable-alist'. -Any single ${variable} within PATH is resolved. Then PATH is -expanded from the first file matching regexp in -`hpath:auto-variable-alist'. +Any single ${variable} within PATH is resolved. Then PATH is expanded from +the first file matching regexp in `hpath:auto-variable-alist'. With optional EXISTS-FLAG non-nil, return the expanded path if it exists or if it contains file wildcards of '[]', '*', or '?'; if neither of those @@ -1397,7 +1396,9 @@ If PATH is absolute, return it unchanged." ;; 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)) + ;; Expand only if not absolute. + (unless (file-name-absolute-p path) + (setq path (expand-file-name path))) (unless (or (file-name-absolute-p path) (hpath:url-p path) (string-match-p hpath:variable-regexp path)) diff --git a/test/hyrolo-tests.el b/test/hyrolo-tests.el index 26122782..553d736d 100644 --- a/test/hyrolo-tests.el +++ b/test/hyrolo-tests.el @@ -1843,7 +1843,7 @@ match (ert-deftest hyrolo-tests--expand-path-list () "Verify `hyrolo-expand-path-list'." (should (equal (hyrolo-expand-path-list nil) - (list (expand-file-name "~/.rolo.otl")))) + (list hyrolo-default-file))) (let ((bbdb-file nil)) (mocklet (((hpath:expand-list '("/file1")