summaryrefslogtreecommitdiff
path: root/test/lisp/tempo-tests.el
diff options
context:
space:
mode:
authorFederico Tedin <federicotedin@gmail.com>2020-02-17 22:24:40 +0100
committerEli Zaretskii <eliz@gnu.org>2020-02-21 11:15:00 +0200
commit97b8a78334d22a6b12cc0f922771baf67a4030bc (patch)
treeef00d7258184f9185b65acd54b0df05f0beec83c /test/lisp/tempo-tests.el
parent41450a8ea5a156a34f6641a0768cadb174fa261c (diff)
downloademacs-97b8a78334d22a6b12cc0f922771baf67a4030bc.tar.gz
emacs-97b8a78334d22a6b12cc0f922771baf67a4030bc.tar.bz2
emacs-97b8a78334d22a6b12cc0f922771baf67a4030bc.zip
Allow tempo-define-template to reassign tags to new templates
* lisp/tempo.el (tempo-define-template): Update documentation string to mention that existing tags can be reassigned new templates. (tempo-add-tag): Allow reassigning tags to new templates. Additionally, invalidate tag collections in all buffers if the global tags list is being modified. (tempo-invalidate-collection): Allow invalidating tag collections in all buffers at the same time. * test/lisp/tempo-tests.el (tempo-define-tag-globally-test): Add a test to check that new templates plus tags can be defined from any buffer and then immediately used in other buffers. (tempo-overwrite-tag-test): Add a test to check that tags can be reassigned templates. * etc/NEWS: Announce changes in tempo.el. (Bug#39555)
Diffstat (limited to 'test/lisp/tempo-tests.el')
-rw-r--r--test/lisp/tempo-tests.el39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/lisp/tempo-tests.el b/test/lisp/tempo-tests.el
index 0dd310b8531..bfe475910da 100644
--- a/test/lisp/tempo-tests.el
+++ b/test/lisp/tempo-tests.el
@@ -216,6 +216,45 @@
(tempo-complete-tag)
(should (equal (buffer-string) "Hello, World!"))))
+(ert-deftest tempo-define-tag-globally-test ()
+ "Testing usage of a template tag defined from another buffer."
+ (tempo-define-template "test" '("Hello, World!") "hello")
+
+ (with-temp-buffer
+ ;; Use a tag in buffer 1
+ (insert "hello")
+ (tempo-complete-tag)
+ (should (equal (buffer-string) "Hello, World!"))
+ (erase-buffer)
+
+ ;; Collection should not be dirty
+ (should-not tempo-dirty-collection)
+
+ ;; Define a tag on buffer 2
+ (with-temp-buffer
+ (tempo-define-template "test2" '("Now expanded.") "mytag"))
+
+ ;; I should be able to use this template back in buffer 1
+ (insert "mytag")
+ (tempo-complete-tag)
+ (should (equal (buffer-string) "Now expanded."))))
+
+(ert-deftest tempo-overwrite-tag-test ()
+ "Testing ability to reassign templates to tags."
+ (with-temp-buffer
+ ;; Define a tag and use it
+ (tempo-define-template "test-tag-1" '("abc") "footag")
+ (insert "footag")
+ (tempo-complete-tag)
+ (should (equal (buffer-string) "abc"))
+ (erase-buffer)
+
+ ;; Define a new template with the same tag
+ (tempo-define-template "test-tag-2" '("xyz") "footag")
+ (insert "footag")
+ (tempo-complete-tag)
+ (should (equal (buffer-string) "xyz"))))
+
(ert-deftest tempo-expand-partial-tag-test ()
"Testing expansion of a template with a tag, with a partial match."
(with-temp-buffer