[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/hyperbole d9ace571e9 10/10: Merge pull request #591 fro
From: |
ELPA Syncer |
Subject: |
[elpa] externals/hyperbole d9ace571e9 10/10: Merge pull request #591 from rswgnu/rsw |
Date: |
Sun, 22 Sep 2024 03:58:31 -0400 (EDT) |
branch: externals/hyperbole
commit d9ace571e979cc8db763b6020400bbb213eee5a4
Merge: ae6188cbd9 245704eec9
Author: Robert Weiner <rsw@gnu.org>
Commit: GitHub <noreply@github.com>
Merge pull request #591 from rswgnu/rsw
HyWiki Updates - handle plurals of HyWikiWords, removing empty HyWiki
files, track hywiki-directory updates
---
ChangeLog | 73 +++++++++++++++
hsys-org.el | 8 +-
hycontrol.el | 3 +-
hypb.el | 7 +-
hywiki.el | 254 +++++++++++++++++++++++++++++++--------------------
man/hyperbole.texi | 40 +++++---
test/hywiki-tests.el | 25 +++--
7 files changed, 289 insertions(+), 121 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ad80593f5f..882d44cf68 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,76 @@
+2024-09-22 Bob Weiner <rsw@gnu.org>
+
+* test/hywiki-tests.el (hywiki-tests--get-page-list-when-new-wiki-directory):
+ Remove 'hash-empty-p' test that fails exclusively on Emacs master.
+
+* hywiki.el (hywiki-find-page): Move prompt tests to 'hywiki-add-page'.
+ (hywiki-add-page): Add and run 'hywiki-add-page-hook'. Add
+ optional second arg 'prompt-flag' that 'hywiki-find-page' passes.
+ (hywiki-directory-get-checksum): Update to use
'hywiki-get-page-files'.
+ (hywiki-get-files): Remove, essentially duplicate of
+ 'hywiki-get-page-files'.
+
+* test/hywiki-tests.el (hywiki-tests--directory-modified-p):
+ Update to set checksum which is needed now and expand
+ test scenarios.
+ (hywiki-tests--wikiword-with-prefix-creates-a-new-page):
+ Update to add optional 2nd arg of nil to 'hywiki-add-page' call.
+
(hywiki-tests--hywiki-add-page--adds-file-in-wiki-folder):
+ Actually create empty file and then delete it, fixing
+ hywiki-add-page call failure.
+ hywiki.el (hywiki-add-page): Fix issue where hash table
+ value was set before empty page file is created so
+ did not have correct value.
+
+* hywiki.el (hywiki-maybe-highlight-page-names-in-frame,
+ hywiki-maybe-highlight-page-names): Move set of
+ mod-time and checksum here from 'hywiki-get-page-hasht' to
+ make work with 'hywiki-kill-buffer-hook'.
+
+2024-09-21 Bob Weiner <rsw@gnu.org>
+
+* hywiki.el (hywiki-kill-buffer-hook): Add for use as a global
+ 'kill-buffer-hook'.
+ hypb.el (hypb:empty-file-p): Add and use in 'hywiki-kill-buffer-hook'.
+
+* hywiki.el (hywiki-maybe-highlight-page-names): Dehighlight HyWikiWords
+ before re-highlighting new set.
+
+* hywiki.el (hywiki-find-page): Prompt when creating the first HyWiki page
+ so user is not surprised by this Action Key behavior.
+ (hywiki-maybe-highlight-page-names): Add 3rd optional arg,
+ 'skip-lookups-update-flag'.
+ (hywiki-maybe-highlight-page-names-in-frame): Add optional 2nd arg,
+ 'skip-lookups-update-flag'
+ (hywiki-get-page-hasht): Call above function when update
+ lookup tables so use new data to highlight HyWikiWords.
+
+* man/hyperbole.texi (Manual Overview): Add links for HyWiki and HyNote.
+
+* hywiki.el (hywiki-maybe-highlight-balanced-pairs): Separate balanced
+ pair delimited expression highlighting into this function to allow
+ for more general handling. Expand range from one line to two.
+ (hywiki-maybe-highlight-page-name): Call above function.
+ (hywiki-get-page): Auto-link standard pluralizations of HyWikiWords
+ that end 's' when not preceded by an 's' or in 'es'.
+ (hywiki-directory-set-mod-time): Add.
+ (hywiki--directory-checksum): Add for checking if any HyWiki page
file
+ names have changed.
+ (hywiki-directory-get-checksum, hywiki-directory-set-checksum): Add.
+ (hywiki-directory-modified-p): Additionally test if dir checksum
changed.
+ (hywiki-get-page-hasht): Fix to update pages hash table and page
name
+ and page name regexp lookups if any page file name changes.
+ (hywiki-maybe-highlight-page-names): Force rebuild of pages hash
table
+ if any page file names have changed in 'hywiki-directory' and move mod-time
+ update to 'hywiki-get-page-hasht'.
+
+2024-09-16 Bob Weiner <rsw@gnu.org>
+
+* hsys-org.el {C-c C-@} Bind this key in Org mode to
+ 'hycontrol-windows-grid' unless already bound.
+ hycontrol.el (hycontrol-windows-grid): Fix infinite recursive call
+ when 'mode-binding' is the same as the current command, e.g. org-mode.
+
2024-09-11 Mats Lidell <matsl@gnu.org>
* test/hyrolo-tests.el (hyrolo-tests--get-file-list): Verify
diff --git a/hsys-org.el b/hsys-org.el
index e45db4fedf..ebc7dbc1bd 100644
--- a/hsys-org.el
+++ b/hsys-org.el
@@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 2-Jul-16 at 14:54:14
-;; Last-Mod: 8-Aug-24 at 23:51:10 by Mats Lidell
+;; Last-Mod: 16-Sep-24 at 22:19:53 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -45,6 +45,12 @@
;;; Public declarations
;;; ************************************************************************
+;; Bind {C-c C-@} to create a user-specified sized grid of windows
+;; displaying different buffers.
+;; Don't override prior bindings of this key.
+(unless (lookup-key org-mode-map "\C-c\C-@")
+ (define-key org-mode-map "\C-c\C-@" #'hycontrol-windows-grid))
+
(defvar hyperbole-mode-map) ; "hyperbole.el"
(defvar org--inhibit-version-check) ; "org-macs.el"
(defvar hywiki-org-link-type-required) ; "hywiki.el"
diff --git a/hycontrol.el b/hycontrol.el
index ea25e52801..46bcec75ae 100644
--- a/hycontrol.el
+++ b/hycontrol.el
@@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 1-Jun-16 at 15:35:36
-;; Last-Mod: 29-May-24 at 00:57:08 by Bob Weiner
+;; Last-Mod: 16-Sep-24 at 22:40:19 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -1666,6 +1666,7 @@ command instead. Typically prevents clashes over
{\\`C-c' @}."
(this-key-flag (and (called-interactively-p 'interactive)
(equal (this-single-command-keys) key))))
(cond ((and mode-binding (not (integerp mode-binding))
+ (not (eq this-command mode-binding))
this-key-flag (if (eq major-mode #'outline-mode) (not arg)
t))
;; If the key that invokes this command in `hyperbole-minor-mode'
;; is also bound in the current major mode map, then
diff --git a/hypb.el b/hypb.el
index d804b5e064..a198e15a85 100644
--- a/hypb.el
+++ b/hypb.el
@@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 6-Oct-91 at 03:42:38
-;; Last-Mod: 8-Jun-24 at 19:54:44 by Bob Weiner
+;; Last-Mod: 21-Sep-24 at 23:20:56 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -465,6 +465,11 @@ This will install the Emacs devdocs package if not yet
installed."
dname))))
(concat "@" dname))))
+(defun hypb:empty-file-p ()
+ "Return non-nil if the current buffer has an attached file of zero size."
+ (when (and buffer-file-name (file-readable-p buffer-file-name))
+ (= (file-attribute-size (file-attributes buffer-file-name)) 0)))
+
(defun hypb:error (&rest args)
"Signal an error typically to be caught by `hyperbole'.
The error message is formatted passing the rest of the ARGS to
diff --git a/hywiki.el b/hywiki.el
index 8bcc9905c3..05e0069fa5 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: 11-Sep-24 at 08:52:36 by Mats Lidell
+;; Last-Mod: 22-Sep-24 at 02:44:39 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -39,11 +39,11 @@
;; - comments of programming buffers, when `hywiki-mode' is enabled.
;;
;; As HyWikiWords are typed, highlighting occurs after a trailing
-;; whitespace or punctuation character is added, or when an opening
-;; or closing parenthesis or curly brace is added to surround the
-;; HyWikiWord. Since Org links use double square brackets and Org
-;; targets use double or triple angle brackets, HyWikiWords within
-;; these delimiters are ignored.
+;; whitespace or punctuation character is added, or when it is
+;; surrounded by a matching pair of characters such as curly braces
+;; or single square brackets. Since Org links use double square
+;; brackets and Org targets use double or triple angle brackets,
+;; HyWikiWords within these delimiters are ignored.
;;
;; You can also create Org links to HyWikiWords in any non-special text
;; buffer by surrounding them with double square brackets and the
@@ -372,6 +372,9 @@ in `hywiki-mode'.")
(defconst hywiki--word-and-buttonize-character-regexp nil
"Regexp matching HyWikiWord#section plus a valid word separating character.")
+(defvar hywiki--directory-checksum ""
+ "String checksum for `hywiki-directory' page names.")
+
(defvar hywiki--directory-mod-time 0
"Last mod time for `hywiki-directory' or 0 if the value has not been read.")
@@ -518,11 +521,12 @@ Return the absolute path to any page successfully found;
nil if
failed or if displaying a regular file (read in via a `find-file'
call).
-By default, create any non-existent page. With optional
-PROMPT-FLAG t, prompt to create if non-existent. If PROMPT-FLAG
-is :existing or with a prefix argument when called interactively,
-return nil unless the page already exists. After successfully
-finding a page and reading it into a buffer, run
+By default, create any non-existent page. When not in batch mode,
+with optional PROMPT-FLAG t or if this is the first HyWiki page in
+`hywiki-directory', prompt to create if non-existent. If
+PROMPT-FLAG is :existing or with a prefix argument when called
+interactively, return nil unless the page already exists. After
+successfully finding a page and reading it into a buffer, run
`hywiki-find-page-hook'."
(interactive (list (if current-prefix-arg
(hywiki-read-page-name "Find existing HyWiki page: ")
@@ -546,11 +550,7 @@ finding a page and reading it into a buffer, run
(substring page-name 0 (match-beginning 0))
page-name))
(page-file (or (hywiki-get-page page-name)
- (if prompt-flag
- (unless (eq prompt-flag :existing)
- (when (y-or-n-p (concat "Create new `"
page-name "' page? "))
- (hywiki-add-page page-name)))
- (hywiki-add-page page-name)))))
+ (hywiki-add-page page-name prompt-flag))))
(when page-file
;; Ensure highlight any page name at point in case called as a
;; Hyperbole action type
@@ -585,27 +585,39 @@ Exclude the minibuffer if selected and return nil."
(insert (hywiki-read-page-name "Link to HyWiki page: "))
(hywiki-maybe-highlight-page-name))
-(defun hywiki-add-page (page-name)
+(defun hywiki-add-page (page-name &optional prompt-flag)
"Add or edit the HyWiki page for PAGE-NAME and return its file.
If file exists already, just return it. 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 mode,
+with optional PROMPT-FLAG t or if this is the first HyWiki page in
+`hywiki-directory', prompt to create if non-existent. If
+PROMPT-FLAG is :existing or with a prefix argument when called
+interactively, return nil unless the page already exists. After
+successfully adding a page, run `hywiki-add-page-hook'.
+
Use `hywiki-get-page' to determine whether a HyWiki page exists."
- (interactive (list (hywiki-read-new-page-name "Add/Edit HyWiki page: ")))
+ (interactive (list (hywiki-read-new-page-name "Add/Edit HyWiki page: ")
+ current-prefix-arg))
(if (hywiki-word-is-p page-name)
- (progn
+ (unless (or (eq prompt-flag :existing)
+ (and prompt-flag (null noninteractive)
+ (not (y-or-n-p (concat "Create new HyWiki page `"
page-name "'? ")))))
(when (match-string-no-properties 2 page-name)
;; Remove any #section suffix in PAGE-NAME.
(setq page-name (match-string-no-properties 1 page-name)))
(let ((page-file (hywiki-get-file page-name))
- (pages-hasht (hywiki-get-page-hasht)))
+ pages-hasht)
(unless (file-readable-p page-file)
;; Create any parent dirs necessary to create empty file
(make-empty-file page-file t))
+ (setq pages-hasht (hywiki-get-page-hasht))
(unless (hash-get page-name pages-hasht)
(hash-add page-file page-name pages-hasht))
+ (run-hooks 'hywiki-add-page-hook)
page-file))
(when (called-interactively-p 'interactive)
(user-error "(hywiki-add-page): Invalid page name: '%s'; must be
capitalized, all alpha" page-name))))
@@ -792,6 +804,12 @@ interactively), limit dehighlighting to the region."
(unless (or region-start region-end)
(setq hywiki-buffer-highlighted-state 'd))))
+(defun hywiki-directory-get-checksum ()
+ "Compute and return the checksum for the current set of HyWiki pages."
+ (let ((hywiki-page-files (hywiki-get-page-files)))
+ (when hywiki-page-files
+ (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 0."
(if (file-readable-p hywiki-directory)
@@ -801,9 +819,18 @@ interactively), limit dehighlighting to the region."
0))
(defun hywiki-directory-modified-p ()
- "Return non-nil if `hywiki-directory' has been modified since last read."
+ "Return non-nil if any HyWiki page name change since last read."
(or (zerop hywiki--directory-mod-time)
- (/= hywiki--directory-mod-time (hywiki-directory-get-mod-time))))
+ (and (/= hywiki--directory-mod-time (hywiki-directory-get-mod-time))
+ (not (string-equal hywiki--directory-checksum
(hywiki-directory-get-checksum))))))
+
+(defun hywiki-directory-set-checksum ()
+ "Store the last page name checksum for `hywiki-directory' as a string."
+ (setq hywiki--directory-checksum (hywiki-directory-get-checksum)))
+
+(defun hywiki-directory-set-mod-time ()
+ "Store the last page mod time for `hywiki-directory' as an integer."
+ (setq hywiki--directory-mod-time (hywiki-directory-get-mod-time)))
(defun hywiki-highlight-on-yank (_prop-value start end)
"Used in `yank-handled-properties' called with START and END pos of the
text."
@@ -820,6 +847,42 @@ and its option #section."
(overlays-in (point-min) (point-max)))
nil))
+
+(defun hywiki-maybe-highlight-balanced-pairs ()
+ "Before or after a balanced delimiter, highlight HyWikiWords within.
+Includes: (), {}, <> and []. Excludes Org links and radio targets."
+ (save-excursion
+ (save-restriction
+ ;; Limit balanced pair checks to the next two lines for speed
+ (narrow-to-region (line-beginning-position) (line-end-position 2))
+ (cond ((memq (char-before) '(?\[ ?\<))
+ (goto-char (1- (point)))
+ ;; Clear any HyWikiWord highlighting within double opening
+ ;; square or angle brackets, when this is a link or target
+ (hywiki-maybe-highlight-org-element-forward))
+ ((memq (char-after) '(?\[ ?\<))
+ ;; Clear any HyWikiWord highlighting within double opening
+ ;; square or angle brackets, when this is a link or target
+ (hywiki-maybe-highlight-org-element-forward))
+ ((memq (char-before) '(?\( ?\{))
+ ;; Highlight any HyWikiWords within opening parens or braces
+ (ignore-errors
+ (goto-char (1- (point)))
+ (hywiki-maybe-highlight-sexp 1)))
+ ((memq (char-before) '(?\] ?\>))
+ ;; Clear any HyWikiWord highlighting within double closing
+ ;; square or angle brackets, as this may be a link or target
+ (hywiki-maybe-highlight-org-element-backward))
+ ((memq (char-after) '(?\] ?\>))
+ (goto-char (1+ (point)))
+ ;; Clear any HyWikiWord highlighting within double closing
+ ;; square or angle brackets, as this may be a link or target
+ (hywiki-maybe-highlight-org-element-backward))
+ ((memq (char-before) '(?\) ?\}))
+ ;; Highlight any HyWikiWords within closing parens or braces
+ (ignore-errors
+ (hywiki-maybe-highlight-sexp -1)))))))
+
;;;###autoload
(defun hywiki-maybe-highlight-page-name (&optional on-page-name)
"Highlight any non-Org link HyWiki page#section at or one char before point.
@@ -848,38 +911,7 @@ the current page unless they have sections attached."
;; after page name
(skip-syntax-backward "-"))
- (save-excursion
- (save-restriction
- ;; Limit sexp checks to a single line for speed since links and
- ;; targets should be on a single line.
- (narrow-to-region (line-beginning-position) (line-end-position))
- (cond ((memq (char-before) '(?\[ ?\<))
- (goto-char (1- (point)))
- ;; Clear any HyWikiWord highlighting within double opening
- ;; square or angle brackets, when this is a link or target
- (hywiki-maybe-highlight-org-element-forward))
- ((memq (char-after) '(?\[ ?\<))
- ;; Clear any HyWikiWord highlighting within double opening
- ;; square or angle brackets, when this is a link or target
- (hywiki-maybe-highlight-org-element-forward))
- ((memq (char-before) '(?\( ?\{))
- ;; Highlight any HyWikiWords within opening parens or
braces
- (ignore-errors
- (goto-char (1- (point)))
- (hywiki-maybe-highlight-sexp 1)))
- ((memq (char-before) '(?\] ?\>))
- ;; Clear any HyWikiWord highlighting within double closing
- ;; square or angle brackets, as this may be a link or
target
- (hywiki-maybe-highlight-org-element-backward))
- ((memq (char-after) '(?\] ?\>))
- (goto-char (1+ (point)))
- ;; Clear any HyWikiWord highlighting within double closing
- ;; square or angle brackets, as this may be a link or
target
- (hywiki-maybe-highlight-org-element-backward))
- ((memq (char-before) '(?\) ?\}))
- ;; Highlight any HyWikiWords within closing parens or
braces
- (ignore-errors
- (hywiki-maybe-highlight-sexp -1))))))
+ (hywiki-maybe-highlight-balanced-pairs)
(unless hywiki--highlighting-done-flag
(unless on-page-name
@@ -984,10 +1016,12 @@ DIRECTION-NUMBER is 1 for forward scanning and -1 for
backward scanning."
(hywiki-maybe-highlight-sexp 1))))
;;;###autoload
-(defun hywiki-maybe-highlight-page-names (&optional region-start region-end)
+(defun hywiki-maybe-highlight-page-names (&optional region-start region-end
skip-lookups-update-flag)
"Highlight each non-Org link HyWiki page#section in a buffer/region.
-With optional REGION-START and REGION-END positions (active region
-interactively), limit highlighting to the region.
+With optional REGION-START and REGION-END positions (active
+region interactively), limit highlighting to the region. With
+optional SKIP-LOOKUPS-UPDATE-FLAG non-nil, HyWiki lookup tables
+should have already been updated and this is skipped.
Use `hywiki-word-face' to highlight. Do not highlight references to
the current page unless they have sections attached.
@@ -996,29 +1030,19 @@ Dehighlight buffers other than HyWiki pages when
`hywiki-mode' is
disabled. Highlight/dehighlight HyWiki page buffers when
`hywiki-word-highlight-flag' is changed."
(interactive (when (use-region-p) (list (region-beginning) (region-end))))
- ;; Avoid doing any lets for efficiency.
+ ;; Avoid doing many lets for efficiency.
;; Highlight HyWiki words in buffers where `hywiki-mode' is enabled
- ;; or with attached files below `hywiki-directory'.
+ ;; or HyWiki pages below `hywiki-directory'.
(if (hywiki-active-in-current-buffer-p)
(unless (and (null region-start) (null region-end)
- (eq hywiki-buffer-highlighted-state 'h))
+ (eq hywiki-buffer-highlighted-state 'h)
+ (not (hywiki-directory-modified-p)))
+ (unless skip-lookups-update-flag
+ ;; Rebuild lookup tables if any HyWiki page name has changed
+ (hywiki-get-page-hasht))
(unwind-protect
(save-excursion
(save-restriction
- (when (or (null hywiki--any-page-regexp-list)
- (hywiki-directory-modified-p))
- ;; Compute these expensive regexps (matching 50
- ;; hywiki words at a time) only if `hywiki-directory'
- ;; mod time has changed.
- (setq hywiki--any-page-regexp-list
- (mapcar (lambda (page-sublist)
- (concat (regexp-opt page-sublist 'words)
- "\\("
- hywiki-word-section-regexp "?\\)"
- hywiki--buttonize-character-regexp))
- (hypb:split-seq-into-sublists
- (hywiki-get-page-list) 50))
- hywiki--directory-mod-time
(hywiki-directory-get-mod-time)))
(setq hywiki--save-case-fold-search case-fold-search
case-fold-search nil
hywiki--save-org-link-type-required
hywiki-org-link-type-required
@@ -1027,6 +1051,8 @@ disabled. Highlight/dehighlight HyWiki page buffers when
(if (and region-start region-end)
(narrow-to-region region-start region-end)
(widen))
+ (let ((hywiki-word-highlight-flag))
+ (hywiki-maybe-dehighlight-page-names))
(dolist (hywiki-words-regexp hywiki--any-page-regexp-list)
(goto-char (point-min))
(let ((highlight-in-comments-only
@@ -1086,19 +1112,22 @@ disabled. Highlight/dehighlight HyWiki page buffers
when
(/= region-end (point-max))))
(setq hywiki-buffer-highlighted-state 'h))))
(setq case-fold-search hywiki--save-case-fold-search
- hywiki-org-link-type-required
hywiki--save-org-link-type-required))
- )
+ hywiki-org-link-type-required
hywiki--save-org-link-type-required)))
;; Otherwise, dehighlight HyWikiWords in this buffer when
;; 'hywiki-mode' is disabled and this is not a HyWiki page
;; buffer. If this is a HyWiki page buffer, then dehighlight
;; when `hywiki-word-highlight-flag' is nil.
- (hywiki-maybe-dehighlight-page-names region-start region-end)))
+ (hywiki-maybe-dehighlight-page-names region-start region-end))
+ (unless (hyperb:stack-frame '(hywiki-maybe-highlight-page-names-in-frame))
+ (hywiki-directory-set-mod-time)
+ (hywiki-directory-set-checksum)))
-(defun hywiki-maybe-highlight-page-names-in-frame (frame)
+(defun hywiki-maybe-highlight-page-names-in-frame (frame &optional
skip-lookups-update-flag)
"Highlight all non-Org link HyWiki page names displayed in FRAME.
If FRAME is t, then highlight in all windows across all frames, even
-invisible ones.
+invisible ones. With optional SKIP-LOOKUPS-UPDATE-FLAG non-nil, HyWiki
+lookup tables should have already been updated and this is skipped.
Use `hywiki-word-face' to highlight. Does not highlight references to
the current page unless they have sections attached."
@@ -1108,8 +1137,10 @@ the current page unless they have sections attached."
;; Display buffer before `normal-mode' triggers possibly
;; long-running font-locking
(sit-for 0)
- (hywiki-maybe-highlight-page-names)))
- nil frame))
+ (hywiki-maybe-highlight-page-names nil nil skip-lookups-update-flag)))
+ nil frame)
+ (hywiki-directory-set-mod-time)
+ (hywiki-directory-set-checksum))
(defun hywiki-in-page-p ()
"Return non-nil if the current buffer is a HyWiki page.
@@ -1126,21 +1157,10 @@ are typed in the buffer."
(file-name-sans-extension (file-name-nondirectory
(or buffer-file-name (buffer-name)))))
-(defun hywiki-get-files ()
- "Return the list of existing HyWiki files ending with `hywiki-file-suffix'.
-This includes both HyWiki page files and others. File names returned are
-relative to `hywiki-directory'."
- (when (stringp hywiki-directory)
- (make-directory hywiki-directory t)
- (when (file-readable-p hywiki-directory)
- (directory-files
- hywiki-directory nil
- (concat "^[^#]+" (regexp-quote hywiki-file-suffix) "$")))))
-
(defun hywiki-get-page (page-name)
"Return the absolute path of HyWiki PAGE-NAME or nil if it does not exist."
(when (and (stringp page-name) (not (string-empty-p page-name))
- (string-match hywiki-word-with-optional-section-exact-regexp
page-name))
+ (string-match hywiki-word-with-optional-section-exact-regexp
page-name))
(when (match-string-no-properties 2 page-name)
;; Remove any #section suffix in PAGE-NAME.
(setq page-name (match-string-no-properties 1 page-name)))
@@ -1148,7 +1168,13 @@ relative to `hywiki-directory'."
(or (hash-get page-name (hywiki-get-page-hasht))
;; If page exists but not yet in lookup hash table, add it.
(when (file-readable-p (hywiki-get-file page-name))
- (hywiki-add-page page-name)))))
+ (hywiki-add-page page-name))
+ ;; Handle typical pluralized words ending in 's' (not preceded
+ ;; by an 's') or 'es'
+ (when (string-match "es$" page-name)
+ (hash-get (substring page-name 0 -2) (hywiki-get-page-hasht)))
+ (when (string-match ".[^eEsS]s$" page-name)
+ (hash-get (substring page-name 0 -1) (hywiki-get-page-hasht))))))
(defun hywiki-get-file (file-stem-name)
"Return possibly non-existent path in `hywiki-directory' from FILE-STEM-NAME.
@@ -1173,14 +1199,44 @@ These must end with `hywiki-file-suffix'."
(regexp-quote hywiki-file-suffix) "$")))))
(defun hywiki-get-page-hasht ()
- "Return hash table of existing HyWiki pages."
- (if (equal hywiki--pages-directory hywiki-directory)
+ "Return hash table of existing HyWiki pages.
+May update the page hash table if out-of-date as well as the list of
+regexps of page names."
+ (if (and hywiki--any-page-regexp-list
+ (equal hywiki--pages-directory hywiki-directory)
+ ;; If page files changed, have to rebuild page hash table
+ (not (hywiki-directory-modified-p)))
(or hywiki--pages-hasht (hywiki-make-pages-hasht))
- (hywiki-make-pages-hasht)))
+ ;; Rebuild page hash table
+ (hywiki-make-pages-hasht)
+ ;; Compute these expensive regexps (matching 50
+ ;; hywiki words at a time) only if the set of HyWiki
+ ;; page names has changed in `hywiki-directory'.
+ (setq hywiki--any-page-regexp-list
+ (mapcar (lambda (page-sublist)
+ (concat (regexp-opt page-sublist 'words)
+ "\\("
+ hywiki-word-section-regexp "?\\)"
+ hywiki--buttonize-character-regexp))
+ (hypb:split-seq-into-sublists
+ (hash-map #'cdr hywiki--pages-hasht) 50)))
+ (hywiki-maybe-highlight-page-names-in-frame t t)
+ hywiki--pages-hasht))
(defun hywiki-get-page-list ()
(hash-map #'cdr (hywiki-get-page-hasht)))
+(defun hywiki-kill-buffer-hook ()
+ "Delete file attached to HyWiki buffer if the file is zero-sized.
+If deleted, update HyWikiWord highlighting across all frames."
+ (when (hywiki-in-page-p)
+ (when (hypb:empty-file-p)
+ (delete-file buffer-file-name))
+ (when (hywiki-directory-modified-p)
+ ;; Rebuild lookup tables if any HyWiki page name has changed
+ (hywiki-get-page-hasht))
+ nil))
+
(defun hywiki-make-pages-hasht ()
(let* ((page-files (hywiki-get-page-files))
(page-elts (mapcar (lambda (file)
@@ -1430,7 +1486,7 @@ optional VIEW-BUFFER-NAME, use that rather than the
default,
"Watch function for variable ``hywiki-word-highlight-flag'.
Function is called with 4 arguments: (SYMBOL SET-TO-VALUE OPERATION WHERE).
Highlight/dehighlight HyWiki page names across all frames on change."
- (unless (memq operation '(let unlet)) ;; not setting global valNue
+ (unless (memq operation '(let unlet)) ;; not setting global value
(set symbol set-to-value)
(if set-to-value
;; enabled
@@ -1472,6 +1528,8 @@ Highlight/dehighlight HyWiki page names across all frames
on change."
;;; Public initializations
;;; ************************************************************************
+(add-hook 'kill-buffer-hook 'hywiki-kill-buffer-hook)
+
(eval-after-load "org-element"
'(advice-add 'org-element--generate-copy-script :before
#'hywiki-org-export-function))
diff --git a/man/hyperbole.texi b/man/hyperbole.texi
index e40ee134a5..e6c3baba70 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: 2-Sep-24 at 19:50:16 by Bob Weiner
+@c Last-Mod: 21-Sep-24 at 18:10:46 by Bob Weiner
@c %**start of header (This is for running Texinfo on a region.)
@setfilename hyperbole.info
@@ -159,7 +159,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</P>
<PRE>
Edition 9.0.2pre
-Printed September 1, 2024.
+Printed September 21, 2024.
Published by the Free Software Foundation, Inc.
Author: Bob Weiner
@@ -201,7 +201,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@example
Edition 9.0.2pre
-September 1, 2024
+September 21, 2024
Published by the Free Software Foundation, Inc.
Author: Bob Weiner
@@ -589,7 +589,7 @@ Hyperbole allows hypertext buttons to be embedded within
unstructured and
structured files, mail messages and news articles. It offers intuitive
keyboard and mouse-based control of information display within multiple
windows. It also provides point-and-click access to Info manuals, ftp
-archives, and the World-Wide Web.
+archives, the World-Wide Web and much more.
@cindex file, FAST-DEMO
@cindex Hyperbole demo
@@ -632,17 +632,33 @@ provides a number of overlapping interaction methods that
support differing
work styles. In such instances, you need learn only one technique that suits
you.
-@xref{Buttons}, for an overview of Hyperbole buttons and how to use them.
+@xref{Buttons}, for an overview of Hyperbole buttons and how to use
+them. Hyperbole's action-oriented button support is enabled via the
+global minor mode, @code{hyperbole-mode).
+
@xref{Menus}, for summaries of Hyperbole menu commands and how to use
the minibuffer-based menus that work on any display that Emacs supports.
+@xref{HyWiki}, for Hyperbole's markup-free, personal Wiki system for
+note-taking and automatic WikiWord highlighting and hyperlinking. It
+extends Org mode. HyWikiWord hyperlink buttons are automatically
+enabled for wiki pages below @code{hywiki-directory}. To enable them
+in text buffers outside of this directory, enable the global minor
+mode, @code{hywiki-mode}.
+
+@xref{HyNote}, for a start on the very early stages of Hyperbole's
+multi-format note taking system. HyNote supports Org, Markdown,
+Koutline and Emacs Outline file formats. HyNote works in any buffer
+where HyWiki support is active.
+
@xref{HyControl}, for how to quickly and interactively control what your
Emacs windows and frames display and where they appear.
@xref{Koutliner}, for concept and usage information on the
-autonumbered, hypertextual outliner. @xref{Koutliner Keys}, for a full
-summary of the outliner commands that are bound to keys.
+autonumbered, hypertextual outliner. It uses its own major mode.
+@xref{Koutliner Keys}, for a full summary of the outliner commands
+that are bound to keys.
@xref{HyRolo}, for concept and usage information on the rapid lookup,
hierarchical, full-text record management system included with Hyperbole.
@@ -4487,10 +4503,10 @@ the following contexts:
@cindex HyWikiWord highlighting
As HyWikiWords are typed, highlighting occurs after a trailing
whitespace or punctuation character is added, or when the HyWikiWord
-is surrounded by a matching pair of characters such as curly braces.
-Since Org links use double square brackets and Org targets use double
-or triple angle brackets, HyWikiWords within these delimiters are
-ignored once the brackets are in place.
+is surrounded by a matching pair of characters such as curly braces or
+single square brackets. Since Org links use double square brackets
+and Org targets use double or triple angle brackets, HyWikiWords
+within these delimiters are ignored once the brackets are in place.
@vindex hywiki-word-highlight-flag
The custom setting, @code{hywiki-word-highlight-flag} (default =
@@ -4668,7 +4684,7 @@ implicit button type that HyNote defines,
@code{hynote-file}.
In the future, HyNote will also provide a universal way to easily link to
information across many file formats.
-See also @ref{HyWiki}.
+For more, @ref{HyWiki}.
@node HyControl, Koutliner, HyNote, Top
diff --git a/test/hywiki-tests.el b/test/hywiki-tests.el
index a200ee0463..bf896fdb24 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: 15-Aug-24 at 09:17:01 by Mats Lidell
+;; Last-Mod: 22-Sep-24 at 03:00:21 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -29,7 +29,7 @@
(hywiki-directory (make-temp-file "hywiki" t))
(hywiki-page-file (expand-file-name "WikiWord.org" hywiki-directory)))
(unwind-protect
- (mocklet (((make-empty-file (expand-file-name "WikiWord.org"
hywiki-directory) t) => t))
+ (progn
(should (string= hywiki-page-file
(hywiki-add-page "WikiWord")))
;; Verify hash table is updated
@@ -37,6 +37,7 @@
(not-called hywiki-add-page)
(should (string= hywiki-page-file
(hywiki-get-page "WikiWord")))))
+ (hy-delete-file-and-buffer hywiki-page-file)
(hy-delete-dir-and-buffer hywiki-directory))))
(ert-deftest hywiki-tests--hywiki-add-page--adds-no-wiki-word-fails ()
@@ -61,7 +62,7 @@
(with-temp-buffer
(insert "[[hy:WikiWord]]")
(goto-char 4)
- (mocklet (((hywiki-add-page "WikiWord") => wikifile))
+ (mocklet (((hywiki-add-page "WikiWord" nil) => wikifile))
(action-key)))
(hy-delete-file-and-buffer wikifile))))
@@ -163,10 +164,19 @@
"Verify `hywiki-directory-modified-p'."
(let ((hywiki--directory-mod-time 0))
(should (hywiki-directory-modified-p)))
- (let ((hywiki--directory-mod-time 2))
- (mocklet ((hywiki-directory-get-mod-time => 2))
+ (let ((hywiki--directory-mod-time 2)
+ (hywiki--directory-checksum "3"))
+ (mocklet ((hywiki-directory-get-mod-time => 2)
+ (hywiki-directory-get-checksum => "3"))
(should-not (hywiki-directory-modified-p)))
- (mocklet ((hywiki-directory-get-mod-time => 1))
+ (mocklet ((hywiki-directory-get-mod-time => 2)
+ (hywiki-directory-get-checksum => "4"))
+ (should-not (hywiki-directory-modified-p)))
+ (mocklet ((hywiki-directory-get-mod-time => 1)
+ (hywiki-directory-get-checksum => "3"))
+ (should-not (hywiki-directory-modified-p)))
+ (mocklet ((hywiki-directory-get-mod-time => 1)
+ (hywiki-directory-get-checksum => "4"))
(should (hywiki-directory-modified-p)))))
(ert-deftest hywiki-tests--get-page-list ()
@@ -206,8 +216,7 @@
(let ((hywiki-directory (make-temp-file "hywiki" t)))
(unwind-protect
(progn
- (should (hash-empty-p (hywiki-get-page-hasht)))
- (should (= 0 (length (hywiki-get-page-list)))))
+ (should (= 0 (length (hywiki-get-page-list)))))
(hy-delete-dir-and-buffer hywiki-directory))))
(hy-delete-file-and-buffer wiki-page)
(hy-delete-dir-and-buffer hywiki-directory))))
- [elpa] externals/hyperbole updated (ae6188cbd9 -> d9ace571e9), ELPA Syncer, 2024/09/22
- [elpa] externals/hyperbole ecda83745a 04/10: hypb.el (hypb:empty-file-p): Add, use in 'hywiki-kill-buffer-hook', ELPA Syncer, 2024/09/22
- [elpa] externals/hyperbole c11d34e806 01/10: hsys-org.el {C-c C-@} - bind in Org mode to 'hycontrol-windows-grid', ELPA Syncer, 2024/09/22
- [elpa] externals/hyperbole 7fe5e3f99c 05/10: hywiki.el - Add 'hywiki-kill-buffer-hook', ELPA Syncer, 2024/09/22
- [elpa] externals/hyperbole 64f7c8f1ea 07/10: Merge branch 'master' of hyperbole into rsw, ELPA Syncer, 2024/09/22
- [elpa] externals/hyperbole d9ace571e9 10/10: Merge pull request #591 from rswgnu/rsw,
ELPA Syncer <=
- [elpa] externals/hyperbole 6d2586e581 02/10: hywiki.el - Add support for page name plurals, ELPA Syncer, 2024/09/22
- [elpa] externals/hyperbole 8a29158612 03/10: hywiki.el (hywiki-find-page): Prompt when creating first HyWiki page, ELPA Syncer, 2024/09/22
- [elpa] externals/hyperbole 385c6f121f 06/10: hywiki.el - Fix so HyWikiWord highlighting tracks hywiki-dir updates, ELPA Syncer, 2024/09/22
- [elpa] externals/hyperbole 245704eec9 09/10: test/hywiki-tests.el (hywiki-tests--get-page-list-when-new-wiki-directory):, ELPA Syncer, 2024/09/22
- [elpa] externals/hyperbole 6c1011c896 08/10: hywiki.el - Ensure hywiki-directory is created before trying to read, ELPA Syncer, 2024/09/22