branch: externals/hyperbole
commit a34f43c939161bc9bd052dcb2636d5c074e45c51
Author: bw <[email protected]>
Commit: bw <[email protected]>
hywiki-completion-at-point - Fix to use completion tables with Corfu
hywiki-maybe-highlight-wikiwords-in-frame - Ignore any child/popup
windows such as those used by the posframe package. Vertico and Corfu
may also use these. Fixes gh#issue-863.
hsys-org-fix-version - Use 'find-library--from-load-history' on
"org-loaddefs" to get actual dir defs were loaded from, not using
current 'load-path'.
hywiki-mode - Prevent def of a customizable variable for this mode.
---
ChangeLog | 20 ++++++++++++++-
hproperty.el | 1 +
hsys-org.el | 8 +++---
hywiki.el | 83 ++++++++++++++++++++++++++++++------------------------------
4 files changed, 66 insertions(+), 46 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ccf8f395e4..8d79dd075b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2026-02-14 Bob Weiner <[email protected]>
+
+* hsys-org.el (hsys-org-fix-version): Use 'find-library--from-load-history' on
+ "org-loaddefs" to get actual dir defs were loaded from, not using current
+ 'load-path'.
+
+* hywiki.el (hywiki-maybe-highlight-wikiwords-in-frame): Ignore any child/popup
+ windows such as those used by the posframe package. Vertico and Corfu may
+ also use these.
+ (hywiki-completion-at-point): Fix to use completion tables for use
+ with the Corfu in-buffer completion package.
+ (hywiki-completion-at-point): Fix to return all existing
HyWikiWords,
+ not just those with pages but of any referent type.
+ (hywiki-company-hasht-backend): Remove in favor of above generic
function.
+ (hywiki-mode): Prevent def of a customizable variable for this mode.
+ Use the 'hwyiki-mode' function to affect the state of the variable of the
same name.
+ (hywiki-word-from-reference): Improve doc string.
+
2026-02-12 Bob Weiner <[email protected]>
* hywiki.el (hywiki-word-add-completion-at-point): Add in-buffer
@@ -9,7 +27,7 @@
2026-02-11 Bob Weiner <[email protected]>
-* hywiki.el (hywiki-word-at): Add optional 2nd arg, 'pound-sign-only-flag'
+* hywiki.el (hywiki-word-at): Add optional 2nd arg, 'hash-sign-only-flag'
to allow matching to a WikiWord# without any heading name for use when
completing on headings.
(hywiki-completion-at-point,
diff --git a/hproperty.el b/hproperty.el
index c083f8ac3c..38b6d8d6f7 100644
--- a/hproperty.el
+++ b/hproperty.el
@@ -22,6 +22,7 @@
(eval-when-compile
(require 'subr-x)) ; For when-let* in Emacs 28.2
(require 'hload-path)
+(require 'hbut)
;;; ************************************************************************
;;; Public declarations
diff --git a/hsys-org.el b/hsys-org.el
index add084ecf7..8a6db8dc7f 100644
--- a/hsys-org.el
+++ b/hsys-org.el
@@ -33,7 +33,7 @@
(eval-when-compile (require 'hmouse-drv))
(require 'hargs) ;; for `hargs:delimited-p'
(require 'hproperty) ;; requires 'hbut
-(require 'hsys-consult)
+(require 'hsys-consult) ;; requires 'find-func
(require 'hypb)
(require 'org)
(require 'org-element)
@@ -264,8 +264,9 @@ Return t if Org is reloaded, else nil."
(setq org--inhibit-version-check nil
org-list-allow-alphabetical nil)
(let ((org-dir (ignore-errors (org-find-library-dir "org")))
+ ;; Use the loadhist to get the path Org defs were loaded from
(org-install-dir
- (ignore-errors (org-find-library-dir "org-loaddefs"))))
+ (ignore-errors (find-library--from-load-history "org-loaddefs"))))
(cond ((and org-dir org-install-dir (string-equal org-dir org-install-dir)
;; Still may have a situation where the Org version matches the
;; builtin Org but the directories are for a newer Org
@@ -300,8 +301,7 @@ Return t if Org is reloaded, else nil."
(package-initialize))
;; Ensure Org folding is configured for `reveal-mode' compatibility
(hsys-org--set-fold-style)
- (let ((pkg-desc (car (cdr (assq 'org package-archive-contents)))))
- (package-activate pkg-desc t))
+ (package-activate 'org t)
;; Load org libraries with right path but save "org" for last
(mapc #'load (remove "org" org-libraries-to-reload))
diff --git a/hywiki.el b/hywiki.el
index c0a0ca3476..aa4d6e5fd3 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: 12-Feb-26 at 00:30:44 by Bob Weiner
+;; Last-Mod: 14-Feb-26 at 22:49:32 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -152,10 +152,6 @@
(require 'subr-x) ;; For `string-remove-prefix'
(require 'thingatpt)
-(eval-and-compile
- '(when (require 'company nil t)
- (add-to-list 'company-backends 'hywiki-company-hasht-backend)))
-
;;; ************************************************************************
;;; Public declarations
;;; ************************************************************************
@@ -407,12 +403,12 @@ where PATH is the un-resolvable reference."
:type 'string
:group 'hyperbole-hywiki)
-(defun hywiki--preparation-function (_project-plist)
+(defun hywiki--export-preparation-function (_project-plist)
"Setup export hook functions."
(message "Hywiki export is in preparation.")
(add-hook 'org-export-before-parsing-functions #'hywiki-org-export-function))
-(defun hywiki--completion-function (_project-plist)
+(defun hywiki--export-completion-function (_project-plist)
"Remove export hook function."
(remove-hook 'org-export-before-parsing-functions
#'hywiki-org-export-function)
(message "Hywiki export is completed."))
@@ -425,8 +421,8 @@ where PATH is the un-resolvable reference."
hywiki-org-publish-project-alist
(list
"hywiki"
- :preparation-function 'hywiki--preparation-function
- :completion-function 'hywiki--completion-function
+ :preparation-function 'hywiki--export-preparation-function
+ :completion-function 'hywiki--export-completion-function
:auto-sitemap t
:base-directory (expand-file-name hywiki-directory)
:html-head (format
@@ -824,6 +820,9 @@ See the Info documentation at \"(hyperbole)HyWiki\".
:lighter hywiki-mode-lighter
:keymap hywiki-mode-map
:group 'hyperbole-hywiki
+ ;; Prevent definition of a custom-variable since it makes no sense to
+ ;; customize this variable.
+ :variable hywiki-mode
(progn
(unless hywiki-mode-map
(setq hywiki-mode-map (make-sparse-keymap)))
@@ -1463,17 +1462,30 @@ Ensures that selecting a completion replaces only the
text after the '#'."
;; 2. Validate the WikiWord and page existence
(when (and (not (string-empty-p word))
(file-readable-p page))
- (let ((headings (hywiki-get-page-headings page)))
- ;; 3. Return completion data
- (list (1+ hash-pos) ;; START: Right after '#'
- opoint ;; END: Current cursor
- headings ;; CANDIDATES
- :exclusive 'no))))
+ (let* ((headings (hywiki-get-page-headings page))
+ ;; Build the table with metadata manually
+ (table (lambda (str pred action)
+ (if (eq action 'metadata)
+ '(metadata (category . hywiki-heading))
+ (complete-with-action action headings str
pred)))))
+ (list (1+ hash-pos)
+ opoint
+ table
+ :exclusive 'no))))
;; CASE 2: Standard WikiWord completion (no '#' found)
- (list start end
- (hywiki-get-page-list)
- :exclusive 'no)))))))
+ (let ((wikiword-list (hywiki-get-wikiword-list)))
+ ;; 2. Validate the WikiWord and page existence
+ (when (and start end wikiword-list (not (string-empty-p word)))
+ (let ((table
+ ;; Build the table with metadata manually
+ (lambda (str pred action)
+ (if (eq action 'metadata)
+ '(metadata (category . hywiki-page))
+ (complete-with-action action wikiword-list str
pred)))))
+ (list start end
+ table
+ :exclusive 'no))))))))))
(defun hywiki-create-referent-and-display (wikiword &optional prompt-flag)
"Display the HyWiki referent for WIKIWORD if not in an ert test; return it.
@@ -2626,11 +2638,13 @@ lookup tables should have already been updated and this
is skipped.
Use `hywiki-word-face' to highlight."
(walk-windows
(lambda (window)
- (with-selected-window window
- ;; Display buffer before `normal-mode' triggers possibly
- ;; long-running font-locking
- (sit-for 0)
- (hywiki-maybe-highlight-references nil nil skip-lookups-update-flag)))
+ ;; Skip child/popup/posframe windows; use only top-level frame windows
+ (unless (frame-parent (window-frame window))
+ (with-selected-window window
+ ;; Display buffer before `normal-mode' triggers possibly
+ ;; long-running font-locking
+ (sit-for 0)
+ (hywiki-maybe-highlight-references nil nil
skip-lookups-update-flag))))
nil frame)
(hywiki-maybe-directory-updated))
@@ -2861,23 +2875,6 @@ If deleted, update HyWikiWord highlighting across all
frames."
(setq hywiki--referent-hasht nil
hywiki--any-wikiword-regexp-list nil))
-(eval-and-compile
- '(when (featurep 'company)
- (defun hywiki-company-hasht-backend (command &optional _arg &rest ignored)
- "A `company-mode` backend that completes from the keys of a hash table."
- (interactive (list 'interactive))
- (when (hywiki-word-at)
- (pcase command
- ('interactive (company-begin-backend 'company-hash-table-backend))
- ('prefix (company-grab-word))
- ('candidates
- (let ((prefix (company-grab-word)))
- (when prefix
- (cl-loop for key being the hash-keys in
(hywiki-get-wikiword-list)
- when (string-prefix-p prefix key)
- collect key))))
- ('sorted t))))))
-
(defvar hywiki-cache-default-file ".hywiki.eld"
"Standard file name for storing cached data for a HyWiki.")
@@ -3667,7 +3664,11 @@ Default to any HyWikiWord at point."
(user-error "(hywiki-word-consult-grep): Invalid HyWikiWord: '%s'; must be
capitalized, all alpha" word)))
(defun hywiki-word-from-reference (ref)
- "Return the HyWikiWord part of a reference (part before the #)."
+ "Return the HyWikiWord part of a reference (part before the #).
+This does not test whether a referent exists for the HyWikiWord; call
+‘hywiki-referent-exists-p’ without an argument for that. Nor does it
+test whether the HyWikiWord reference is within an invalid context;
+call ‘hywiki-non-hook-context-p’ for that."
(when (and (stringp ref)
(string-match hywiki-word-with-optional-suffix-exact-regexp ref))
(match-string 1 ref)))