branch: externals/hyperbole
commit b1f4e77103dc17147379b5a742782acd0a74c247
Merge: e217c6083e ea30339ee9
Author: Robert Weiner <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #864 from rswgnu/rsw
hywiki-completion-at-point - Fix to use completion tables with Corfu
---
ChangeLog | 32 +++++++++++++-
hproperty.el | 1 +
hsys-org.el | 12 +++---
hywiki.el | 99 ++++++++++++++++++++++++--------------------
test/hy-test-dependencies.el | 7 ++--
5 files changed, 96 insertions(+), 55 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ccf8f395e4..559f7b0b5b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,33 @@
+2026-02-14 Bob Weiner <[email protected]>
+
+* hsys-org.el (hsys-org-fix-version): Ensure 'org-install-dir' is a dir and
+ not the file found from 'find-library--from-load-history' call.
+
+* test/hy-test-dependencies.el (hsys-org-log-and-fix-version): Ignore any
version
+ fixing errors due to publishing incompatibilities between versions. Not
+ relevant to run tests.
+
+* hywiki.el (hywiki--prior-mode): Rename to 'hywiki--prior-mode' since only
+ used internally.
+ (hywiki-mode): Define and document as a variable now that its
+ minor-mode does not define it but just references it with :variable.
+
+* 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 +39,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..4c473fb7c2 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: 31-Dec-25 at 00:03:26 by Mats Lidell
+;; Last-Mod: 14-Feb-26 at 23:40:17 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -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,11 @@ 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"))))
+ (when org-install-dir
+ (setq org-install-dir (file-name-directory org-install-dir)))
(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 +303,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..f10841f4ca 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 23:07:37 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
;;; ************************************************************************
@@ -188,6 +184,8 @@
;;; Private variables
;;; ************************************************************************
+(defvar hywiki--prior-mode nil)
+
(defvar-local hywiki--buffer-modified-tick nil
"Used to determine if a command modifies a buffer or not.
The `pre-command-hook' saves this value for a buffer and `post-command-hook'
@@ -407,12 +405,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 +423,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
@@ -788,7 +786,11 @@ since the command may have moved it off a HyWikiWord."
;; Not inside a comment or a string
(not (or (nth 4 (syntax-ppss)) (hypb:in-string-p))))))
-(defvar hywiki-prior-mode nil)
+(defvar hywiki-mode nil
+ "Non-nil when the global hywiki minor mode is enabled.
+Don't set this directly, instead call the function `hywiki-mode'
+with the value you want as its argument. See the docstring for
+that function for valid values.")
;;;###autoload
(define-minor-mode hywiki-mode
@@ -824,6 +826,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)))
@@ -853,7 +858,7 @@ See the Info documentation at \"(hyperbole)HyWiki\".
;; Need hyperbole-mode
(unless hyperbole-mode
(hyperbole-mode 1))
- (hywiki-word-set-auto-highlighting hywiki-prior-mode arg)
+ (hywiki-word-set-auto-highlighting hywiki--prior-mode arg)
(setq hywiki-mode arg))
((or (and (integerp arg) (<= arg 0))
(null arg))
@@ -862,7 +867,7 @@ See the Info documentation at \"(hyperbole)HyWiki\".
;; 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-mode' is nil.
- (hywiki-word-set-auto-highlighting hywiki-prior-mode arg)
+ (hywiki-word-set-auto-highlighting hywiki--prior-mode arg)
(setq hywiki-mode arg))
(t ;; (> arg 1)
;; Enable in HyWiki page buffers only
@@ -870,11 +875,11 @@ See the Info documentation at \"(hyperbole)HyWiki\".
;; Need hyperbole-mode
(unless hyperbole-mode
(hyperbole-mode 1))
- (hywiki-word-set-auto-highlighting hywiki-prior-mode arg)
+ (hywiki-word-set-auto-highlighting hywiki--prior-mode arg)
(setq hywiki-mode arg)))))
(defun hywiki-mode-around-advice (hywiki-mode-fn &optional arg)
- (setq hywiki-prior-mode hywiki-mode)
+ (setq hywiki--prior-mode hywiki-mode)
(funcall hywiki-mode-fn arg))
(advice-add 'hywiki-mode :around #'hywiki-mode-around-advice)
@@ -1463,17 +1468,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 +2644,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 +2881,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 +3670,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)))
diff --git a/test/hy-test-dependencies.el b/test/hy-test-dependencies.el
index e50ea65fbc..47207be4ae 100644
--- a/test/hy-test-dependencies.el
+++ b/test/hy-test-dependencies.el
@@ -3,7 +3,7 @@
;; Author: Mats Lidell <[email protected]>
;;
;; Orig-Date: 20-Feb-21 at 23:16:00
-;; Last-Mod: 25-Apr-25 at 19:28:36 by Mats Lidell
+;; Last-Mod: 14-Feb-26 at 23:46:04 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -41,8 +41,9 @@
;; Needed when `hypb:display-file-with-logo' uses `org-mode'
(setq hsys-org-enable-smart-keys t)
-;; Log and fix any mixed version Org installation
-(hsys-org-log-and-fix-version)
+;; Log and fix any mixed version Org installation.
+;; Ignore publishing-related errors that don't affect the tests.
+(ignore-errors (hsys-org-log-and-fix-version))
(provide 'hy-test-dependencies)
;;; hy-test-dependencies.el ends here