Skip to content

Commit ff2dba3

Browse files
authored
Merge pull request #913 from rswgnu/rsw
Fix hib-link-to-file-line, hpath:find and hywiki-get-referent-hasht
2 parents 5479da6 + 6930cc4 commit ff2dba3

5 files changed

Lines changed: 38 additions & 20 deletions

File tree

ChangeLog

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
2026-03-22 Bob Weiner <rsw@gnu.org>
2+
3+
* hibtypes.el (hib-link-to-file-line): Fix that a filename both in the current
4+
dir and in the 'load-path' variable is expanded into a 'load-path' dir
5+
first rather than the current directory, which should be preferred.
6+
7+
* hpath.el (hpath:find): Fix (let ((buf))) when (string-empty-p path) to
8+
return the current buffer when 'hpath:display-buffer' is called. Fixes
9+
bug where that function returned a window instead.
10+
11+
* hywiki.el (hywiki-get-referent-hasht): Remove rebuild of referent-hasht
12+
when empty. This was causing a problem in the
13+
'hywiki-tests--save-referent-org-id'.
14+
115
2026-03-21 Bob Weiner <rsw@gnu.org>
216

317
* hypb.el (hypb:grep-has-pcre-p, hypb:ripgrep-has-pcre-p): Add.

hibtypes.el

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
;; Author: Bob Weiner
44
;;
55
;; Orig-Date: 19-Sep-91 at 20:45:31
6-
;; Last-Mod: 17-Mar-26 at 19:48:06 by Bob Weiner
6+
;; Last-Mod: 22-Mar-26 at 14:08:04 by Bob Weiner
77
;;
88
;; SPDX-License-Identifier: GPL-3.0-or-later
99
;;
@@ -1013,14 +1013,20 @@ See `hpath:find' function documentation for special file display options."
10131013
"Expand FILE and jump to its LINE-NUM in Hyperbole specified window.
10141014
The variable `hpath:display-where' determines where to display the file.
10151015
LINE-NUM may be an integer or string."
1016-
;; RSW 12-05-2021 - Added hpath:expand in next line to
1017-
;; resolve any variables in the path before checking if absolute.
1018-
(let ((source-loc (unless (file-name-absolute-p (hpath:expand file))
1019-
(hbut:to-key-src t)))
1020-
ext)
1021-
(if (stringp source-loc)
1022-
(setq file (expand-file-name file (file-name-directory source-loc)))
1023-
(setq file (or (hpath:prepend-shell-directory file)
1016+
;; RSW 12-05-2021 - Add hpath:expand in next line to resolve any variables
1017+
;; in the path before checking if absolute.
1018+
;; RSW 03-22-2026 - Save expanded-file and use if absolute in order to
1019+
;; prefer files found in current directory over those in a `load-path' dir.
1020+
(let ((expanded-file (hpath:expand file))
1021+
source-loc)
1022+
(unless (and (stringp expanded-file) (file-name-absolute-p expanded-file))
1023+
(setq expanded-file nil))
1024+
(setq source-loc (unless expanded-file (hbut:to-key-src t)))
1025+
(cond (expanded-file
1026+
(setq file expanded-file))
1027+
((stringp source-loc)
1028+
(setq file (expand-file-name file (file-name-directory source-loc))))
1029+
(t (setq file (or (hpath:prepend-shell-directory file)
10241030
;; find-library-name will strip file
10251031
;; suffixes, so use it only when the file
10261032
;; either doesn't have a suffix or has a
@@ -1029,7 +1035,7 @@ LINE-NUM may be an integer or string."
10291035
(member (concat "." ext) (get-load-suffixes)))
10301036
(ignore-errors (find-library-name file)))
10311037
(hpath:is-p (expand-file-name file))
1032-
(hywiki-get-existing-page-file file))))
1038+
(hywiki-get-existing-page-file file)))))
10331039
(when (file-exists-p (hpath:normalize file))
10341040
(actypes::link-to-file-line file line-num))))
10351041

hpath.el

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
;; Author: Bob Weiner
44
;;
55
;; Orig-Date: 1-Nov-91 at 00:44:23
6-
;; Last-Mod: 17-Mar-26 at 22:51:48 by Bob Weiner
6+
;; Last-Mod: 22-Mar-26 at 13:41:04 by Bob Weiner
77
;;
88
;; SPDX-License-Identifier: GPL-3.0-or-later
99
;;
@@ -1625,9 +1625,9 @@ but locational suffixes within the file are utilized."
16251625
;; If no path, e.g. just an anchor link in a non-file buffer,
16261626
;; then must display within Emacs, ignoring any external programs.
16271627
((string-empty-p path)
1628-
(if noselect
1629-
(current-buffer)
1630-
(hpath:display-buffer (current-buffer) display-where)))
1628+
(unless noselect
1629+
(hpath:display-buffer (current-buffer) display-where))
1630+
(current-buffer))
16311631
(noselect
16321632
(find-file-noselect path))
16331633
(t (funcall (hpath:display-path-function display-where) path)))))

hywiki.el

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
;; Author: Bob Weiner
44
;;
55
;; Orig-Date: 21-Apr-24 at 22:41:13
6-
;; Last-Mod: 22-Mar-26 at 01:34:22 by Bob Weiner
6+
;; Last-Mod: 22-Mar-26 at 12:53:00 by Bob Weiner
77
;;
88
;; SPDX-License-Identifier: GPL-3.0-or-later
99
;;
@@ -1461,8 +1461,8 @@ Use `hywiki-get-referent' to determine whether a HyWiki page exists."
14611461
current-prefix-arg))
14621462
(if (hywiki-word-is-p page-name)
14631463
(when (or noninteractive
1464-
(not (hash-empty-p (hywiki-get-referent-hasht)))
14651464
(hyperb:stack-frame '(ert-run-test))
1465+
(not (hash-empty-p (hywiki-get-referent-hasht)))
14661466
(y-or-n-p (concat "Create new HyWiki page `" page-name "'? ")))
14671467
;; Remove any #section suffix in PAGE-NAME.
14681468
(setq page-name (hywiki-get-singular-wikiword page-name))
@@ -3076,8 +3076,7 @@ regexps of wikiwords, if the hash table is out-of-date."
30763076
(if (and (equal hywiki--pages-directory hywiki-directory)
30773077
;; If page files changed, have to rebuild referent hash table
30783078
(not (hywiki-directory-modified-p))
3079-
(hash-table-p hywiki--referent-hasht)
3080-
(not (hash-empty-p hywiki--referent-hasht)))
3079+
(hash-table-p hywiki--referent-hasht))
30813080
hywiki--referent-hasht
30823081
;; Rebuild referent hash table
30833082
(hywiki-make-referent-hasht))

test/hywiki-tests.el

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,8 +1474,7 @@ Note special meaning of `hywiki-allow-plurals-flag'."
14741474
(hywiki-tests--insert "* header\n")
14751475
(mocklet (((org-id-get) => "generated-org-id"))
14761476
(goto-char (point-max))
1477-
(hywiki-add-referent wiki-word-non-page
1478-
(hywiki-add-org-id wiki-word-non-page))))
1477+
(hywiki-add-org-id wiki-word-non-page)))
14791478
(hy-delete-file-and-buffer filea))))))
14801479

14811480
;; !! FIXME: Add Org-id links tests.

0 commit comments

Comments
 (0)