Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 125 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,93 @@
2026-03-16 Bob Weiner <rsw@gnu.org>

* hibtypes.el (action): Ensure if action name is bound only as a variable
that there are no arguments within the angle brackets. If there are,
then it is not an action button.

* test/hywiki-tests.el (hywiki-tests--save-referent-org-id): Fix to mock
'org-id-get' instead of 'org-id-get-create' and add call to
`hywiki-get-referent' to ensure referent is created and read back properly.

* hywiki.el (hywiki-get-page-file): The page file may have previously been
resolved and sent as input here. If it exists, simply use it.

* hpath.el (hpath:is-p): Remove 'file-exists-p' call because 'hpath:normalize'
handles that while accounting for path #suffixes which the 'file-exists-p'
call mistakenly nullifies.
(hpath:validate): Fix that 'suffix' was set to the whole path string
when 'suffix-start' was null. Now it is set properly to nil.
Also fix so if a file named "myfile#name", validate accepts it without
treating the #name as a suffic/section to be stripped.

2026-03-15 Bob Weiner <rsw@gnu.org>

* test/demo-tests.el (fast-demo-display-kotl-starting-from-cell,
demo-implicit-button-hash-link-test)
demo-implicit-button-line-and-column-rtest):
Update these to remove 'hy-test-helpers:kill-buffer' since 'with-temp-buffer'
cleans it up. This eliminates a null buffer error.

* hpath.el (hpath:normalize): Handle directory paths and avoid reading in the
file to handle it.
(hpath:validate): Fix to strip #suffix before validation and add
it back on return.
* hibtypes.el (hywiki-existing-word): Simplify pathname check without calling
other ibtypes.

* hpath.el (hpath:suffixes): Remove ".org" as it triggers pathname ibtype when
it shouldn't and overrides `hywiki-existing-word'.

* hywiki.el (hywiki-add-org-id): Remove (hmouse-choose-link-and-referent-windows)
as this is not what inserts a link but just creates the wikiword referent.
(hywiki-word-regexp): Add optional .org suffix so "WikiWord.org#section"
works.

* hywiki.el (hywiki-referent-menu): Change from inserting a string link
to an Org link that includes the associated Org heading title. Change
format from "ID: uuid" to [[id:uuid][title]].
(hywiki-add-org-id):
test/hywiki-tests.el (hywiki-tests--add-org-id):
(hywiki-tests--save-referent-org-id):
(hywiki-tests--add-org-id): Add reading back the org-id
referent.
(hywiki-tests--save-referent-org-id): Delete this test;
covered better by 'hywiki-tests--add-org-id'.
hui.el (hui:link-possible-types): Update id handling in all of these.

* hywiki.el (hywiki-get-page-file, hywiki-get-existing-page-file): Add
second function and check that 'file-stem-name' does not contain
a directory, so it is not returned with the wrong dir attached.
hpath.el (hpath:at-p, hpath:find-line):
hibtypes.el (pathname-line-and-column, hib-link-to-file-line): Call
the new fuction in these four functions.

* hywiki.el (hywiki-org-get-heading-match-regexp,
hywiki--org-set-heading-regexp): Make whitespace before
optional components optional and allow for tabs.

* hywiki.el (hywiki-referent-menu): Change all "ID: " to "id:" to match
how Org works with the id: link type prefix when specifying ids.

* hpath.el (hpath:find, hpath:expand): Fix to properly expand HyWiki
page references.

* test/hywiki-tests.el (hywiki-tests--save-referent-global-button-use-menu):
Rewrite to not use mocking. Fixes this to work with latest
'hpath:find' as well.

* hbut.el (ibut:insert-text): Ensure line and col nums are prefixed with :L
and :C.
* hywiki.el (hywiki-org-get-heading-match-regexp): Handle both HyWiki dir
custom todo keywords when in a page and Org standard todo keywords, otherwise.
* hibtypes.el (pathname-line-and-column, hib-link-to-file-line): Expand HyWiki
page name using 'hywiki-get-page-file' before try to expand in current
directory
(pathname-line-and-column, hib-link-to-file-line): Call
'hywiki-get-page-file' only if 'label' has no directory attached. This fixes
a problem where ".org" is attached improperly to the filename.
* hpath.el (hpath:at-p, hpath:find-line): Handle pathname expansion of HyWiki
page names.

2026-03-15 Mats Lidell <matsl@gnu.org>

* test/hyrolo-tests.el: Prefix all tests with hyrolo-tests. Use
Expand All @@ -22,6 +112,41 @@

2026-03-14 Bob Weiner <rsw@gnu.org>

* hpath.el (hpath:call): (file-exists-p "") returns t, so fix to check for empty
string before calling that.
hibtypes.el (hpath:is-p): Unless 'non-exist' arg is sent or path is a remote file,
return path only if it exists.

* hui.el (require 'hsys-org): Add.
hibtypes.el (require 'hsys-org): Add.
hsys-org.el (hsys-org-uuid-is-p): Add and use in "hibtypes.el" and "hui.el".

* hui.el (hui:link-possible-types): For Org/Org-Roam ids, send 2nd arg
of current heading string to 'link-to-org-id' call.
(hui:link-possible-types): If in a HyWiki page but not on a heading line,
use a 'link-to-wikiword' with the page name and line number.
hactypes.el (link-to-org-id): Add optional heading 'title' arg for use in
'hbut:insert-text' where ibut links are created.

* hbut.el (ibut:insert-text): For 'actypes::link-to-org-id', change from
a double-quoted link to a double square bracketed Org link. This allows
including the title from the Org heading linked to which is stored in
the current Hyperbole button attribute, 'lbl-key'.

* hui.el (hui:link-possible-types): For HyWiki links, wrap a call of
'hpath:org-normalize-title' around 'hywiki-org-format-heading' to ensure
everything but the title is removed.

* hsys-org.el (hsys-org-link-at-p): Don't shrink label region down to just
the description part of the Org link, leave it as the entire space inside
the Org open and close brackets. Remove this code:
(when (string-match "\\]\\[" label)
(setq start (match-end 0)))
This makes link activation work better.

* hibtypes.el (org-id, org-id:help): Fix to remove "id:" prefix so
that uuid check predicates succeed properly.

* Makefile (HYPB_BIN_WARN): Fix preceding commentary on example use.
(test-all TERM=xterm-256color): Add #(LET_VARIABLES).

Expand Down
4 changes: 2 additions & 2 deletions hact.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 18-Sep-91 at 02:57:09
;; Last-Mod: 30-Dec-25 at 14:42:06 by Mats Lidell
;; Last-Mod: 16-Mar-26 at 22:11:38 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
Expand Down Expand Up @@ -391,7 +391,7 @@ Autoloads action function if need be to get the parameter list."
;;; ========================================================================

(defun hact (&rest args)
"Perform action formed from rest of ARGS and return the result.
"Perform action function formed from rest of ARGS and return the result.
The value of `hrule:action' determines what effect this has. The
default for `hrule:action' is `actype:act' which returns the result of
the action unless it is nil, in which case t is returned instead, to
Expand Down
7 changes: 4 additions & 3 deletions hactypes.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 23-Sep-91 at 20:34:36
;; Last-Mod: 28-Sep-25 at 23:27:18 by Mats Lidell
;; Last-Mod: 15-Mar-26 at 14:44:00 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
Expand Down Expand Up @@ -639,8 +639,9 @@ information on how to specify a mail reader to use."
(hypb:error "(link-to-mail): No msg `%s' in file \"%s\""
mail-msg-id mail-file)))))

(defact link-to-org-id (id)
"Display the Org entry, if any, for ID."
(defact link-to-org-id (id &optional title)
"Display the Org entry, if any, for ID with optional TITLE.
ID is a uuid without any 'id:' prefix."
(when (stringp id)
(let* ((inhibit-message t) ;; Inhibit org-id-find status msgs
(m (or (and (featurep 'org-roam) (org-roam-id-find id 'marker))
Expand Down
19 changes: 11 additions & 8 deletions hbut.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 18-Sep-91 at 02:57:09
;; Last-Mod: 28-Feb-26 at 16:33:40 by Bob Weiner
;; Last-Mod: 15-Mar-26 at 22:16:44 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
Expand Down Expand Up @@ -586,9 +586,7 @@ For interactive creation, use `hui:ebut-create' instead."
(hattr:set 'hbut:current 'args args)
(ebut:operate label nil))
(error (hattr:clear 'hbut:current)
(if (and (listp (cdr err)) (= (length (cdr err)) 1))
(error "(ebut:program): actype arg must be a bound symbol (not a string): %S" actype)
(error "(ebut:program): %S" err)))))))
(error "(ebut:program): %S" err))))))

(defun ebut:search (string out-buf &optional match-part)
"Write explicit button lines matching STRING to OUT-BUF.
Expand Down Expand Up @@ -2723,7 +2721,12 @@ Summary of operations based on inputs (name arg from \\='hbut:current attrs):
(if (string-prefix-p "<" arg1)
(insert arg1)
(insert "<" arg1 ">"))))
('actypes::link-to-org-id (insert (format "\"id:%s\"" arg1)))
;; Insert an Org-style link here so can include the Org title linked
;; to for clarity.
('actypes::link-to-org-id
(insert (if arg2
(format "[[id:%s][%s]]" arg1 arg2)
(format "[[id:%s]]" arg1))))
('actypes::link-to-rfc (insert (format "rfc%d" arg1)))
('actypes::link-to-wikiword (insert (if (and (stringp arg1)
(string-match-p "\\s-" arg1))
Expand All @@ -2732,13 +2735,13 @@ Summary of operations based on inputs (name arg from \\='hbut:current attrs):
arg1)))
('man (insert arg1))
('actypes::man-show (insert arg1))
('actypes::link-to-file-line (insert (format "\"%s:%d\""
('actypes::link-to-file-line (insert (format "\"%s:L%d\""
(hpath:shorten arg1) arg2)))
('actypes::link-to-file-line-and-column
(insert
(if (eq arg3 0)
(format "\"%s:%d\"" (hpath:shorten arg1) arg2)
(format "\"%s:%d:%d\"" (hpath:shorten arg1) arg2 arg3))))
(format "\"%s:L%d\"" (hpath:shorten arg1) arg2)
(format "\"%s:L%d:C%d\"" (hpath:shorten arg1) arg2 arg3))))
('actypes::link-to-file
;; arg2 when given is a buffer position
(insert "\""
Expand Down
49 changes: 29 additions & 20 deletions hibtypes.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 19-Sep-91 at 20:45:31
;; Last-Mod: 14-Mar-26 at 03:16:36 by Bob Weiner
;; Last-Mod: 16-Mar-26 at 23:02:23 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
Expand Down Expand Up @@ -37,10 +37,11 @@
;;; Other required Elisp libraries
;;; ************************************************************************

(require 'cl-lib) ;; for cl-count
(require 'cl-lib) ;; for cl-count and cl-find
(require 'find-func) ;; used by grep-msg ibtype
(eval-when-compile (require 'hversion))
(require 'hactypes)
(require 'hsys-org)
(require 'hypb)
(require 'org-macs) ;; for org-uuid-regexp
(require 'subr-x) ;; for string-trim
Expand Down Expand Up @@ -175,17 +176,19 @@ only to prevent false matches."
(start (when bounds (car bounds)))
(end (when bounds (cdr bounds)))
m)
;; Remove any "ID:" or "id:" prefix
(when (and id (string-prefix-p "id:" id t))
(setq id (substring id 3)
start (+ start 3)))
;; Ignore ID definitions or when not on a possible ID
(when (and id (if (fboundp 'org-uuidgen-p)
(org-uuidgen-p id)
(string-match org-uuid-regexp (downcase id))))
(when (hsys-org-uuid-is-p id)
(when (and start end)
(ibut:label-set id start end))
(if (and (not assist-flag)
(save-excursion (beginning-of-line)
(re-search-forward ":\\(CUSTOM_\\)?ID:[ \t]+"
(line-end-position) t)))
(hact 'message "On ID definition; use {C-u M-RET} to copy a link to an ID.")
(hact 'message "On Org ID definition; use {C-u M-RET} to copy a link to an ID.")
(when (let ((inhibit-message t) ;; Inhibit org-id-find status msgs
(obuf (current-buffer))
(omode major-mode))
Expand All @@ -208,6 +211,9 @@ If the referenced location is found, return non-nil."
(let ((id (thing-at-point 'symbol t)) ;; Could be a uuid or some other form of id
m
mpos)
;; Remove any "ID:" or "id:" prefix
(when (and id (string-prefix-p "id:" id t))
(setq id (substring id 3)))
;; Ignore ID definitions or when not on a possible ID
(when (and id
(let ((inhibit-message t)) ;; Inhibit org-id-find status msgs
Expand Down Expand Up @@ -490,7 +496,6 @@ handle any links they recognize first."
;; Prevent infinite recursion, e.g. if called via
;; `org-metareturn-hook' from `org-meta-return' invocation.
(not (hyperb:stack-frame '(ibtypes::debugger-source org-meta-return))))
(require 'hsys-org)
(declare-function hsys-org-link-at-p "hsys-org" ())
(declare-function hsys-org-set-ibut-label "hsys-org" (start-end))
(let ((start-end (hsys-org-link-at-p)))
Expand Down Expand Up @@ -985,9 +990,10 @@ See `hpath:find' function documentation for special file display options."
(col-num (when (match-end 4)
(string-to-number (match-string-no-properties 5 path-line-and-col))))
(label (match-string-no-properties 1 path-line-and-col))
;; Next variable must come last as it can overwrite the match-data
(file (hpath:expand label)))
(when (setq file (hpath:is-p file))
;; Next variable should come last as it can overwrite the match-data
file)
(when (setq file (or (hpath:is-p (hpath:expand label))
(hywiki-get-existing-page-file label)))
(ibut:label-set label start (+ start (length label)))
(if col-num
(hact 'link-to-file-line-and-column file line-num col-num)
Expand Down Expand Up @@ -1017,8 +1023,9 @@ LINE-NUM may be an integer or string."
(and (or (null (setq ext (file-name-extension file)))
(member (concat "." ext) (get-load-suffixes)))
(ignore-errors (find-library-name file)))
(expand-file-name file))))
(when (file-exists-p file)
(hpath:is-p (expand-file-name file))
(hywiki-get-existing-page-file file))))
(when (file-exists-p (hpath:normalize file))
(actypes::link-to-file-line file line-num))))

(defib ipython-stack-frame ()
Expand Down Expand Up @@ -1624,7 +1631,7 @@ action type, function symbol to call or test to execute, i.e.
(let ((hbut:max-len 0)
(name (hattr:get 'hbut:current 'name))
(testing-flag (when (bound-and-true-p ert--running-tests) t))
actype actype-sym action args lbl var-flag)
actname actype actype-sym action args is-var lbl sep var-flag)

;; Continue only if there if there is one of:
;; 1. `ert--running-tests' is non-nil
Expand All @@ -1640,23 +1647,26 @@ action type, function symbol to call or test to execute, i.e.
(when (string-match "\\`\\$" lbl)
(setq var-flag t
lbl (substring lbl 1)))
(setq actype (if (string-match-p " " lbl) (car (split-string lbl)) lbl)
actype-sym (or (actype:elisp-symbol actype) (intern-soft actype))
(setq actname (if (setq sep (cl-position ?\ lbl)) (substring lbl 0 sep) lbl)
actype-sym (or (actype:elisp-symbol actname) (intern-soft actname))
;; Must ignore that (boundp nil) would be t here.
actype (and actype-sym
(or (fboundp actype-sym) (boundp actype-sym)
(or (fboundp actype-sym)
(setq is-var (boundp actype-sym))
(special-form-p actype-sym)
(ert-test-boundp actype-sym))
actype-sym))
(when actype
(when (and actype (or (null is-var)
;; is a variable so can't have arguments
(equal actname lbl)))
;; For <hynote> buttons, need to double quote each argument so
;; 'read' does not change the idstamp 02 to 2.
(when (and (memq actype '(hy hynote))
(string-match-p " " lbl))
(setq lbl (replace-regexp-in-string "\"\\(.*\\)\\'" "\\1\""
(combine-and-quote-strings
(split-string lbl) "\" \""))))
(setq action (read (concat "(" lbl ")"))
(setq action (ignore-errors (read (concat "(" lbl ")")))
args (cdr action))
;; Ensure action uses an fboundp symbol if executing a
;; Hyperbole actype.
Expand Down Expand Up @@ -1762,8 +1772,7 @@ not yet existing HyWikiWords."
(cl-destructuring-bind (wikiword start end)
(hywiki-referent-exists-p :range)
(when wikiword
(unless (or (ibtypes::pathname-line-and-column)
(ibtypes::pathname))
(unless (file-exists-p (hywiki-word-from-reference wikiword))
(if (and start end)
(ibut:label-set wikiword start end)
(ibut:label-set wikiword))
Expand Down
Loading
Loading