Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,11 +1,35 @@
2026-05-20 Bob Weiner <rsw@gnu.org>

* 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 <matsl@gnu.org>

* test/hy-test-dependencies.el (fboundp): When markdown-ts-mode is defined
prefer markdown-mode. This avoids markdown-ts-mode prompting for
treesitter grammar.

2026-05-17 Bob Weiner <rsw@gnu.org>

* 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 <rsw@gnu.org>

* 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,
Expand Down
34 changes: 18 additions & 16 deletions hpath.el
Original file line number Diff line number Diff line change
Expand Up @@ -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 17:41:19 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
Expand Down Expand Up @@ -1248,17 +1248,15 @@ 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'.

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
Expand Down Expand Up @@ -1293,11 +1291,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)
Expand Down Expand Up @@ -1396,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))
Expand Down
38 changes: 19 additions & 19 deletions hyrolo.el
Original file line number Diff line number Diff line change
Expand Up @@ -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: 20-May-26 at 15:59:37 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
Expand Down Expand Up @@ -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)
Expand All @@ -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.")

Expand All @@ -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
Expand Down Expand Up @@ -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)
(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)
Expand Down
9 changes: 7 additions & 2 deletions hyrolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand All @@ -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
Expand Down
21 changes: 12 additions & 9 deletions man/hyperbole.texi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
14 changes: 7 additions & 7 deletions test/hpath-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
;; Author: Mats Lidell <matsl@gnu.org>
;;
;; 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
;;
Expand Down Expand Up @@ -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*"))
Expand All @@ -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")))
Expand Down
10 changes: 4 additions & 6 deletions test/hyrolo-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
;; Author: Mats Lidell <matsl@gnu.org>
;;
;; 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
;;
Expand Down Expand Up @@ -1843,19 +1843,17 @@ 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")
"\\.\\(kotl?\\|org\\|ou?tl\\|md\\|markdown\\|mkd\\|mdown\\|mkdn\\|mdwn\\)$"
#'file-readable-p)
"\\.\\(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\\)$"
#'file-readable-p)
"\\.\\(kotl?\\|org\\|ou?tl\\|md\\|markdown\\|mkd\\|mdown\\|mkdn\\|mdwn\\)$")
=> (list "/file1")))
(should (equal (hyrolo-expand-path-list '("/file1")) '("/file1"))))))

Expand Down