diff options
| author | Allen Li | 2018-09-29 15:19:04 -0700 |
|---|---|---|
| committer | Eli Zaretskii | 2018-10-12 11:44:15 +0300 |
| commit | f5896e2cbf0e537ec6b79ba139220239f934c840 (patch) | |
| tree | 51604349e1190449caf75043d689694a84212441 /test | |
| parent | 5bd8cfc14d4b0c78c07e65a583f42a10c4cbc06d (diff) | |
| download | emacs-f5896e2cbf0e537ec6b79ba139220239f934c840.tar.gz emacs-f5896e2cbf0e537ec6b79ba139220239f934c840.zip | |
Rework empty abbrev table omitting
There were two problems with the original implementation:
1. It changed the behavior of insert-abbrev-table-description when
READABLE is nil to sometimes insert one Emacs Lisp expression and
sometimes insert nothing.
2. It broke the tests.
This commit reworks this so that insert-abbrev-table-description
always inserts an expressions even if no abbrevs need to be saved and
making only write-abbrev-file check that a table has any abbrevs to
save before calling insert-abbrev-table-description. This duplicates
the work of filtering the table for savable abbrevs, but the benefit
of keeping the API is worth it.
* doc/lispref/abbrevs.texi (Abbrev Tables): Update documentation.
* lisp/abbrev.el (write-abbrev-file): Skip tables without user abbrevs
(insert-abbrev-table-description): Always insert the define
expression.
(abbrev--table-symbols): New function.
* test/lisp/abbrev-tests.el (abbrev--table-symbols-test):
Add test for abbrev--table-symbols.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/abbrev-tests.el | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/lisp/abbrev-tests.el b/test/lisp/abbrev-tests.el index facf097815e..e50f931cef5 100644 --- a/test/lisp/abbrev-tests.el +++ b/test/lisp/abbrev-tests.el | |||
| @@ -64,6 +64,14 @@ | |||
| 64 | (should (= (length table) obarray-default-size)) | 64 | (should (= (length table) obarray-default-size)) |
| 65 | (should (eq (abbrev-table-get table 'foo) 'bar)))) | 65 | (should (eq (abbrev-table-get table 'foo) 'bar)))) |
| 66 | 66 | ||
| 67 | (ert-deftest abbrev--table-symbols-test () | ||
| 68 | (let ((ert-test-abbrevs (setup-test-abbrev-table))) | ||
| 69 | (define-abbrev ert-test-abbrevs "sys" "system abbrev" nil :system t) | ||
| 70 | (should (equal (mapcar #'symbol-name (abbrev--table-symbols 'ert-test-abbrevs)) | ||
| 71 | '("a-e-t"))) | ||
| 72 | (should (equal (mapcar #'symbol-name (abbrev--table-symbols 'ert-test-abbrevs t)) | ||
| 73 | '("a-e-t" "sys"))))) | ||
| 74 | |||
| 67 | (ert-deftest abbrev-table-get-put-test () | 75 | (ert-deftest abbrev-table-get-put-test () |
| 68 | (let ((table (make-abbrev-table))) | 76 | (let ((table (make-abbrev-table))) |
| 69 | (should-not (abbrev-table-get table 'foo)) | 77 | (should-not (abbrev-table-get table 'foo)) |