From 212ca9ea11078f753d0949f28dd21f382910635a Mon Sep 17 00:00:00 2001 From: bw Date: Sun, 22 Mar 2026 14:10:34 -0400 Subject: [PATCH] Fix hib-link-to-file-line, hpath:find and hywiki-get-referent-hasht hib-link-to-file-line - Fix that a filename both in the current dir and in the 'load-path' variable is expanded into a 'load-path' dir first rather than the current directory, which should be preferred. hpath:find - Fix (let ((buf))) when (string-empty-p path) to return the current buffer when 'hpath:display-buffer' is called. Fixes bug where that function returned a window instead. hywiki-get-referent-hasht - Remove rebuild of referent-hasht when empty. This was causing a problem in the 'hywiki-tests--save-referent-org-id'. --- ChangeLog | 14 ++++++++++++++ hibtypes.el | 26 ++++++++++++++++---------- hpath.el | 8 ++++---- hywiki.el | 7 +++---- test/hywiki-tests.el | 3 +-- 5 files changed, 38 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index a3439655..ded0f081 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2026-03-22 Bob Weiner + +* hibtypes.el (hib-link-to-file-line): Fix that a filename both in the current + dir and in the 'load-path' variable is expanded into a 'load-path' dir + first rather than the current directory, which should be preferred. + +* hpath.el (hpath:find): Fix (let ((buf))) when (string-empty-p path) to + return the current buffer when 'hpath:display-buffer' is called. Fixes + bug where that function returned a window instead. + +* hywiki.el (hywiki-get-referent-hasht): Remove rebuild of referent-hasht + when empty. This was causing a problem in the + 'hywiki-tests--save-referent-org-id'. + 2026-03-21 Bob Weiner * hypb.el (hypb:grep-has-pcre-p, hypb:ripgrep-has-pcre-p): Add. diff --git a/hibtypes.el b/hibtypes.el index 45351272..566434cd 100644 --- a/hibtypes.el +++ b/hibtypes.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 19-Sep-91 at 20:45:31 -;; Last-Mod: 17-Mar-26 at 19:48:06 by Bob Weiner +;; Last-Mod: 22-Mar-26 at 14:08:04 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -1013,14 +1013,20 @@ See `hpath:find' function documentation for special file display options." "Expand FILE and jump to its LINE-NUM in Hyperbole specified window. The variable `hpath:display-where' determines where to display the file. LINE-NUM may be an integer or string." - ;; RSW 12-05-2021 - Added hpath:expand in next line to - ;; resolve any variables in the path before checking if absolute. - (let ((source-loc (unless (file-name-absolute-p (hpath:expand file)) - (hbut:to-key-src t))) - ext) - (if (stringp source-loc) - (setq file (expand-file-name file (file-name-directory source-loc))) - (setq file (or (hpath:prepend-shell-directory file) + ;; RSW 12-05-2021 - Add hpath:expand in next line to resolve any variables + ;; in the path before checking if absolute. + ;; RSW 03-22-2026 - Save expanded-file and use if absolute in order to + ;; prefer files found in current directory over those in a `load-path' dir. + (let ((expanded-file (hpath:expand file)) + source-loc) + (unless (and (stringp expanded-file) (file-name-absolute-p expanded-file)) + (setq expanded-file nil)) + (setq source-loc (unless expanded-file (hbut:to-key-src t))) + (cond (expanded-file + (setq file expanded-file)) + ((stringp source-loc) + (setq file (expand-file-name file (file-name-directory source-loc)))) + (t (setq file (or (hpath:prepend-shell-directory file) ;; find-library-name will strip file ;; suffixes, so use it only when the file ;; either doesn't have a suffix or has a @@ -1029,7 +1035,7 @@ LINE-NUM may be an integer or string." (member (concat "." ext) (get-load-suffixes))) (ignore-errors (find-library-name file))) (hpath:is-p (expand-file-name file)) - (hywiki-get-existing-page-file file)))) + (hywiki-get-existing-page-file file))))) (when (file-exists-p (hpath:normalize file)) (actypes::link-to-file-line file line-num)))) diff --git a/hpath.el b/hpath.el index 3b859fee..ab0ec7de 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: 17-Mar-26 at 22:51:48 by Bob Weiner +;; Last-Mod: 22-Mar-26 at 13:41:04 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -1625,9 +1625,9 @@ but locational suffixes within the file are utilized." ;; If no path, e.g. just an anchor link in a non-file buffer, ;; then must display within Emacs, ignoring any external programs. ((string-empty-p path) - (if noselect - (current-buffer) - (hpath:display-buffer (current-buffer) display-where))) + (unless noselect + (hpath:display-buffer (current-buffer) display-where)) + (current-buffer)) (noselect (find-file-noselect path)) (t (funcall (hpath:display-path-function display-where) path))))) diff --git a/hywiki.el b/hywiki.el index 2e55ae11..856f4d87 100644 --- a/hywiki.el +++ b/hywiki.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 21-Apr-24 at 22:41:13 -;; Last-Mod: 22-Mar-26 at 01:34:22 by Bob Weiner +;; Last-Mod: 22-Mar-26 at 12:53:00 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -1461,8 +1461,8 @@ Use `hywiki-get-referent' to determine whether a HyWiki page exists." current-prefix-arg)) (if (hywiki-word-is-p page-name) (when (or noninteractive - (not (hash-empty-p (hywiki-get-referent-hasht))) (hyperb:stack-frame '(ert-run-test)) + (not (hash-empty-p (hywiki-get-referent-hasht))) (y-or-n-p (concat "Create new HyWiki page `" page-name "'? "))) ;; Remove any #section suffix in PAGE-NAME. (setq page-name (hywiki-get-singular-wikiword page-name)) @@ -3076,8 +3076,7 @@ regexps of wikiwords, if the hash table is out-of-date." (if (and (equal hywiki--pages-directory hywiki-directory) ;; If page files changed, have to rebuild referent hash table (not (hywiki-directory-modified-p)) - (hash-table-p hywiki--referent-hasht) - (not (hash-empty-p hywiki--referent-hasht))) + (hash-table-p hywiki--referent-hasht)) hywiki--referent-hasht ;; Rebuild referent hash table (hywiki-make-referent-hasht)) diff --git a/test/hywiki-tests.el b/test/hywiki-tests.el index f3bd8600..eb924b7d 100644 --- a/test/hywiki-tests.el +++ b/test/hywiki-tests.el @@ -1474,8 +1474,7 @@ Note special meaning of `hywiki-allow-plurals-flag'." (hywiki-tests--insert "* header\n") (mocklet (((org-id-get) => "generated-org-id")) (goto-char (point-max)) - (hywiki-add-referent wiki-word-non-page - (hywiki-add-org-id wiki-word-non-page)))) + (hywiki-add-org-id wiki-word-non-page))) (hy-delete-file-and-buffer filea)))))) ;; !! FIXME: Add Org-id links tests.