[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/hyperbole 1dd924149f 05/14: Handle hooks to mimic redis
From: |
ELPA Syncer |
Subject: |
[elpa] externals/hyperbole 1dd924149f 05/14: Handle hooks to mimic redisplay behavior |
Date: |
Mon, 11 Nov 2024 03:58:23 -0500 (EST) |
branch: externals/hyperbole
commit 1dd924149ff457f03d39ee8a4c63051d413b1c7a
Author: Mats Lidell <mats.lidell@lidells.se>
Commit: Mats Lidell <mats.lidell@lidells.se>
Handle hooks to mimic redisplay behavior
---
ChangeLog | 12 ++++
test/hywiki-tests.el | 151 ++++++++++++++++++++++++++++++++++-----------------
2 files changed, 112 insertions(+), 51 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ed7fc2c911..6f63c0c21f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2024-11-10 Mats Lidell <matsl@gnu.org>
+
+* test/hywiki-tests.el (hywiki-tests--add-hywiki-hooks)
+ (hywiki-tests--remove-hywiki-hooks, with-hywiki-buttonize-hooks)
+ (with-hywiki-buttonize-and-insert-hooks): Add functions and macros for
+ mimicking redisplay hook behavior and use these in the highlighting tests.
+ (hywiki-tests--face-property-for-wikiword-with-wikipage)
+ (hywiki-tests--no-face-property-for-no-wikipage)
+ (hywiki-tests--verify-face-property-when-editing-wikiword)
+ (hywiki-tests--verify-face-property-when-editing-wikiword-first-char):
+ Tests using the hook mimicking functions.
+
2024-11-02 Mats Lidell <matsl@gnu.org>
* test/hywiki-tests.el (hywiki-tests--word-is-p)
diff --git a/test/hywiki-tests.el b/test/hywiki-tests.el
index a724720f9f..667703708b 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: 2-Nov-24 at 23:29:41 by Mats Lidell
+;; Last-Mod: 10-Nov-24 at 22:54:09 by Mats Lidell
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -270,87 +270,136 @@ Both mod-time and checksum must be changed for a test to
return true."
;; Following three test cases for verifying proper face is some what
;; experimental. They need to be run in interactive mode.
+(defun hywiki-tests--add-hywiki-hooks ()
+ "Enable all hywiki hook functions."
+ (add-hook 'pre-command-hook 'hywiki-debuttonize-non-character-commands
95)
+ (add-hook 'post-command-hook 'hywiki-buttonize-non-character-commands 95)
+ (add-hook 'post-self-insert-hook 'hywiki-buttonize-character-commands)
+ (add-hook 'window-buffer-change-functions
+ 'hywiki-maybe-highlight-page-names-in-frame)
+ (add-to-list 'yank-handled-properties
+ '(hywiki-word-face . hywiki-highlight-on-yank)))
+
+(defun hywiki-tests--remove-hywiki-hooks ()
+ "Disable all hywiki hook functions."
+ (remove-hook 'pre-command-hook
'hywiki-debuttonize-non-character-commands)
+ (remove-hook 'post-command-hook 'hywiki-buttonize-non-character-commands)
+ (remove-hook 'post-self-insert-hook 'hywiki-buttonize-character-commands)
+ (remove-hook 'window-buffer-change-functions
+ 'hywiki-maybe-highlight-page-names-in-frame)
+ (setq yank-handled-properties
+ (delete '(hywiki-word-face . hywiki-highlight-on-yank)
+ yank-handled-properties)))
+
+(defmacro with-hywiki-buttonize-hooks (&rest body)
+ "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-buttonize-non-character-commands)))
+
+(defmacro with-hywiki-buttonize-and-insert-hooks (&rest body)
+ "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-buttonize-character-commands)
+ (funcall 'hywiki-buttonize-non-character-commands)))
+
(ert-deftest hywiki-tests--face-property-for-wikiword-with-wikipage ()
"Verify WikiWord for a wiki page gets face property hywiki-word-face."
+ (skip-unless (not noninteractive))
(let* ((hsys-org-enable-smart-keys t)
(hywiki-directory (make-temp-file "hywiki" t))
(wikipage (hywiki-add-page "WikiWord")))
(unwind-protect
- (with-temp-buffer
- (hywiki-mode 1)
- (insert "WikiWord")
- (newline nil t)
- (goto-char 4)
- (hywiki-maybe-highlight-page-names (point-min) (point-max))
- (should (hproperty:but-get (point) 'face hywiki-word-face)))
+ (progn
+ (hywiki-tests--remove-hywiki-hooks)
+ (with-temp-buffer
+ (hywiki-mode 1)
+ (with-hywiki-buttonize-and-insert-hooks
+ (insert "WikiWord")
+ (newline nil t))
+ (goto-char 4)
+ (should (hproperty:but-get (point) 'face hywiki-word-face))))
+ (hywiki-tests--add-hywiki-hooks)
(hywiki-mode 0)
(hy-delete-file-and-buffer wikipage)
(hy-delete-dir-and-buffer hywiki-directory))))
(ert-deftest hywiki-tests--no-face-property-for-no-wikipage ()
"Verify WikiWord for no wiki page does not get face property
hywiki-word-face."
+ (skip-unless (not noninteractive))
(let* ((hsys-org-enable-smart-keys t)
(hywiki-directory (make-temp-file "hywiki" t)))
(unwind-protect
- (with-temp-buffer
- (hywiki-mode 0)
- (insert "WikiWord")
- (newline nil t)
- (goto-char 4)
- (hywiki-maybe-highlight-page-names (point-min) (point-max))
- (should-not (hproperty:but-get (point) 'face hywiki-word-face)))
+ (progn
+ (hywiki-tests--remove-hywiki-hooks)
+ (with-temp-buffer
+ (hywiki-mode 0)
+ (with-hywiki-buttonize-and-insert-hooks
+ (insert "WikiWord")
+ (newline nil t))
+ (goto-char 4)
+ (should-not (hproperty:but-get (point) 'face hywiki-word-face))))
+ (hywiki-tests--add-hywiki-hooks)
(hy-delete-dir-and-buffer hywiki-directory))))
(ert-deftest hywiki-tests--verify-face-property-when-editing-wikiword ()
"Verify face property changes when WikiWord is edited."
+ (skip-unless (not noninteractive))
(let* ((hywiki-directory (make-temp-file "hywiki" t))
(wikipage (hywiki-add-page "WikiWord")))
(unwind-protect
- (with-temp-buffer
- (hywiki-mode 1)
- (insert "Wikiord ")
- (goto-char 5)
- (should (looking-at-p "ord"))
- (hywiki-maybe-highlight-page-names (point-min) (point-max))
- (should-not (hproperty:but-get (point) 'face hywiki-word-face))
-
- (insert "W")
- (goto-char 5)
- (should (looking-at-p "Word"))
- (hywiki-maybe-highlight-page-names (point-min) (point-max))
- (should (hproperty:but-get (point) 'face hywiki-word-face))
-
- (delete-char 1)
- (should (looking-at-p "ord"))
- (hywiki-maybe-highlight-page-names (point-min) (point-max))
- (should-not (hproperty:but-get (point) 'face hywiki-word-face)))
+ (progn
+ (hywiki-tests--remove-hywiki-hooks)
+ (with-temp-buffer
+ (hywiki-mode 1)
+ (with-hywiki-buttonize-and-insert-hooks (insert "Wikiord "))
+ (goto-char 5)
+ (should (looking-at-p "ord"))
+ (should-not (hproperty:but-get (point) 'face hywiki-word-face))
+
+ (with-hywiki-buttonize-and-insert-hooks (insert "W"))
+ (goto-char 5)
+ (should (looking-at-p "Word"))
+ (should (hproperty:but-get (point) 'face hywiki-word-face))
+
+ (with-hywiki-buttonize-and-insert-hooks (delete-char 1))
+ (should (looking-at-p "ord"))
+ (should-not (hproperty:but-get (point) 'face hywiki-word-face))))
+ (hywiki-tests--add-hywiki-hooks)
(hywiki-mode 0)
(hy-delete-files-and-buffers (list wikipage))
(hy-delete-dir-and-buffer hywiki-directory))))
(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))
(unwind-protect
- (with-temp-buffer
- (hywiki-mode 1)
- (insert "WikiWord ")
- (goto-char 1)
- (should (looking-at-p "Wiki"))
- (hywiki-maybe-highlight-page-names (point-min) (point-max))
- (should (hproperty:but-get (point) 'face hywiki-word-face))
-
- (delete-char 1)
- (should (looking-at-p "iki"))
- (hywiki-maybe-highlight-page-names (point-min) (point-max))
- (should-not (hproperty:but-get (point) 'face hywiki-word-face))
-
- (insert "W")
- (goto-char 1)
- (should (looking-at-p "Wiki"))
- (hywiki-maybe-highlight-page-names (point-min) (point-max))
- (should (hproperty:but-get (point) 'face hywiki-word-face)))
+ (progn
+ (hywiki-tests--remove-hywiki-hooks)
+ (with-temp-buffer
+ (hywiki-mode 1)
+ (with-hywiki-buttonize-and-insert-hooks (insert "WikiWord "))
+ (goto-char 1)
+ (should (looking-at-p "Wiki"))
+ (should (hproperty:but-get (point) 'face hywiki-word-face))
+
+ (with-hywiki-buttonize-and-insert-hooks (delete-char 1))
+ (should (looking-at-p "iki"))
+ (should-not (hproperty:but-get (point) 'face hywiki-word-face))
+
+ (with-hywiki-buttonize-and-insert-hooks (insert "W"))
+ (goto-char 1)
+ (should (looking-at-p "Wiki"))
+ (should (hproperty:but-get (point) 'face hywiki-word-face))))
+ (hywiki-tests--add-hywiki-hooks)
(hywiki-mode 0)
(hy-delete-files-and-buffers (list wikipage))
(hy-delete-dir-and-buffer hywiki-directory))))
- [elpa] externals/hyperbole updated (3555e549f8 -> 9ebfcfe2e3), ELPA Syncer, 2024/11/11
- [elpa] externals/hyperbole 4571614bc5 11/14: Merge branch 'master' into make-comment-work-as-an-info-ibut, ELPA Syncer, 2024/11/11
- [elpa] externals/hyperbole 742ccea3ff 13/14: Merge branch 'master' into rsw, ELPA Syncer, 2024/11/11
- [elpa] externals/hyperbole 2ec382cdaf 03/14: Add test case for verifying property is updated on edit, ELPA Syncer, 2024/11/11
- [elpa] externals/hyperbole aecb4ec856 06/14: Revert "Use plain star wildcard and add a test", ELPA Syncer, 2024/11/11
- [elpa] externals/hyperbole 1dd924149f 05/14: Handle hooks to mimic redisplay behavior,
ELPA Syncer <=
- [elpa] externals/hyperbole 74e7c4eb4e 07/14: make comment text into an ibut, ELPA Syncer, 2024/11/11
- [elpa] externals/hyperbole 9f2eff61f2 10/14: Merge pull request #600 from rswgnu/add-more-hywiki-tests, ELPA Syncer, 2024/11/11
- [elpa] externals/hyperbole 498f28757c 12/14: Merge pull request #601 from rswgnu/make-comment-work-as-an-info-ibut, ELPA Syncer, 2024/11/11
- [elpa] externals/hyperbole 8a5b3e2327 01/14: Add hywiki-word-is-p test, ELPA Syncer, 2024/11/11
- [elpa] externals/hyperbole 9ebfcfe2e3 14/14: Merge pull request #602 from rswgnu/rsw, ELPA Syncer, 2024/11/11
- [elpa] externals/hyperbole 68e68cd893 09/14: hyrolo.el (hyrolo-grep-file) - Fix bug (gh#rswgnu/hyperbole/599), ELPA Syncer, 2024/11/11
- [elpa] externals/hyperbole a535696bb4 08/14: Support latest Treemacs and HyWiki page navigation with it, ELPA Syncer, 2024/11/11
- [elpa] externals/hyperbole 12d84d101f 04/14: Call hook function explicitly to simulate interactive use, ELPA Syncer, 2024/11/11
- [elpa] externals/hyperbole c98bdbf501 02/14: Use plain star wildcard and add a test, ELPA Syncer, 2024/11/11