branch: externals/hyperbole
commit a327ae5d299dec09d1f59bdb8a5d2ad929183357
Author: bw <[email protected]>
Commit: bw <[email protected]>
hywiki-cace-save, hywiki-make-referent-hasht - Fix test failures
- hywiki-directory-changed - Fix so don't recursively call
`hywiki-make-referent-hasht' when loading from .eld cache file.
- hywiki-make-referent-hasht - Fix that the cons action of the
`unless' clause was stuck in the predicate part and so was not
called, due to a missing paren in the unless predicate.
This fixes test: `hywiki-tests--referent-cache-test'.
- hywiki-cache-save - Fix that print calls were not advancing point
in standard-output; required using a marker with `insertion-type' t
for advance. This fixes test: `hywiki-tests--referent-cache-test'.
- Makefile ($(pkg_parent)/hyperbole-$(HYPB_VERSION).tar.gz,
$(pkg_parent)/hyperbole-local.tar.gz): Start target by
removing any prior dir used to create the tar file and leave this dir
for inspection after creating the package tar file at rsw request.
- hywiki-directory-modified-p - Change to test checksum and dir mod-time
separately to account for both page and non-page WikiWords.
- hywiki-directory-get-mod-time - Change to base mod-time only on changes
to HyWiki page files in the directory, eliminating race condition where
mod-time stored in .eld cache file was always earlier than latest dir
mod-time since that included the dir mod-time change from saving the
cache file after the mod-time was stored in that file.
---
ChangeLog | 25 +++++++++++
HY-NEWS | 2 +-
Makefile | 6 +--
hywiki.el | 123 +++++++++++++++++++++++++++++++--------------------
test/hywiki-tests.el | 6 +--
5 files changed, 107 insertions(+), 55 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 30155372058..c42a6d4ae50 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,34 @@
2026-10-19 Bob Weiner <[email protected]>
+* hywiki.el (hywiki-directory-changed): Fix so don't recursively
+ call 'hywiki-make-referent-hasht' when loading from .eld
+ cache file.
+ (hywiki-make-referent-hasht): Fix that the cons action
+ of the unless clause was stuck in the predicate part and so was
+ not called, due to a missing paren in the unless predicate.
+ This fixes test: 'hywiki-tests--referent-cache-test'.
+ (hywiki-cache-save): Fix that print calls were not
+ advancing point in standard-output; required using a marker
+ with insertion-type t for advance. This fixes test:
+ 'hywiki-tests--referent-cache-test'.
+
+* Makefile ($(pkg_parent)/hyperbole-$(HYPB_VERSION).tar.gz,
+ $(pkg_parent)/hyperbole-local.tar.gz): Start target by
+ removing any prior dir used to create the tar file and leave
+ this dir for inspection after creating the package tar file at
+ rsw request.
+
* hywiki.el (hywiki-cache-save): Add back mistakenly removed '(setq'
in the .eld cache file so variables are saved properly.
(hywiki-make-referent-hasht): Fix to load non-page entries
when there are no page entries.
+ (hywiki-directory-modified-p): Change to test checksum and
+ dir mod-time separately to account for both page and non-page WikiWords.
+ (hywiki-directory-get-mod-time): Change to base mod-time only
+ on changes to HyWiki page files in the directory, eliminating race
+ condition where mod-time stored in .eld cache file was always earlier
+ than latest dir mod-time since that included the dir mod-time change
+ from saving the cache file after the mod-time was stored in that file.
* test/demo-tests.el
(fast-demo-outline-section-anchor-and-relative-line-number,
fast-demo-elisp-or-env-vars): Enable all local
diff --git a/HY-NEWS b/HY-NEWS
index ff5a257aafb..b12fdc22e8c 100644
--- a/HY-NEWS
+++ b/HY-NEWS
@@ -1,4 +1,4 @@
-;;; -*- mode: org; org-open-link-functions: (hbut:activate-at-p);
org-cycle-global-at-bob: t; hsys-org-enable-smart-keys: t -*-
+# -*- mode: org; org-open-link-functions: (hbut:activate-at-p);
org-cycle-global-at-bob: t; hsys-org-enable-smart-keys: t -*-
* What's New in GNU Hyperbole
by Bob Weiner
diff --git a/Makefile b/Makefile
index 0a1376ea374..2d44ac6dcf5 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@
# Author: Bob Weiner
#
# Orig-Date: 15-Jun-94 at 03:42:38
-# Last-Mod: 16-Oct-26 at 11:12:54 by Mats Lidell
+# Last-Mod: 19-Oct-26 at 11:26:26 by Bob Weiner
#
# Copyright (C) 1994-2026 Free Software Foundation, Inc.
# See the file HY-COPY for license information.
@@ -577,13 +577,13 @@ kotl/kotl-autoloads.el: $(EL_KOTL)
# Used for ftp uploads. Pick tagged release files, make autoloads and
# put together as a compressed tarball.
$(pkg_parent)/hyperbole-$(HYPB_VERSION).tar.gz:
+ $(RM) -fr $(pkg_hyperbole)
git archive --format=tar --prefix=hyperbole-$(HYPB_VERSION)/
hyperbole-$(HYPB_VERSION) \
| (cd $(pkg_parent) && tar xf -)
cd $(pkg_hyperbole) && \
$(MAKE) autoloads && \
chmod 755 topwin.py && \
COPYFILE_DISABLE=1 $(TAR) -C $(pkg_parent) -clzf
$(pkg_hyperbole).tar.gz hyperbole-$(HYPB_VERSION)
- $(RM) -fr $(pkg_hyperbole)
# Create a tarball based on local files. Pick version controlled
# files, make autoloads and put together as a compressed tarball.
@@ -591,13 +591,13 @@ $(pkg_parent)/hyperbole-$(HYPB_VERSION).tar.gz:
pkg: $(pkg_parent)/hyperbole-local.tar.gz
$(pkg_parent)/hyperbole-local.tar.gz:
+ $(RM) -fr $(pkg_parent)/hyperbole-local
mkdir -p $(pkg_parent)/hyperbole-local
git ls-files -z | xargs -0 cp --parents -t $(pkg_parent)/hyperbole-local
cd $(pkg_parent)/hyperbole-local && \
$(MAKE) autoloads && \
chmod 755 topwin.py && \
COPYFILE_DISABLE=1 $(TAR) -C $(pkg_parent) -clzf
$(pkg_parent)/hyperbole-local.tar.gz hyperbole-local
- $(RM) -fr $(pkg_parent)/hyperbole-local
.PHONY: pkgclean packageclean
pkgclean: packageclean
diff --git a/hywiki.el b/hywiki.el
index 8dbee2a17fd..2765067d27a 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: 19-Oct-26 at 02:52:23 by Bob Weiner
+;; Last-Mod: 19-Oct-26 at 18:03:35 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -367,9 +367,10 @@ See `hywiki-org-publishing-directory' for exported pages
in html format."
(defun hywiki-directory-changed (option set-to-value operation _where)
"Watch function for variable `hywiki-directory'.
Function is called with 4 arguments: (OPTION SET-TO-VALUE OPERATION WHERE)."
- (if (memq operation '(let unlet)) ;; not setting global value
- (hywiki-let-directory option set-to-value)
- (hywiki-set-directory option set-to-value)))
+ (unless (hyperb:stack-frame '(hywiki-make-referent-hasht))
+ (if (memq operation '(let unlet)) ;; not setting global value
+ (hywiki-let-directory option set-to-value)
+ (hywiki-set-directory option set-to-value))))
;; This next line is needed to invoke `hywiki-set-directory' when
;; `hywiki-directory' is changed via `setq' or `let' rather than
@@ -1616,12 +1617,13 @@ from the documentation string for `hpath:find'.
PAGE-NAME must be the
HyWikiWord reference that can link to the page (no pathname directory nor
file extension).
-With optional FORCE-FLAG prefix arg non-nil, force an update to
-the page's modification time. If PAGE-NAME is invalid, trigger a
-`user-error' if called interactively or return nil if not.
+With optional FORCE-FLAG prefix arg non-nil, force an update to the page's
+modification time and create it if needed without asking. If PAGE-NAME is
+invalid, trigger a `user-error' if called interactively or return nil if
+not.
-By default, create any non-existent page. When not in batch or
-ert test results mode, if this is the first HyWiki page in
+By default, create any non-existent page. When not in batch or ert test
+results mode and FORCE-FLAG is nil, if this is the first HyWiki page in
`hywiki-directory', prompt to create it.
After successfully adding a page, run `hywiki-add-page-hook'.
@@ -1632,6 +1634,7 @@ Use `hywiki-get-referent' to determine whether a HyWiki
page exists."
current-prefix-arg))
(if (hywiki-word-is-p page-name)
(when (or noninteractive
+ force-flag
(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 "'? ")))
@@ -1792,7 +1795,7 @@ absolute path."
buffer-read-only nil)))
(defun hywiki-cache-save (&optional save-file)
- "Save the modified Environment to a file.
+ "Save `hywiki-directory' lookup data to a file.
The file is given by optional SAVE-FILE or `hywiki-cache-file'. Also
save and potentially set `hywiki--directory-mod-time' and
`hywiki--directory-checksum'."
@@ -1813,32 +1816,43 @@ save and potentially set `hywiki--directory-mod-time'
and
(unless (file-writable-p dir)
(error "(hywiki-cache-save): Non-writable Environment directory, \"%s\""
dir)))
(save-excursion
- (let ((standard-output (hywiki-cache-edit save-file)))
- (with-current-buffer standard-output
- (erase-buffer)
- (princ ";; -*- mode:lisp-data; coding: utf-8-emacs; -*-\n")
-
- ;; Don't save these 2 as then when read back, they overwrite the
- ;; current values improperly. Left commented here temporarily
- ;; while testing this change. -- RSW 2026-10-18
- ;; (princ (format "\n(setq\nhyperb:version %S\n" hyperb:version))
- ;; (princ (format "\nhywiki-directory %S\n" hywiki-directory))
-
- ;; Save last `hywiki-directory' mod time and checksum, nil if none.
- (princ (format "\n(setq\nhywiki--directory-mod-time '%S\n"
- (hywiki-directory-set-mod-time)))
-
- (princ (format "\nhywiki--directory-checksum %S\n"
- (hywiki-directory-set-checksum)))
-
- (princ "\nhywiki--referent-alist\n'")
- (hash-prin1 (hywiki-get-referent-hasht) nil t)
- (princ ")\n")
-
- (hypb:save-buffer-silently)
- (if (buffer-modified-p)
- (error "(hywiki-cache-save): Attempt to kill modified Environment
file failed to save, \"%s\"" save-file)
- (kill-buffer standard-output))))))
+ (let ((output-buffer (hywiki-cache-edit save-file))
+ marker
+ standard-output)
+ (with-current-buffer output-buffer
+ ;; Need to use a marker here or point will not always advance
+ ;; after the print calls
+ (unwind-protect
+ (progn (setq marker (copy-marker (point) t)
+ standard-output marker)
+ (set-marker-insertion-type standard-output t)
+ (erase-buffer)
+ (princ ";; -*- mode:lisp-data; coding: utf-8-emacs; -*-\n")
+
+ ;; Save these next two values only as comments for
reference.
+ ;; Otherwise, they would improperly override the current
values.
+ ;; -- RSW 2026-10-19
+ (terpri)
+ (princ (format ";; hyperb:version: %S\n" hyperb:version))
+ (princ (format ";; hywiki-directory: %S\n" hywiki-directory))
+
+ ;; Save last `hywiki-directory' mod time and checksum, nil
if none.
+ (princ (format "\n(setq\nhywiki--directory-mod-time '%S\n"
+ (hywiki-directory-set-mod-time)))
+
+ (princ (format "\nhywiki--directory-checksum %S\n"
+ (hywiki-directory-set-checksum)))
+
+ (princ "\nhywiki--referent-alist\n'")
+ (hash-prin1 (hywiki-get-referent-hasht) nil t)
+ (princ ")\n")
+
+ (hypb:save-buffer-silently))
+ (set-marker marker nil)
+ (if (buffer-modified-p)
+ (error "(hywiki-cache-save): HyWiki cache file failed to save:
\"%s\"" save-file)
+ (kill-buffer output-buffer))
+ save-file)))))
(defun hywiki-completion-at-point ()
"Complete a HyWiki reference at point.
@@ -2297,21 +2311,34 @@ Use `dired' unless
`action-key-modeline-buffer-id-function' is set to
(md5 (apply #'concat hywiki-page-files) nil nil nil t))))
(defun hywiki-directory-get-mod-time ()
- "Return the last mod time for `hywiki-directory' or nil."
+ "Return the last page file mod time for `hywiki-directory' or nil.
+Page file deletion is handled by a checksum over the set of
+HyWiki pages, which is verified before this mod-time check."
(when (file-readable-p hywiki-directory)
- (time-convert (file-attribute-modification-time
- (file-attributes hywiki-directory))
- 'list)))
+ (let* ((default-directory (expand-file-name (hpath:expand
hywiki-directory)))
+ (page-files (hywiki-get-page-files))
+ (max-page-mod-time (if page-files
+ (truncate
+ (apply #'max (mapcar (lambda (f)
+ (float-time
(file-attribute-modification-time
+
(file-attributes f))))
+ page-files)))
+ 0)))
+ (time-convert max-page-mod-time))))
(defun hywiki-directory-modified-p ()
"Return non-nil if any HyWiki page name change since last read."
(or (null hywiki--directory-mod-time)
- ;; Both dir mod-time and filename checksum over HyWiki page
- ;; files must have changed for this to be an update to report.
- ;; Don't change this logic as many other dir changes can occur
- ;; that should not be reported here.
- (not (or (equal hywiki--directory-mod-time
(hywiki-directory-get-mod-time))
- (string-equal hywiki--directory-checksum
(hywiki-directory-get-checksum))))))
+ ;; If checksum over HyWiki page files has changed, consider the
+ ;; directory modified
+ (not (string-equal hywiki--directory-checksum
+ (or (hywiki-directory-get-checksum) "")))
+ ;; The checksum handles only page file changes; here we have to
+ ;; account for the .eld cache file being updated with changes to
+ ;; WikiWords with non-page referents. Use the directory mod-time
+ ;; comparison for this.
+ (not (equal hywiki--directory-mod-time
+ (hywiki-directory-get-mod-time)))))
(defun hywiki-directory-set-checksum ()
"Store the last page name checksum for `hywiki-directory' as a string."
@@ -3768,8 +3795,8 @@ Use `hywiki-word-face' to highlight."
(page-elts (delq nil (mapcar (lambda (file)
(setq key (file-name-sans-extension
file))
(unless (and non-page-hasht
- (hash-get key
non-page-hasht)
- (cons (cons 'page
file) key))))
+ (hash-get key
non-page-hasht))
+ (cons (cons 'page file) key)))
page-files)))
(page-hasht (hash-make page-elts)))
(setq hywiki--referent-hasht
diff --git a/test/hywiki-tests.el b/test/hywiki-tests.el
index 80e292f43ac..504dd148063 100644
--- a/test/hywiki-tests.el
+++ b/test/hywiki-tests.el
@@ -3,7 +3,7 @@
;; Author: Mats Lidell
;;
;; Orig-Date: 18-May-24 at 23:59:48
-;; Last-Mod: 13-Sep-26 at 11:26:36 by Bob Weiner
+;; Last-Mod: 19-Oct-26 at 17:24:19 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -1492,7 +1492,7 @@ Note special meaning of `hywiki-allow-plurals-flag'."
(hywiki-add-org-id wiki-word-non-page)))
(hy-delete-file-and-buffer filea))))))
-;; !! FIXME: Add Org-id links tests.
+;; !! TODO FIXME: Add Org-id links tests.
;; Org roam
(ert-deftest hywiki-tests--save-referent-org-roam-node ()
@@ -1504,7 +1504,7 @@ Note special meaning of `hywiki-allow-plurals-flag'."
((org-roam-node-title "node") => "node-title"))
(hywiki-add-org-roam-node wiki-word-non-page))))
-;; !! TODO RSW having problems with this test so disabled for now
+;; !! TODO FIX: RSW having problems with this test so disabled for now
;; (ert-deftest hywiki-tests--save-referent-org-roam-node-use-menu ()
;; "Verify saving and loading a referent org roam node works using
Hyperbole's menu."
;; (skip-unless (not noninteractive))