branch: externals/hyperbole
commit 85d64e4d6a44c76e3e84c85fab5fd1fd14eb1002
Author: bw <r...@gnu.org>
Commit: bw <r...@gnu.org>

    hywiki-word-is-p - Fix invalid HyWikiWord page name creation
    
    This was due to not saving match data where needed.
---
 ChangeLog |  4 ++++
 hywiki.el | 11 ++++++-----
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 13931e2a13..6dad4d72c5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2025-05-27  Bob Weiner  <r...@gnu.org>
 
+* hywiki.el (hywiki-word-is-p): Save match data so when returns it represents
+    the match to the whole HyWikiWord referent, if any.  This fixes a bug
+    that created HyWikiWord page files with the section name attached.
+
 * hsmail.el (mail-send-hook): Remove this setting since 'message-send-hook'
     has replaced it in modern Emacs.
 
diff --git a/hywiki.el b/hywiki.el
index 941df7ce50..11872f0b4f 100644
--- a/hywiki.el
+++ b/hywiki.el
@@ -3,7 +3,7 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    21-Acpr-24 at 22:41:13
-;; Last-Mod:     26-May-25 at 00:16:02 by Bob Weiner
+;; Last-Mod:     27-May-25 at 02:05:56 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -3242,10 +3242,11 @@ these are handled by the Org mode link handler."
                  (eq 0 (string-match
                         hywiki-word-with-optional-suffix-exact-regexp
                         word)))
-             ;; If has a #section, ensure there are no invalid chars
-             (if (string-match "#" word)
-                 (string-match "#[^][#()<>{}\"\n\r\f]+\\'" word)
-               t)))))
+             (save-match-data
+               ;; If has a #section, ensure there are no invalid chars
+               (if (string-match "#" word)
+                   (string-match "#[^][#()<>{}\"\n\r\f]+\\'" word)
+                 t))))))
 
 (defun hywiki-word-read (&optional prompt)
   "Prompt with completion for and return an existing HyWikiWord.

Reply via email to