[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/hyperbole a7aefb122b 1/4: HyWiki - fix a number of edge
From: |
ELPA Syncer |
Subject: |
[elpa] externals/hyperbole a7aefb122b 1/4: HyWiki - fix a number of edge cases with HyWiki highlighting |
Date: |
Sun, 17 Nov 2024 15:58:08 -0500 (EST) |
branch: externals/hyperbole
commit a7aefb122bdd2892f99b642a624c2a7fa2274e19
Author: bw <rsw@gnu.org>
Commit: bw <rsw@gnu.org>
HyWiki - fix a number of edge cases with HyWiki highlighting
---
ChangeLog | 19 +++++++++++++++++++
hproperty.el | 7 ++++---
hui-mouse.el | 10 ++++++----
hywiki.el | 27 +++++++++++++--------------
test/hywiki-tests.el | 8 ++++----
5 files changed, 46 insertions(+), 25 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 6b67c3ab90..6cf58b5747 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2024-11-17 Bob Weiner <rsw@gnu.org>
+
+* hproperty.el (hproperty:but-get-all-in-region): Return only overlays that
still
+ point to some buffer (may have overlay references that have been deleted
and point
+ to no buffer).
+
+* test/hywiki-tests.el
(hywiki-tests--verify-face-property-when-editing-wikiword-first-char):
+ Fix middle test after delete-char from HyWikiWord.
+
+* hui-mouse.el (smart-eobp): Trigger only if eobp = eolp or if only
+ whitespace on line preceding eobp.
+
+2024-11-16 Bob Weiner <rsw@gnu.org>
+
+* hywiki.el (hywiki-debuttonize-non-character-commands):
+ Remove (let ((hywiki-word-highlight-flag))) which was preventing
+ dehighlighting at the start of a WikiWord when the first character
+ was deleted.
+
2024-11-13 Bob Weiner <rsw@gnu.org>
* hywiki.el (hywiki-maybe-dehighlight-page-name,
diff --git a/hproperty.el b/hproperty.el
index c8bef57e3a..5ca2c3d2f7 100644
--- a/hproperty.el
+++ b/hproperty.el
@@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 21-Aug-92
-;; Last-Mod: 13-Oct-24 at 23:11:55 by Bob Weiner
+;; Last-Mod: 17-Nov-24 at 10:31:59 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -249,8 +249,9 @@ first button with that PROPERTY and VALUE only."
hproperty:flash-face))))
(delq nil
(mapcar (lambda (overlay)
- (when (memq (overlay-get overlay (or property 'face))
- val-list)
+ (when (and (bufferp (overlay-buffer overlay))
+ (memq (overlay-get overlay (or property 'face))
+ val-list))
(if property
(throw 'first (list overlay))
overlay)))
diff --git a/hui-mouse.el b/hui-mouse.el
index 50e15c35cf..58ba01fbba 100644
--- a/hui-mouse.el
+++ b/hui-mouse.el
@@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 04-Feb-89
-;; Last-Mod: 19-Aug-24 at 22:17:10 by Bob Weiner
+;; Last-Mod: 17-Nov-24 at 12:01:54 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -2216,8 +2216,8 @@ If key is pressed:
;;;###autoload
(defun smart-eobp ()
- "Return t if point is past the last visible buffer line with text."
- (and (or (eobp)
+ "Return t if point is past the last visible buffer line with non-whitespace
characters."
+ (and (or (and (eobp) (bolp))
;; On a blank line and nothing but whitespace until eob
(save-excursion
(beginning-of-line)
@@ -2226,7 +2226,9 @@ If key is pressed:
(not (smart-outline-char-invisible-p (1- (point)))))))
(defun smart-eolp ()
- "Return t if point is at the end of a visible line but not the end of the
buffer."
+ "Return t if point is at the end of a visible line.
+This includes the last buffer line if it contains any non-whitespace
+characters. It excludes a blank line at the end of the buffer."
;; smart-helm handles eol for helm buffers
(unless (or (and (smart-helm-alive-p) (equal (helm-buffer-get)
(buffer-name)))
;; Allow for org global cycling at start of buffer on a
diff --git a/hywiki.el b/hywiki.el
index 0f0db7ced2..cc3cb49148 100644
--- a/hywiki.el
+++ b/hywiki.el
@@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 21-Apr-24 at 22:41:13
-;; Last-Mod: 14-Nov-24 at 00:11:05 by Bob Weiner
+;; Last-Mod: 17-Nov-24 at 10:27:44 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -451,13 +451,12 @@ deletion commands and those in
`hywiki-non-character-commands'."
;; Use these to store any range of a delimited HyWikiWord#section
(set-marker hywiki--buttonize-start start)
(set-marker hywiki--buttonize-end end)
- ;; Enable dehighlighting in HyWiki pages
- (let ((hywiki-word-highlight-flag))
- (if (and start end)
- (hywiki-maybe-dehighlight-page-names hywiki--buttonize-start
- hywiki--buttonize-end)
- ;; Dehighlight any page name at point
- (hywiki-maybe-dehighlight-between-page-names))))))
+ ;; Enable dehighlighting in HyWiki pages
+ (if (and start end)
+ (hywiki-maybe-dehighlight-page-names hywiki--buttonize-start
+ hywiki--buttonize-end)
+ ;; Dehighlight any page name at point
+ (hywiki-maybe-dehighlight-between-page-names)))))
(defun hywiki-buttonize-word (func start end face)
"Create a HyWikiWord button by calling FUNC with START and END positions.
@@ -1263,8 +1262,8 @@ the current page unless they have sections attached."
(progn
(setq hywiki--page-name (match-string-no-properties 1)
hywiki--start (match-beginning 0)
- ;; This includes char after the page#section
- hywiki--end (match-end 0))
+ ;; This excludes optional char after the
page#section
+ hywiki--end (match-beginning 3))
(hywiki-get-page hywiki--page-name)))
(progn
(setq hywiki--current-page (hywiki-get-buffer-page-name))
@@ -1272,7 +1271,7 @@ the current page unless they have sections attached."
;; include a #section.
(unless (string-equal hywiki--current-page
(buffer-substring-no-properties
- hywiki--start (1- hywiki--end)))
+ hywiki--start hywiki--end))
(if (setq hywiki--buts (hproperty:but-get-all-in-region
hywiki--start hywiki--end
'face hywiki-word-face))
@@ -1285,7 +1284,7 @@ the current page unless they have sections attached."
hywiki--but-start (hproperty:but-start
hywiki--buts)
hywiki--but-end (hproperty:but-end
hywiki--buts))
(unless (and (= hywiki--start hywiki--but-start)
- (= (1- hywiki--end) hywiki--but-end))
+ (= hywiki--end hywiki--but-end))
(hproperty:but-delete hywiki--buts)
(hywiki-maybe-highlight-page-names
hywiki--start hywiki--end)))
@@ -2045,9 +2044,9 @@ DIRECTION-NUMBER is 1 for forward scanning and -1 for
backward scanning."
(setq hywiki--buttonize-characters
(concat "[]()<>{} \t\r\n'" (hywiki-get-buttonize-characters))
hywiki--buttonize-character-regexp
- (concat "[]["
+ (concat "\\([]["
(regexp-quote (substring hywiki--buttonize-characters 2))
- "]")
+ "]\\|$\\)")
hywiki--word-and-buttonize-character-regexp
(concat hywiki-word-with-optional-section-regexp
hywiki--buttonize-character-regexp)))
diff --git a/test/hywiki-tests.el b/test/hywiki-tests.el
index 946035851a..1c972d0a0e 100644
--- a/test/hywiki-tests.el
+++ b/test/hywiki-tests.el
@@ -3,7 +3,7 @@
;; Author: Mats Lidell
;;
;; Orig-Date: 18-May-24 at 23:59:48
-;; Last-Mod: 14-Nov-24 at 00:17:30 by Bob Weiner
+;; Last-Mod: 17-Nov-24 at 12:53:21 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -292,8 +292,8 @@ Both mod-time and checksum must be changed for a test to
return true."
"Call BODY wrapped in hywiki hooks to simulate Emacs redisplay."
(declare (indent 0) (debug t))
`(progn
- (funcall 'hywiki-debuttonize-non-character-commands)
(progn ,@body)
+ (funcall 'hywiki-debuttonize-non-character-commands)
(funcall 'hywiki-buttonize-character-commands)
(funcall 'hywiki-buttonize-non-character-commands)))
@@ -371,7 +371,6 @@ Both mod-time and checksum must be changed for a test to
return true."
(ert-deftest
hywiki-tests--verify-face-property-when-editing-wikiword-first-char ()
"Verify face property changes when WikiWord is edited in the first char
position."
- :expected-result :failed
(let* ((hywiki-directory (make-temp-file "hywiki" t))
(wikipage (hywiki-add-page "WikiWord")))
(skip-unless (not noninteractive))
@@ -385,7 +384,8 @@ Both mod-time and checksum must be changed for a test to
return true."
(should (looking-at-p "Wiki"))
(should (hproperty:but-get (point) 'face hywiki-word-face))
- (with-hywiki-buttonize-and-insert-hooks (delete-char 1))
+ (delete-char 1)
+ (hywiki-maybe-dehighlight-page-name t)
(should (looking-at-p "iki"))
(should-not (hproperty:but-get (point) 'face hywiki-word-face))