diff options
| author | Federico Tedin | 2020-02-17 22:24:40 +0100 |
|---|---|---|
| committer | Eli Zaretskii | 2020-02-21 11:15:00 +0200 |
| commit | 97b8a78334d22a6b12cc0f922771baf67a4030bc (patch) | |
| tree | ef00d7258184f9185b65acd54b0df05f0beec83c /test | |
| parent | 41450a8ea5a156a34f6641a0768cadb174fa261c (diff) | |
| download | emacs-97b8a78334d22a6b12cc0f922771baf67a4030bc.tar.gz 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')
| -rw-r--r-- | test/lisp/tempo-tests.el | 39 |
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 @@ | |||
| 216 | (tempo-complete-tag) | 216 | (tempo-complete-tag) |
| 217 | (should (equal (buffer-string) "Hello, World!")))) | 217 | (should (equal (buffer-string) "Hello, World!")))) |
| 218 | 218 | ||
| 219 | (ert-deftest tempo-define-tag-globally-test () | ||
| 220 | "Testing usage of a template tag defined from another buffer." | ||
| 221 | (tempo-define-template "test" '("Hello, World!") "hello") | ||
| 222 | |||
| 223 | (with-temp-buffer | ||
| 224 | ;; Use a tag in buffer 1 | ||
| 225 | (insert "hello") | ||
| 226 | (tempo-complete-tag) | ||
| 227 | (should (equal (buffer-string) "Hello, World!")) | ||
| 228 | (erase-buffer) | ||
| 229 | |||
| 230 | ;; Collection should not be dirty | ||
| 231 | (should-not tempo-dirty-collection) | ||
| 232 | |||
| 233 | ;; Define a tag on buffer 2 | ||
| 234 | (with-temp-buffer | ||
| 235 | (tempo-define-template "test2" '("Now expanded.") "mytag")) | ||
| 236 | |||
| 237 | ;; I should be able to use this template back in buffer 1 | ||
| 238 | (insert "mytag") | ||
| 239 | (tempo-complete-tag) | ||
| 240 | (should (equal (buffer-string) "Now expanded.")))) | ||
| 241 | |||
| 242 | (ert-deftest tempo-overwrite-tag-test () | ||
| 243 | "Testing ability to reassign templates to tags." | ||
| 244 | (with-temp-buffer | ||
| 245 | ;; Define a tag and use it | ||
| 246 | (tempo-define-template "test-tag-1" '("abc") "footag") | ||
| 247 | (insert "footag") | ||
| 248 | (tempo-complete-tag) | ||
| 249 | (should (equal (buffer-string) "abc")) | ||
| 250 | (erase-buffer) | ||
| 251 | |||
| 252 | ;; Define a new template with the same tag | ||
| 253 | (tempo-define-template "test-tag-2" '("xyz") "footag") | ||
| 254 | (insert "footag") | ||
| 255 | (tempo-complete-tag) | ||
| 256 | (should (equal (buffer-string) "xyz")))) | ||
| 257 | |||
| 219 | (ert-deftest tempo-expand-partial-tag-test () | 258 | (ert-deftest tempo-expand-partial-tag-test () |
| 220 | "Testing expansion of a template with a tag, with a partial match." | 259 | "Testing expansion of a template with a tag, with a partial match." |
| 221 | (with-temp-buffer | 260 | (with-temp-buffer |