branch: externals/hyperbole
commit 5e1350d9d56234f009fc74e5582859d8c464f200
Author: bw <[email protected]>
Commit: bw <[email protected]>
hywiki-word-at - Fix to obey `hywiki-org-link-type-required' setting
hywiki-tests--assist-key-on-hywikiword-displays-help - Fix.
hywiki-tests--wikiword-identified-with-delimiters - Handle
'hywiki-org-link-type-required'.
hsys-org:org-link-at-p - Handle 'hywiki-org-link-type-required'.
Rename HyWiki hook functions.
---
ChangeLog | 43 ++++++++++---
hibtypes.el | 3 +-
hsys-org.el | 20 +++---
hyrolo-logic.el | 42 ++++++------
hyrolo.el | 8 ++-
hywiki.el | 172 ++++++++++++++++++++++++-------------------------
hywiki/HyWiki.org | 2 +-
man/hyperbole.texi | 6 +-
test/hsys-org-tests.el | 45 ++++++-------
test/hywiki-tests.el | 15 +++--
10 files changed, 195 insertions(+), 161 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 226262bdc2..f361a6ac39 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,30 @@
+2025-11-22 Bob Weiner <[email protected]>
+
+* test/hywiki-tests.el (hywiki-tests--assist-key-on-hywikiword-displays-help):
+ Fix so always works regardless of where Hyperbole Help window is displayed
+ or whether it is the selected window.
+ (hywiki-tests--wikiword-identified-with-delimiters): Set
+ 'hywiki-org-link-type-required' to nil so WikiWords are recognized in Org
+ links without the hy: prefix.
+
+* hywiki.el (hywiki-word-at): Fix to respect the
'hywiki-org-link-type-required'
+ setting and ignore HyWikiWord Org links without a 'hy:' prefix when that
+ variable is non-nil.
+ test/hsys-org-tests.el (hsys-org:org-link-at-p): Avoid failure by forcing
+ the setting of 'hywiki-org-link-type-required' to t.
+
+* hywiki.el (hywiki-debuttonize-non-character-commands): Elaborate contexts
+ where this hook function fires. Rename to
'hywiki-word-store-around-point'.
+ (hywiki-buttonize-non-character-commands): Rename to
+ 'hywiki-word-highlight-post-command'.
+ (hywiki-buttonize-character-commands): Rename to
+ 'hywiki-word-highlight-post-self-insert'.
+ (hywiki--buttonize-characters): Remove, not used.
+
+* hyrolo.el (hyrolo-logical-regexp): Add so regexp can be reused and anchor
+ to start of the search string. Use in 'hyrolo-fgrep' and
+ 'hyrolo-fgrep-logical'.
+
2025-11-18 Mats Lidell <[email protected]>
* test/hmouse-drv-tests.el (hbut-find-exec-shell-cmd-test)
@@ -1746,7 +1773,7 @@
2025-03-23 Mats Lidell <[email protected]>
* test/hywiki-tests.el (hywiki-tests--run-test-case): Run DSL for testing
- Hywiki words.
+ HywikiWords.
(hywiki-tests--lorem-ipsum): Surrounding test text.
(hywiki-tests--verify-hywiki-word): DSL verification helper.
(hywiki-tests--wikiword-step-check-verification)
@@ -2619,7 +2646,7 @@ value to be [[WikiWord]] not
[[file:WikiWord.org][WikiWord]].
* test/hywiki-tests.el (hywiki-tests--a-wikiword-in-hywiki-directory)
(hywiki-tests--wikiword-identified-with-delimiters): Add tests for
- hywiki words with delimiters.
+ HyWikiWords with delimiters.
2024-12-23 Bob Weiner <[email protected]>
@@ -3823,8 +3850,6 @@ value to be [[WikiWord]] not
[[file:WikiWord.org][WikiWord]].
* hywiki.el (hywiki--range): Add to hold (start . end) range values.
(hywiki-word-at): If word is already highlighted with
'hywiki-word-face', use that as a shortcut to get the word.
- (hywiki-buttonize-word): Add.
- (hywiki-maybe-highlight-page-name): Rewrite to use above function.
2024-07-12 Mats Lidell <[email protected]>
@@ -4252,7 +4277,7 @@ value to be [[WikiWord]] not
[[file:WikiWord.org][WikiWord]].
(hywiki-mode): Change all defcustom groups in this library to
'hyperbole-wiki.
(hywiki-excluded-major-modes): Add to exclude major modes and their
- descendents from highlighting and activation of HyWiki words. Default is
nil.
+ descendents from highlighting and activation of HyWikiWords. Default is
nil.
(hywiki-active-in-current-buffer-p): Add and use in 'hywiki'
ibtype.
(hywiki-in-page-p): Add and use where buffer's file is tested
against
'hywiki-directory'.
@@ -4320,7 +4345,7 @@ value to be [[WikiWord]] not
[[file:WikiWord.org][WikiWord]].
call of 'hywiki-buttonize'.
(hywiki-remap-buttonize-characters, hywiki-initialize-mode-map):
Remove these and move keymap init into 'hywiki-mode' definition.
- (hywiki-buttonize): Rewrite to highlight hywiki word to the left of
+ (hywiki-buttonize): Rewrite to highlight HyWikiWord to the left of
point iff last inserted char is in the set of
'hywiki--buttonize-characters'.
Rename to 'hywiki-buttonize-character-commands'.
(hywiki-buttonize-non-character-commands): Add.
@@ -4377,7 +4402,7 @@ value to be [[WikiWord]] not
[[file:WikiWord.org][WikiWord]].
(hywiki-remap-org-insertion-punctuation-keys): Rename to
'hywiki-remap-buttonize-characters'.
(hywiki--buttonize-characters): Add as a computed string of single
- characters that each trigger prior hywiki word highlighting when it is
enabled.
+ characters that each trigger prior HyWikiWord highlighting when it is
enabled.
(hywiki-highlight-page-name, hywiki-highlight-page-names): Don't
skip
back over symbol chars.
(hywiki-find-page): Use this function as the 'find-file-hook'
instead
@@ -4469,7 +4494,7 @@ value to be [[WikiWord]] not
[[file:WikiWord.org][WikiWord]].
(hywiki-get-page-files): Add missing '+' for multiple chars in
file suffix.
(hywiki-at-wikiword, hywiki-highlight-page-names): Allow for
numerics
in #section references.
- (hywiki--word-face): Change foreground of HyWiki word to 'orange'
+ (hywiki--word-face): Change foreground of HyWikiWord to 'orange'
when on a dark background.
2024-04-22 Bob Weiner <[email protected]>
@@ -4477,7 +4502,7 @@ value to be [[WikiWord]] not
[[file:WikiWord.org][WikiWord]].
* hywiki.el: Add new auto-wikiword note-taking system with `hywiki' ibtype.
hasht.el: Temporarily add this for hywiki hash table support.
hibtypes.el (load "hywiki"): Add at lowest ibtype priority.
- hsys-org.el (hsys-org-link-at-p): Support HyWiki word handling.
+ hsys-org.el (hsys-org-link-at-p): Support HyWikiWord handling.
Makefile (EL_COMPILE):
MANIFEST: Add hywiki.el and hasht.el.
diff --git a/hibtypes.el b/hibtypes.el
index 404c839f5e..ce1b8ed7fe 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: 9-Nov-25 at 13:52:10 by Bob Weiner
+;; Last-Mod: 22-Nov-25 at 12:40:34 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -108,6 +108,7 @@
;;; Creates and displays personal wiki pages and sections with auto-wikiword
links
;;; ========================================================================
+;; Defines `hywiki-word' ibtype
(load "hywiki" nil t)
;;; ========================================================================
diff --git a/hsys-org.el b/hsys-org.el
index cbb30882be..a7c5a15ed0 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: 30-Aug-25 at 23:19:35 by Bob Weiner
+;; Last-Mod: 22-Nov-25 at 12:07:13 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -510,10 +510,12 @@ Start and end are the buffer positions of the label of
the link. This
is either the optional description or if none, then the referent, i.e.
either [[referent][description]] or [[referent]].
-Ignore [[hy:HyWiki]] buttons and return nil (handle these as
-implicit buttons). Assume caller has already checked that the
-current buffer is in `org-mode' or is looking for an Org link in
-a non-Org buffer type."
+If point is on a HyWikiWord within an Org link and HyWikiWords are
+recognized in the current buffer, ignore the Org link and return nil
+(handle these elsewhere as implicit buttons).
+
+Assume caller has already checked that the current buffer is in
+`org-mode' or is looking for an Org link in a non-Org buffer type."
(unless (or (smart-eolp) (smart-eobp))
(let (label-start-end)
(if (derived-mode-p 'org-mode)
@@ -521,15 +523,15 @@ a non-Org buffer type."
(when (org-element-property :raw-link (org-element-context))
;; At an Org link
(save-match-data
- ;; If this Org link matches a potential HyWiki word, ignore it.
+ ;; If this Org link matches a potential HyWikiWord, ignore it.
(when (and (not (and (fboundp 'hywiki-word-at) (hywiki-word-at)))
(setq label-start-end (hsys-org-link-label-start-end)))
(cons (nth 1 label-start-end) (nth 2 label-start-end)))))
- ;; non-Org mode (can't call org-element (which
+ ;; Non-Org mode (can't call org-element (which
;; hsys-org-thing-at-p calls) outside of Org mode.
- ;; Check if point is inside a link
+ ;; Check if point is inside a link.
(save-match-data
- ;; If any Org link matches a potential HyWiki word, ignore it.
+ ;; If any Org link matches a potential HyWikiWord, ignore it.
(when (and (not (and (fboundp 'hywiki-word-at) (hywiki-word-at)))
(setq label-start-end (hargs:delimited "[[" "]]" nil nil
t)))
(let* ((start (nth 1 label-start-end))
diff --git a/hyrolo-logic.el b/hyrolo-logic.el
index ecc812a38e..2c900b7f55 100644
--- a/hyrolo-logic.el
+++ b/hyrolo-logic.el
@@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 13-Jun-89 at 22:57:33
-;; Last-Mod: 21-Jun-25 at 22:20:28 by Bob Weiner
+;; Last-Mod: 22-Nov-25 at 07:56:55 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -75,8 +75,8 @@
;;; ************************************************************************
;;;###autoload
-(defun hyrolo-fgrep-logical (expr &optional count-only include-sub-entries
no-sub-entries-out
- koutline-flag)
+(defun hyrolo-fgrep-logical (expr &optional count-only include-sub-entries
+ no-sub-entries-out koutline-flag)
"Display rolo entries matching EXPR.
EXPR is a string that may contain sexpression logical prefix operators.
If optional COUNT-ONLY is non-nil, don't display entries, return
@@ -111,16 +111,16 @@ Double quotes may be used to group multiple words as a
single argument."
(read expr) count-only include-sub-entries
no-sub-entries-out t))
(setq total-matches (eval (read expr))))
- ((string-match-p "\(\\(r-\\)?\\(and\\|or\\|xor\\|not\\)\\>" expr)
- (setq expr (replace-regexp-in-string "\(or " "\(| " expr nil t))
- (setq expr (replace-regexp-in-string "\(xor " "\(@ " expr nil t))
- (setq expr (replace-regexp-in-string "\(not " "\(! " expr nil t))
- (setq expr (replace-regexp-in-string "\(and " "\(& " expr nil t))
+ ((string-match-p hyrolo-logical-regexp expr)
+ (setq expr (replace-regexp-in-string "(or " "(| " expr nil t))
+ (setq expr (replace-regexp-in-string "(xor " "(@ " expr nil t))
+ (setq expr (replace-regexp-in-string "(not " "(! " expr nil t))
+ (setq expr (replace-regexp-in-string "(and " "(& " expr nil t))
- (setq expr (replace-regexp-in-string "\(r-or " "\(r-| " expr nil t))
- (setq expr (replace-regexp-in-string "\(r-xor " "\(r-@ " expr nil t))
- (setq expr (replace-regexp-in-string "\(r-not " "\(r-! " expr nil t))
- (setq expr (replace-regexp-in-string "\(r-and " "\(r-& " expr nil t))
+ (setq expr (replace-regexp-in-string "(r-or " "(r-| " expr nil t))
+ (setq expr (replace-regexp-in-string "(r-xor " "(r-@ " expr nil t))
+ (setq expr (replace-regexp-in-string "(r-not " "(r-! " expr nil t))
+ (setq expr (replace-regexp-in-string "(r-and " "(r-& " expr nil t))
(setq expr (replace-regexp-in-string
"\"\\([^\"]*\\)\"" "{\\1}" expr nil nil))
@@ -134,15 +134,15 @@ Double quotes may be used to group multiple words as a
single argument."
(setq saved-expr expr)))
(setq expr (replace-regexp-in-string
"{\\([^{}]+\\)}" "\"\\1\"" expr nil nil))
- (setq expr (replace-regexp-in-string "\(| " "\(hyrolo-or start end
" expr nil t))
- (setq expr (replace-regexp-in-string "\(@ " "\(hyrolo-xor start end
" expr nil t))
- (setq expr (replace-regexp-in-string "\(! " "\(hyrolo-not start end
" expr nil t))
- (setq expr (replace-regexp-in-string "\(& " "\(hyrolo-and start end
" expr nil t))
-
- (setq expr (replace-regexp-in-string "\(r-| " "\(hyrolo-r-or start
end " expr nil t))
- (setq expr (replace-regexp-in-string "\(r-@ " "\(hyrolo-r-xor start
end " expr nil t))
- (setq expr (replace-regexp-in-string "\(r-! " "\(hyrolo-r-not start
end " expr nil t))
- (setq expr (replace-regexp-in-string "\(r-& " "\(hyrolo-r-and start
end " expr nil t))
+ (setq expr (replace-regexp-in-string "(| " "(hyrolo-or start end "
expr nil t))
+ (setq expr (replace-regexp-in-string "(@ " "(hyrolo-xor start end "
expr nil t))
+ (setq expr (replace-regexp-in-string "(! " "(hyrolo-not start end "
expr nil t))
+ (setq expr (replace-regexp-in-string "(& " "(hyrolo-and start end "
expr nil t))
+
+ (setq expr (replace-regexp-in-string "(r-| " "(hyrolo-r-or start end
" expr nil t))
+ (setq expr (replace-regexp-in-string "(r-@ " "(hyrolo-r-xor start
end " expr nil t))
+ (setq expr (replace-regexp-in-string "(r-! " "(hyrolo-r-not start
end " expr nil t))
+ (setq expr (replace-regexp-in-string "(r-& " "(hyrolo-r-and start
end " expr nil t))
(setq expr (format "(hyrolo-logic (quote %S) nil %s %s %s %s)"
(read expr) count-only include-sub-entries
diff --git a/hyrolo.el b/hyrolo.el
index 32726d2720..c068fd1511 100644
--- a/hyrolo.el
+++ b/hyrolo.el
@@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 7-Jun-89 at 22:08:29
-;; Last-Mod: 9-Nov-25 at 13:31:08 by Bob Weiner
+;; Last-Mod: 22-Nov-25 at 07:54:28 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -139,6 +139,10 @@
;;; Public variables
;;; ************************************************************************
+(defvar hyrolo-logical-regexp
+ "\\`(\\(r-\\)?\\(and\\|or\\|xor\\|not\\)\\>"
+ "Regexp matching the beginning of a HyRolo logical search string.")
+
(defvar hyrolo-boolean-only-flag nil
"Set to prevent HyRolo from displaying an error buffer when running tests.
Return a boolean only, indicating whether the test passed or not.
@@ -744,7 +748,7 @@ on the logical sexpression matching."
(cadr input-and-matching-files)))))
(setq string (string-trim string "\"" "\""))
(let ((total-matches 0))
- (if (string-match-p "\(\\(r-\\)?\\(and\\|or\\|xor\\|not\\)\\>" string)
+ (if (string-match-p hyrolo-logical-regexp string)
(progn
;; Search string contains embedded logic operators.
;; First try to match logical sexpression within a single
diff --git a/hywiki.el b/hywiki.el
index fd30f92674..aed1f7ba0c 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: 2-Nov-25 at 17:09:25 by Mats Lidell
+;; Last-Mod: 22-Nov-25 at 13:09:38 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -53,7 +53,7 @@
;; prefix, e.g. [[MyWikiWord]]; existing HyWiki page names then will
;; override Org's standard handling of such links. To prevent Org
;; mode's binding of {M-RET} from splitting lines and creating new
-;; headlines when on a HyWiki word whose page has not yet been
+;; headlines when on a HyWikiWord whose page has not yet been
;; created, set `hsys-org-enable-smart-keys' to `t' so that
;; Hyperbole's Action Key does the right thing in this context.
;;
@@ -195,13 +195,10 @@ The `pre-command-hook' saves this value for a buffer and
`post-command-hook'
checks it to determine if any buffer modification has occurred or not.")
;; Must be set after `hywiki-get-buttonize-characters' is defined
-(defvar hywiki--buttonize-characters nil
- "String of single character keys bound to
`hywiki-buttonize-character-commands'.
-Each such key self-inserts before highlighting any prior HyWiki word
-in `hywiki-mode'.")
-
(defvar hywiki--buttonize-character-regexp nil
- "Regexp matching a single separating character following a HyWiki word.")
+ "Regexp matching a single separating character following a HyWikiWord.
+Each such key self-inserts before highlighting any prior HyWikiWord
+in `hywiki-mode'.")
(defvar hywiki--word-and-buttonize-character-regexp nil
"Regexp matching HyWikiWord#section plus a valid word separating character.
@@ -276,7 +273,7 @@ highlighted nor treated as hyperlinks; they are handled
normally by Org."
:group 'hyperbole-hywiki)
(defcustom hywiki-exclude-major-modes nil
- "List of major modes to exclude from HyWiki word highlighting and
recognition."
+ "List of major modes to exclude from HyWikiWord highlighting and
recognition."
:type '(list symbol)
:group 'hyperbole-hywiki)
@@ -372,7 +369,7 @@ Presently, there are no key bindings; this is for future
use.")
(defvar hywiki-org-link-type-required t
"When t, [[hy:HyWiki Org links]] must start with `hywiki-org-link-type':.
-Otherwise, this prefix is not needed and HyWiki word Org links
+Otherwise, this prefix is not needed and HyWikiWord Org links
override standard Org link lookups. See \"(org)Internal Links\".")
(defcustom hywiki-org-publishing-broken-links 'mark
@@ -477,12 +474,12 @@ Nil by default."
(defconst hywiki-word-regexp
"\\<\\([[:upper:]][[:alpha:]]+\\)\\>"
- "Regexp that matches a HyWiki word only.
+ "Regexp that matches a HyWikiWord only.
Do not use a start or end line/string anchor in this regexp.")
(defconst hywiki-word-section-regexp
"\\(#[^][# \t\n\r\f]+\\)"
- "Regexp that matches a non-delimited HyWiki word #section extension.
+ "Regexp that matches a non-delimited HyWikiWord #section extension.
After the first # character, this may contain any non-square-bracket,
non-# and non-whitespace characters.")
@@ -494,11 +491,11 @@ Group 4 is the optional 0-based column number.")
(defconst hywiki-word-with-optional-suffix-regexp
(concat hywiki-word-regexp hywiki-word-section-regexp "??"
hywiki-word-line-and-column-numbers-regexp "?")
- "Regexp for a HyWiki word with an optional #section, :Lline-num, :Ccol-num.
+ "Regexp for a HyWikiWord with an optional #section, :Lline-num, :Ccol-num.
Section may not contain whitespace or square brackets. Use '-' to
substitute for spaces in the section/headline name.
-Group 1 is the HyWiki word.
+Group 1 is the HyWikiWord.
Group 2 is any optional #section with the # included.
Group 4 is any optional 1-based line number to jump to for any
file-based referents (relative to any section given).
@@ -508,12 +505,12 @@ file-based referents.")
(defconst hywiki-word-with-optional-suffix-exact-regexp
(concat "\\`" hywiki-word-regexp "\\(#[^][#\n\r\f]+\\)??"
hywiki-word-line-and-column-numbers-regexp "?\\'")
- "Exact match regexp for a HyWiki word with an optional #section.
+ "Exact match regexp for a HyWikiWord with an optional #section.
The section may contain spaces or tabs but not square brackets;
it is preferable, however, to substitute '-' for whitespace in
the section/headline name to simplify recognition.
-Group 1 is the HyWiki word.
+Group 1 is the HyWikiWord.
Group 2 is any optional #section with the # included.
Group 4 is any optional 1-based line number to jump to for any
file-based referents (relative to any section given).
@@ -530,11 +527,11 @@ of reference and group two is the rest of the suffix
reference.")
(((background dark)) (:background "orange" :foreground "black" :underline
t))
(((min-colors 88)) (:foreground "orange" :underline t))
(t (:background "orange" :underline t)))
- "Face for HyWiki word highlighting."
+ "Face for HyWikiWord highlighting."
:group 'hyperbole-hywiki)
(defcustom hywiki-word-face 'hywiki--word-face
- "Hyperbole face for HyWiki word highlighting."
+ "Hyperbole face for HyWikiWord highlighting."
:initialize #'custom-initialize-default
:type 'face
:group 'hyperbole-hywiki)
@@ -560,10 +557,11 @@ Non-nil is the default."
;;; hywiki minor mode and text edit command hooks
;;; ************************************************************************
-(defun hywiki-debuttonize-non-character-commands ()
- "Store any HyWikiWord before or after point for later comparison.
-Triggered by `pre-command-hook' for non-character -commands, including
-deletion commands and those in `hywiki-non-character-commands'."
+(defun hywiki-word-store-around-point ()
+ "Store any HyWikiWord before or after point for post-command comparison.
+HyWikiWords are stored only outside of `hywiki-non-hook-context-p' contexts.
+This is triggered by `pre-command-hook' for non-character commands,
+including deletion commands and those in `hywiki-non-character-commands'."
;; (when ert--running-tests
;; (message "Running pre-command-hook..."))
(setq hywiki--buffer-modified-tick (buffer-modified-tick)
@@ -594,7 +592,7 @@ deletion commands and those in
`hywiki-non-character-commands'."
(set-marker hywiki--buttonize-end end)
start))))
-(defun hywiki-buttonize-character-commands ()
+(defun hywiki-word-highlight-post-self-insert ()
"Turn any HyWikiWords around point into highlighted Hyperbole buttons.
Triggered by `post-self-insert-hook' after self-inserting one or
more characters while the command is still executing. The
@@ -648,7 +646,7 @@ more characters while the command is still executing. The
(hywiki--maybe-rehighlight-at-point))))
-(defun hywiki-buttonize-non-character-commands ()
+(defun hywiki-word-highlight-post-command ()
"Highlight any HyWikiWord before or after point as a Hyperbole button.
Triggered by `post-command-hook' for non-character-commands, including
deletion commands and those in `hywiki-non-character-commands'."
@@ -715,14 +713,6 @@ deletion commands and those in
`hywiki-non-character-commands'."
(hywiki--maybe-rehighlight-at-point)))))))
-(defun hywiki-buttonize-word (func start end face)
- "Create a HyWikiWord button by calling FUNC with START and END positions.
-Function may apply FACE to highlight the button or may transform it
-into an Org link, etc. Function operates on the current buffer and
-takes 3 arguments: `range-start', `range-end' and `face' to apply to
-the button."
- (funcall func start end face))
-
(defun hywiki-get-buttonize-characters ()
"Return a string of Org self-insert keys that have punctuation/symbol
syntax."
(let (key
@@ -1007,7 +997,7 @@ with the referent."
;;; ************************************************************************
(defun hywiki-active-in-current-buffer-p ()
- "Return non-nil if HyWiki word links are active in the current buffer.
+ "Return non-nil if HyWikiWord links are active in the current buffer.
Exclude the minibuffer if selected and return nil."
(and hywiki-word-highlight-flag
(not (minibuffer-window-active-p (selected-window)))
@@ -1526,7 +1516,7 @@ omit any trailing colon and space in the prompt."
"Grep HyWiki dir")))))
(defun hywiki-references-to-org-links ()
- "Convert all highlighted HyWiki words in current buffer to Org links.
+ "Convert all highlighted HyWikiWords in current buffer to Org links.
Org publishing is then used to convert HyWiki files to other formats such
as html.
@@ -1606,8 +1596,8 @@ simplifies to:
(format "[[%s:%s]]" hywiki-org-link-type reference)))))))
(defun hywiki-maybe-at-wikiword-beginning ()
- "Return non-nil if previous character is one preceding a HyWiki word.
-Do not test whether or not a page exists for the HyWiki word.
+ "Return non-nil if previous character is one preceding a HyWikiWord.
+Do not test whether or not a page exists for the HyWikiWord.
Use `hywiki-get-referent' to determine whether a HyWiki page exists."
;; Ignore wikiwords preceded by any non-whitespace character, except
;; any of these: [({<"'`'
@@ -2363,7 +2353,7 @@ disabled. Highlight/dehighlight HyWiki page buffers
whenever the
value of `hywiki-word-highlight-flag' is changed."
(interactive (when (use-region-p) (list (region-beginning) (region-end))))
;; Avoid doing many lets for efficiency.
- ;; Highlight HyWiki words throughout buffers where `hywiki-mode' is enabled
+ ;; Highlight HyWikiWords throughout buffers where `hywiki-mode' is enabled
;; or HyWiki pages below `hywiki-directory' whenever displayed in a window.
(if (hywiki-active-in-current-buffer-p)
(unless (and (or (and (null region-start) (null region-end))
@@ -2497,7 +2487,7 @@ the current page unless they have sections attached."
(defun hywiki-in-page-p ()
"Return non-nil if the current buffer is a HyWiki page.
If this is a HyWiki page and `hywiki-word-highlight-flag' is non-nil
-\(the default), also enable auto-highlighting of HyWiki words as they
+\(the default), also enable auto-highlighting of HyWikiWords as they
are typed in the buffer."
(or hywiki-page-flag
(and buffer-file-name
@@ -2584,7 +2574,7 @@ regexps of wikiwords, if the hash table is out-of-date."
(hywiki-make-referent-hasht))
(unless hywiki--any-wikiword-regexp-list
;; Compute these expensive regexps (matching 50
- ;; hywiki words at a time) only if the set of
+ ;; HyWikiWords at a time) only if the set of
;; HyWikiWords changed in `hywiki-directory'.
(setq hywiki--any-wikiword-regexp-list
(mapcar (lambda (wikiword-sublist)
@@ -2931,7 +2921,7 @@ hywikiword suffix); otherwise:
referent))))
(defun hywiki-org-link-store ()
- "Store a link to a HyWiki word at point, if any."
+ "Store a link to a HyWikiWord at point, if any."
(when (hywiki-word-at)
(let* ((page-name (hywiki-word-at))
(link (concat
@@ -3003,12 +2993,12 @@ Customize this directory with:
"Return the HyWikiWord at point or optional HyWiki WORD, if has a referent.
If no such referent exists, return nil.
-Word may be of form:
+The HyWikiWord may be of the form:
1. HyWikiWord#section with an optional #section.
2. If WORD is the symbol, :range, and there is a HyWikiWord at point
- with an existing referent, return the tuple of values: (word
- word-start word-end) instead of the word; otherwise, return the tuple
- \='(nil nil nil).
+ with an existing referent, return the tuple of values: \='(<word>
+ <word-start> <word-end>) instead of the word; otherwise, return the
+ tuple \='(nil nil nil).
When using the word at point, a call to `hywiki-active-in-current-buffer-p'
at point must return non-nil or this function will return nil."
@@ -3118,7 +3108,7 @@ With optional RANGE-FLAG, return a list of (HyWikiWord
start-position
end-position); the positions include the entire
HyWikiWord#section:Lnum:Cnum string but exclude any delimiters.
-This does not test whether a referent exists for the HyWiki word; call
+This does not test whether a referent exists for the HyWikiWord; call
`hywiki-referent-exists-p' without an argument for that.
A call to `hywiki-active-in-current-buffer-p' at point must return non-nil
@@ -3144,7 +3134,7 @@ With optional RANGE-FLAG, return a list of (HyWikiWord
start-position
end-position); the positions include the entire
HyWikiWord#section:Lnum:Cnum string but exclude any delimiters.
-This does not test whether a referent exists for the HyWiki word; call
+This does not test whether a referent exists for the HyWikiWord; call
`hywiki-referent-exists-p' without an argument for that.
A call to `hywiki-active-in-current-buffer-p' at point must return
@@ -3154,40 +3144,49 @@ non-nil or this will return nil."
;; First look for an Org-type [[hy:WikiWord]] reference.
;; Don't use `cl-destructuring-bind' here since the `hargs:delimited'
call
;; can return nil rather than the 3 arg list that would be required
- (let* ((wikiword-start-end
- (let ((start-regexp (concat "\\[\\[\\(" hywiki-org-link-type
":\\)?")))
- (save-excursion
- (skip-chars-backward (concat hywiki-org-link-type ":["))
- (when (looking-at start-regexp)
- (goto-char (match-end 0)))
+ (let* ((start-regexp (concat "\\[\\[\\(" hywiki-org-link-type ":\\)?"))
+ (opoint (point))
+ (hywiki-org-link-type-flag)
+ (wikiword-start-end
+ (save-excursion
+ (skip-chars-backward (concat hywiki-org-link-type ":["))
+ (when (looking-at start-regexp)
+ (setq hywiki-org-link-type-flag (match-string 1))
+ (goto-char opoint)
+ ;; This next line drops any `hywiki-org-link-type': from the
+ ;; start of the WikiWord since it is part of the delimiter
used.
(hargs:delimited (concat "\\[\\[\\(" hywiki-org-link-type
":\\)?")
"\\(\\]\\[\\|\\]\\]\\)" t t t))))
(wikiword (nth 0 wikiword-start-end))
(start (nth 1 wikiword-start-end))
(end (nth 2 wikiword-start-end)))
+
(with-syntax-table hywiki--org-mode-syntax-table
(if (and (cond (wikiword
- ;; Handle an Org link [[HyWikiWord]]
[[hy:HyWikiWord]]
- ;; or [[HyWikiWord#section][Description Text]].
- ;; Get the HyWikiWord link reference, ignoring any
- ;; description given in the link.
- ;;
- ;; Don't use next line so don't have to load all of
Org
- ;; mode just to check for HyWikiWords; however,
- ;; ignoring this disables support for Org mode
aliases.
- ;; (setq wikiword (org-link-expand-abbrev
(org-link-unescape (string-trim wikiword))))
- (setq wikiword (hywiki-strip-org-link wikiword))
- (when (and wikiword end)
- ;; Update start and end to newly stripped
- ;; string positions
- (save-excursion
- (save-restriction
- (narrow-to-region start end)
- (goto-char (point-min))
- (when (search-forward wikiword nil t)
- (setq start (match-beginning 0)
- end (match-end 0))))))
- (hywiki-word-is-p wikiword))
+ ;; Enforce `hywiki-org-link-type-required' setting
+ (unless (and hywiki-org-link-type-required
+ (not hywiki-org-link-type-flag))
+ ;; Handle an Org link [[HyWikiWord]]
[[hy:HyWikiWord]]
+ ;; or [[HyWikiWord#section][Description Text]].
+ ;; Get the HyWikiWord link reference, ignoring any
+ ;; description given in the link.
+ ;;
+ ;; Don't use next line so don't have to load all
of Org
+ ;; mode just to check for HyWikiWords; however,
+ ;; ignoring this disables support for Org mode
aliases.
+ ;; (setq wikiword (org-link-expand-abbrev
(org-link-unescape (string-trim wikiword))))
+ (setq wikiword (hywiki-strip-org-link wikiword))
+ (when (and wikiword end)
+ ;; Update start and end to newly stripped
+ ;; string positions
+ (save-excursion
+ (save-restriction
+ (narrow-to-region start end)
+ (goto-char (point-min))
+ (when (search-forward wikiword nil t)
+ (setq start (match-beginning 0)
+ end (match-end 0))))))
+ (hywiki-word-is-p wikiword)))
;; Handle a delimited HyWikiWord reference with
;; multiple, possibly whitespace-separated words in
@@ -3357,7 +3356,7 @@ at a HyWikiWord, return \\='(nil nil nil).
This works regardless of whether the HyWikiWord has been highlighted
or not.
-This does not test whether a referent exists for the HyWiki word; call
+This does not test whether a referent exists for the HyWikiWord; call
`hywiki-referent-exists-p' without an argument for that.
A call to `hywiki-active-in-current-buffer-p' at point must return
@@ -3393,7 +3392,7 @@ Return t if the highlighted range exists at point and
gets moved."
Point should be on the HyWikiWord itself. Suffix is anything after
the # symbol.
-This does not test whether a referent exists for the HyWiki word; call
+This does not test whether a referent exists for the HyWikiWord; call
`hywiki-referent-exists-p' without an argument for that.
A call to `hywiki-active-in-current-buffer-p' at point must return non-nil
@@ -3516,9 +3515,9 @@ auto-highlighting."
;; enable
(progn
(when hywiki-word-highlight-flag
- (add-hook 'pre-command-hook
'hywiki-debuttonize-non-character-commands 95)
- (add-hook 'post-command-hook
'hywiki-buttonize-non-character-commands 95)
- (add-hook 'post-self-insert-hook 'hywiki-buttonize-character-commands)
+ (add-hook 'pre-command-hook 'hywiki-word-store-around-point 95)
+ (add-hook 'post-command-hook 'hywiki-word-highlight-post-command
95)
+ (add-hook 'post-self-insert-hook
'hywiki-word-highlight-post-self-insert)
(add-hook 'window-buffer-change-functions
'hywiki-maybe-highlight-wikiwords-in-frame)
(add-to-list 'yank-handled-properties
@@ -3529,10 +3528,10 @@ auto-highlighting."
(message "HyWikiWord page auto-highlighting enabled")
(message "`hywiki-word-highlight-flag' must first be set to t to
enable auto-highlighting"))))
;; disable
- (remove-hook 'pre-command-hook
'hywiki-debuttonize-non-character-commands)
- (remove-hook 'post-command-hook
'hywiki-buttonize-non-character-commands)
- (remove-hook 'post-self-insert-hook 'hywiki-buttonize-character-commands)
- (hywiki-mode 0) ;; also dehighlights HyWiki words outside of HyWiki pages
+ (remove-hook 'pre-command-hook 'hywiki-word-store-around-point)
+ (remove-hook 'post-command-hook 'hywiki-word-highlight-post-command)
+ (remove-hook 'post-self-insert-hook
'hywiki-word-highlight-post-self-insert)
+ (hywiki-mode 0) ;; also dehighlights HyWikiWords outside of HyWiki pages
(remove-hook 'window-buffer-change-functions
'hywiki-maybe-highlight-wikiwords-in-frame)
(hywiki-maybe-highlight-wikiwords-in-frame t)
@@ -3812,12 +3811,11 @@ This must be called within a `save-excursion' or it may
move point."
;;; ************************************************************************
;; Must be set after `hywiki-get-buttonize-characters' is defined
-(unless hywiki--buttonize-characters
- (setq hywiki--buttonize-characters
- (concat "[]()<>{}\"' \t\r\n" (hywiki-get-buttonize-characters))
- hywiki--buttonize-character-regexp
+(unless hywiki--buttonize-character-regexp
+ (setq hywiki--buttonize-character-regexp
(concat "\\([]["
- (regexp-quote (substring hywiki--buttonize-characters 2))
+ (regexp-quote (concat "()<>{}\"' \t\r\n"
+ (hywiki-get-buttonize-characters)))
"]\\|$\\)")
hywiki--word-and-buttonize-character-regexp
(concat "\\(" hywiki-word-with-optional-suffix-regexp "\\)"
diff --git a/hywiki/HyWiki.org b/hywiki/HyWiki.org
index 29ed6e5f99..009fb89ac5 100644
--- a/hywiki/HyWiki.org
+++ b/hywiki/HyWiki.org
@@ -44,7 +44,7 @@ buffer by surrounding them with double square brackets and the
prefix, e.g. [[MyWikiWord]]; existing HyWiki page names then will
override Org's standard handling of such links. To prevent Org
mode's binding of {M-RET} from splitting lines and creating new
-headlines when on a HyWiki word whose page has not yet been
+headlines when on a HyWikiWord whose page has not yet been
created, set `hsys-org-enable-smart-keys' to `t' so that
Hyperbole's Action Key does the right thing in this context.
diff --git a/man/hyperbole.texi b/man/hyperbole.texi
index 5c97c49c72..05510fbabe 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: 29-Aug-25 at 03:42:13 by Bob Weiner
+@c Last-Mod: 22-Nov-25 at 10:36:49 by Bob Weiner
@c %**start of header (This is for running Texinfo on a region.)
@setfilename hyperbole.info
@@ -2527,7 +2527,7 @@ minibuffer or the other window.
@cindex hywiki existing word
@anchor{hywiki-existing-word}
@item hywiki-existing-word
-When on a HyWiki word with an existing page, display its page and
+When on a HyWikiWord with an existing page, display its page and
optional section.
@findex ibtypes action
@@ -3104,7 +3104,7 @@ source reference line again.
@cindex hywiki word
@anchor{hywiki-word}
@item hywiki-word
-When on a HyWiki word, display its page and optional section. If the
+When on a HyWikiWord, display its page and optional section. If the
associated HyWiki page does not exist, create it automatically.
@findex ibtypes hynote-file
diff --git a/test/hsys-org-tests.el b/test/hsys-org-tests.el
index db5e7dac95..a10103c3dc 100644
--- a/test/hsys-org-tests.el
+++ b/test/hsys-org-tests.el
@@ -3,7 +3,7 @@
;; Author: Mats Lidell <[email protected]>
;;
;; Orig-Date: 23-Apr-21 at 20:55:00
-;; Last-Mod: 15-Sep-25 at 20:07:53 by Mats Lidell
+;; Last-Mod: 22-Nov-25 at 12:07:27 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -66,28 +66,29 @@
(ert-deftest hsys-org:org-link-at-p ()
"Should be t if point is within an org-link."
(with-temp-buffer
- ;; Org-mode
- (org-mode)
- (insert "[[Link]]\n\n")
- (ert-info ("Within an org link")
+ (let ((hywiki-org-link-type-required t))
+ ;; Org-mode
+ (org-mode)
+ (insert "[[Link]]\n\n")
+ (ert-info ("Within an org link")
+ (goto-char 3)
+ (should (hsys-org-link-at-p)))
+ (ert-info ("At end of line")
+ (end-of-line)
+ (should-not (hsys-org-link-at-p)))
+ (ert-info ("At end of buffer")
+ (end-of-buffer)
+ (should-not (hsys-org-link-at-p)))
+ ;; Out side of org-mode
+ (erase-buffer)
+ (fundamental-mode)
+ (insert "[[hy:HyWiki]]\n\n")
(goto-char 3)
- (should (hsys-org-link-at-p)))
- (ert-info ("At end of line")
- (end-of-line)
- (should-not (hsys-org-link-at-p)))
- (ert-info ("At end of buffer")
- (end-of-buffer)
- (should-not (hsys-org-link-at-p)))
- ;; Out side of org-mode
- (erase-buffer)
- (fundamental-mode)
- (insert "[[hy:HyWiki]]\n\n")
- (goto-char 3)
- (ert-info ("Accept link if unknown HyWiki button")
- (should (hsys-org-link-at-p)))
- (ert-info ("Ignore link if known HyWiki button")
- (mocklet (((hywiki-word-at) => t))
- (should-not (hsys-org-link-at-p))))))
+ (ert-info ("Accept link if unknown HyWiki button")
+ (should (hsys-org-link-at-p)))
+ (ert-info ("Ignore link if known HyWiki button")
+ (mocklet (((hywiki-word-at) => t))
+ (should-not (hsys-org-link-at-p)))))))
(ert-deftest hsys-org:org-target-at-p ()
"Should be non nil if point is within an org-radio-target."
diff --git a/test/hywiki-tests.el b/test/hywiki-tests.el
index 5c84525700..4fdfdb1589 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: 16-Nov-25 at 11:09:20 by Bob Weiner
+;; Last-Mod: 22-Nov-25 at 13:35:42 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -323,8 +323,10 @@ This is for simulating the command loop."
(should (string= "WikiWord" (hywiki-word-at)))
(delete-other-windows)
(assist-key)
- (other-window 1)
- (should (string-prefix-p "*Help: Hyperbole " (buffer-name))))
+ (should (get-window-with-predicate
+ (lambda (win) (string-prefix-p "*Help: Hyperbole "
+ (buffer-name
+ (window-buffer win)))))))
(hywiki-tests--delete-hywiki-dir-and-buffer hywiki-directory)))))
(ert-deftest hywiki-tests--action-key-on-wikiword-displays-page ()
@@ -441,6 +443,7 @@ line 2
"Verify WikiWord is identified when surrounded by delimiters."
(hywiki-tests--preserve-hywiki-mode
(let ((hsys-org-enable-smart-keys t)
+ (hywiki-org-link-type-required nil)
(hywiki-directory (make-temp-file "hywiki" t)))
(unwind-protect
(progn
@@ -496,8 +499,8 @@ line 2
(font-lock-ensure)
(should (hsys-org-face-at-p 'org-link))
(if (string= "WikiWord" (hywiki-word-at))
- (should-not v)
- (should t)))))
+ (should v)
+ (should-not v)))))
(hywiki-mode 0)
(hywiki-tests--delete-hywiki-dir-and-buffer hywiki-directory)))))
@@ -1958,7 +1961,7 @@ face is verified during the change."
(hywiki-tests--delete-hywiki-dir-and-buffer hywiki-directory)))))
(ert-deftest hywiki-tests--verify-removal-of-delimiter-updates-face ()
- "Verify removing a delimiter the face is changed along with the WikiWord."
+ "Verify WikiWord highlight face change when adding/removing a delimiter."
:expected-result :failed
(hywiki-tests--preserve-hywiki-mode
(let* ((hywiki-directory (make-temp-file "hywiki" t))