branch: externals/hyperbole
commit f36426ccb0418a3a7ec7da8b7ea5baa24cf4e472
Merge: e2fdb31d44 c1874cd3d4
Author: Robert Weiner <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #817 from rswgnu/rsw
- hpath:html-anchor-id-pattern - Fix for exact match.
- hpath:shorten - Ignore optional RELATIVE-TO if editing a message.
- hui:link-possible-types - Don't create an ilink to a potential but not
yet created HyWikiWord.
---
ChangeLog | 13 +++++++++++++
hpath.el | 42 ++++++++++++++++++++++--------------------
hui.el | 10 +++++++---
test/hmouse-drv-tests.el | 3 +--
4 files changed, 43 insertions(+), 25 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f361a6ac39..cc2cbe525a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2025-11-23 Bob Weiner <[email protected]>
+
+* hpath.el (hpath:shorten): Ignore optional RELATIVE-TO if editing a message,
+ i.e. (hmail:editor-p) => t.
+ (hpath:html-anchor-id-pattern): Fix so only exact matches are found
+ by requiring the trailing quote.
+ test/hmouse-drv-tests.el (hbut-pathname-html-anchor-test): Enable as now
passes.
+
+* hui.el (hui:link-possible-types): Don't create an ilink to a potential but
+ not yet created HyWikiWord. This prevents such links all over the place,
+ e.g. in Koutlines when on any capitalized word, where a klink should be
+ returned instead.
+
2025-11-22 Bob Weiner <[email protected]>
* test/hywiki-tests.el (hywiki-tests--assist-key-on-hywikiword-displays-help):
diff --git a/hpath.el b/hpath.el
index b35da06acd..ac1580ad4c 100644
--- a/hpath.el
+++ b/hpath.el
@@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 1-Nov-91 at 00:44:23
-;; Last-Mod: 16-Nov-25 at 10:49:44 by Bob Weiner
+;; Last-Mod: 23-Nov-25 at 12:54:16 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -682,7 +682,7 @@ use with `string-match'.")
;;; Private variables
;;; ************************************************************************
-(defconst hpath:html-anchor-id-pattern "\\(id\\|name\\)=['\"]%s['\"]?"
+(defconst hpath:html-anchor-id-pattern "\\(id\\|name\\)=['\"]%s['\"]"
"Regexp matching an html anchor id definition.
Contains a %s for replacement of a specific anchor id.")
@@ -2081,29 +2081,31 @@ prior to calling this function."
var-group)))
(defun hpath:shorten (path &optional relative-to)
- "Shorten and return a PATH optionally RELATIVE-TO other path.
-If RELATIVE-TO is omitted or nil, set it to `default-directory'.
-Replace Emacs Lisp variables and environment variables (format of
-${var}) with their values in PATH. The first matching value for
-variables like `${PATH}' is used. Then abbreviate any remaining
-path."
+ "Expand and then shorten and return a PATH optionally RELATIVE-TO other path.
+Ignore optional RELATIVE-TO if editing a message,
+i.e. (hmail:editor-p) => t. If RELATIVE-TO is omitted or nil,
+set it to `default-directory'. Replace Emacs Lisp variables and
+environment variables (format of ${var}) with their values in
+PATH. The first matching value for variables like `${PATH}' is
+used. Then abbreviate any remaining path."
(setq path (expand-file-name (hpath:substitute-value path)))
(when (file-directory-p path)
;; Force path to have a final directory separator so comparisons
;; to `default-directory' work
(setq path (file-name-as-directory path)))
- (unless relative-to
- (setq relative-to default-directory))
- (when (stringp relative-to)
- (setq relative-to (expand-file-name
- (hpath:substitute-value relative-to))
- path
- (cond ((string-equal path relative-to)
- "")
- ((string-equal (file-name-directory path) relative-to)
- (file-name-nondirectory path))
- (t (hpath:relative-to path relative-to)))))
- (hpath:abbreviate-file-name (hpath:substitute-var path)))
+ (unless (hmail:editor-p)
+ (unless relative-to
+ (setq relative-to default-directory))
+ (when (stringp relative-to)
+ (setq relative-to (expand-file-name
+ (hpath:substitute-value relative-to))
+ path
+ (cond ((string-equal path relative-to)
+ "")
+ ((string-equal (file-name-directory path) relative-to)
+ (file-name-nondirectory path))
+ (t (hpath:relative-to path relative-to))))))
+ (hpath:abbreviate-file-name (hpath:substitute-var path)))
(defun hpath:substitute-value (path)
"Substitute values for Emacs Lisp variables and environment variables in
PATH.
diff --git a/hui.el b/hui.el
index a9c8c39224..986076c6bf 100644
--- a/hui.el
+++ b/hui.el
@@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 19-Sep-91 at 21:42:03
-;; Last-Mod: 13-Aug-25 at 23:59:06 by Mats Lidell
+;; Last-Mod: 23-Nov-25 at 12:44:22 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -2062,8 +2062,12 @@ Buffer without File link-to-buffer-tmp"
(list 'link-to-gbut lbl-key))
((and hbut-sym lbl-key (eq (hattr:get
hbut-sym 'categ) 'explicit))
(list 'link-to-ebut lbl-key))
- ((and hbut-sym lbl-key)
- ;; On an implicit button, so link to it
+ ((and hbut-sym lbl-key
+ (not (eq (ibtype:def-symbol
+ (hattr:get 'hbut:current
'categ))
+ 'hywiki-word)))
+ ;; On an implicit button other than a
non-existing
+ ;; potential HyWikiWord, so link to it
;; (message "%S" (hattr:list hbut-sym))
(list 'link-to-ibut lbl-key (or
(hypb:buffer-file-name) (buffer-name))))
((and (require 'bookmark)
diff --git a/test/hmouse-drv-tests.el b/test/hmouse-drv-tests.el
index 1cba0d50ed..1e8636d465 100644
--- a/test/hmouse-drv-tests.el
+++ b/test/hmouse-drv-tests.el
@@ -3,7 +3,7 @@
;; Author: Mats Lidell <[email protected]>
;;
;; Orig-Date: 28-Feb-21 at 22:52:00
-;; Last-Mod: 17-Nov-25 at 16:53:05 by Mats Lidell
+;; Last-Mod: 23-Nov-25 at 12:59:17 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -345,7 +345,6 @@
(ert-deftest hbut-pathname-html-anchor-test ()
"Pathname with HTML anchor."
- :expected-result :failed
(let ((file (make-temp-file "hypb" nil ".html" "\
<a href=\"#idstr1\">link</a>
<h2 id=\"idstr11\"> header</h2>