branch: externals/hyperbole commit 9e4862fc4f76d29bc460fd98c5a022bc50e6e258 Author: bw <r...@gnu.org> Commit: bw <r...@gnu.org>
Add HyWikiWord highlighting only when not already highlighted --- ChangeLog | 3 +++ hproperty.el | 14 +++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 42150229d2..e47deb3513 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +* hproperty.el (hproperty:but-add): Add a button only when a button with the same property + value, start, and end does not already exist, to prevent duplicates. + * hibtypes.el (Info-node): Handle decoding of Info node names in Hyperbole Help buffer lbl-key: lines, eliminating excess underscores. diff --git a/hproperty.el b/hproperty.el index 2a34918c23..11fad38c95 100644 --- a/hproperty.el +++ b/hproperty.el @@ -3,7 +3,7 @@ ;; Author: Bob Weiner ;; ;; Orig-Date: 21-Aug-92 -;; Last-Mod: 29-Jun-24 at 18:57:42 by Bob Weiner +;; Last-Mod: 28-Jul-24 at 23:58:16 by Bob Weiner ;; ;; SPDX-License-Identifier: GPL-3.0-or-later ;; @@ -150,14 +150,18 @@ This is shown when hovering over the button with the mouse." (defun hproperty:but-add (start end face) "Add between START and END a button using FACE in current buffer. +Button is added only if it does not already exist. If `hproperty:but-emphasize-flag' is non-nil when this is called, emphasize that button is selectable whenever the mouse cursor moves over it." - (let ((but (make-overlay start end nil t))) - (overlay-put but 'face face) - (when hproperty:but-emphasize-flag - (overlay-put but 'mouse-face 'highlight)))) + (let ((but (hproperty:but-get start 'face face))) + (unless (and but (eq start (hproperty:but-start but)) + (eq end (hproperty:but-end but))) + (setq but (make-overlay start end nil t)) + (overlay-put but 'face face) + (when hproperty:but-emphasize-flag + (overlay-put but 'mouse-face 'highlight))))) (defun hproperty:but-clear (&optional pos property value) "Remove highlighting from any named Hyperbole button at point or POS.