Skip to content

Commit bbd3502

Browse files
committed
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.
1 parent 5e1350d commit bbd3502

File tree

4 files changed

+43
-25
lines changed

4 files changed

+43
-25
lines changed

ChangeLog

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
2025-11-23 Bob Weiner <[email protected]>
2+
3+
* hpath.el (hpath:shorten): Ignore optional RELATIVE-TO if editing a message,
4+
i.e. (hmail:editor-p) => t.
5+
(hpath:html-anchor-id-pattern): Fix so only exact matches are found
6+
by requiring the trailing quote.
7+
test/hmouse-drv-tests.el (hbut-pathname-html-anchor-test): Enable as now passes.
8+
9+
* hui.el (hui:link-possible-types): Don't create an ilink to a potential but
10+
not yet created HyWikiWord. This prevents such links all over the place,
11+
e.g. in Koutlines when on any capitalized word, where a klink should be
12+
returned instead.
13+
114
2025-11-22 Bob Weiner <[email protected]>
215

316
* test/hywiki-tests.el (hywiki-tests--assist-key-on-hywikiword-displays-help):

hpath.el

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
;; Author: Bob Weiner
44
;;
55
;; Orig-Date: 1-Nov-91 at 00:44:23
6-
;; Last-Mod: 16-Nov-25 at 10:49:44 by Bob Weiner
6+
;; Last-Mod: 23-Nov-25 at 12:54:16 by Bob Weiner
77
;;
88
;; SPDX-License-Identifier: GPL-3.0-or-later
99
;;
@@ -682,7 +682,7 @@ use with `string-match'.")
682682
;;; Private variables
683683
;;; ************************************************************************
684684

685-
(defconst hpath:html-anchor-id-pattern "\\(id\\|name\\)=['\"]%s['\"]?"
685+
(defconst hpath:html-anchor-id-pattern "\\(id\\|name\\)=['\"]%s['\"]"
686686
"Regexp matching an html anchor id definition.
687687
Contains a %s for replacement of a specific anchor id.")
688688

@@ -2081,29 +2081,31 @@ prior to calling this function."
20812081
var-group)))
20822082

20832083
(defun hpath:shorten (path &optional relative-to)
2084-
"Shorten and return a PATH optionally RELATIVE-TO other path.
2085-
If RELATIVE-TO is omitted or nil, set it to `default-directory'.
2086-
Replace Emacs Lisp variables and environment variables (format of
2087-
${var}) with their values in PATH. The first matching value for
2088-
variables like `${PATH}' is used. Then abbreviate any remaining
2089-
path."
2084+
"Expand and then shorten and return a PATH optionally RELATIVE-TO other path.
2085+
Ignore optional RELATIVE-TO if editing a message,
2086+
i.e. (hmail:editor-p) => t. If RELATIVE-TO is omitted or nil,
2087+
set it to `default-directory'. Replace Emacs Lisp variables and
2088+
environment variables (format of ${var}) with their values in
2089+
PATH. The first matching value for variables like `${PATH}' is
2090+
used. Then abbreviate any remaining path."
20902091
(setq path (expand-file-name (hpath:substitute-value path)))
20912092
(when (file-directory-p path)
20922093
;; Force path to have a final directory separator so comparisons
20932094
;; to `default-directory' work
20942095
(setq path (file-name-as-directory path)))
2095-
(unless relative-to
2096-
(setq relative-to default-directory))
2097-
(when (stringp relative-to)
2098-
(setq relative-to (expand-file-name
2099-
(hpath:substitute-value relative-to))
2100-
path
2101-
(cond ((string-equal path relative-to)
2102-
"")
2103-
((string-equal (file-name-directory path) relative-to)
2104-
(file-name-nondirectory path))
2105-
(t (hpath:relative-to path relative-to)))))
2106-
(hpath:abbreviate-file-name (hpath:substitute-var path)))
2096+
(unless (hmail:editor-p)
2097+
(unless relative-to
2098+
(setq relative-to default-directory))
2099+
(when (stringp relative-to)
2100+
(setq relative-to (expand-file-name
2101+
(hpath:substitute-value relative-to))
2102+
path
2103+
(cond ((string-equal path relative-to)
2104+
"")
2105+
((string-equal (file-name-directory path) relative-to)
2106+
(file-name-nondirectory path))
2107+
(t (hpath:relative-to path relative-to))))))
2108+
(hpath:abbreviate-file-name (hpath:substitute-var path)))
21072109

21082110
(defun hpath:substitute-value (path)
21092111
"Substitute values for Emacs Lisp variables and environment variables in PATH.

hui.el

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
;; Author: Bob Weiner
44
;;
55
;; Orig-Date: 19-Sep-91 at 21:42:03
6-
;; Last-Mod: 13-Aug-25 at 23:59:06 by Mats Lidell
6+
;; Last-Mod: 23-Nov-25 at 12:44:22 by Bob Weiner
77
;;
88
;; SPDX-License-Identifier: GPL-3.0-or-later
99
;;
@@ -2062,8 +2062,12 @@ Buffer without File link-to-buffer-tmp"
20622062
(list 'link-to-gbut lbl-key))
20632063
((and hbut-sym lbl-key (eq (hattr:get hbut-sym 'categ) 'explicit))
20642064
(list 'link-to-ebut lbl-key))
2065-
((and hbut-sym lbl-key)
2066-
;; On an implicit button, so link to it
2065+
((and hbut-sym lbl-key
2066+
(not (eq (ibtype:def-symbol
2067+
(hattr:get 'hbut:current 'categ))
2068+
'hywiki-word)))
2069+
;; On an implicit button other than a non-existing
2070+
;; potential HyWikiWord, so link to it
20672071
;; (message "%S" (hattr:list hbut-sym))
20682072
(list 'link-to-ibut lbl-key (or (hypb:buffer-file-name) (buffer-name))))
20692073
((and (require 'bookmark)

test/hmouse-drv-tests.el

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
;; Author: Mats Lidell <[email protected]>
44
;;
55
;; Orig-Date: 28-Feb-21 at 22:52:00
6-
;; Last-Mod: 17-Nov-25 at 16:53:05 by Mats Lidell
6+
;; Last-Mod: 23-Nov-25 at 12:59:17 by Bob Weiner
77
;;
88
;; SPDX-License-Identifier: GPL-3.0-or-later
99
;;
@@ -345,7 +345,6 @@
345345

346346
(ert-deftest hbut-pathname-html-anchor-test ()
347347
"Pathname with HTML anchor."
348-
:expected-result :failed
349348
(let ((file (make-temp-file "hypb" nil ".html" "\
350349
<a href=\"#idstr1\">link</a>
351350
<h2 id=\"idstr11\"> header</h2>

0 commit comments

Comments
 (0)