Commit 0f5cc9a0 authored by Allen Li's avatar Allen Li Committed by Noam Postavsky

Preserve special abbrev properties when writing

Fixes bug#29924

* lisp/abbrev.el (abbrev--write): Write abbrev properties when set.
parent 5b464a9c
......@@ -122,6 +122,11 @@ characters that quote text "like this" are replaced by double
typographic quotes, “like this”, in text modes, and in comments in
non-text modes.
---
** 'write-abbrev-file' now includes special properties.
'write-abbrev-file' now writes special properties like ':case-fixed'
for abbrevs that have them.
* Changes in Specialized Modes and Packages in Emacs 27.1
......
......@@ -908,8 +908,14 @@ Presumes that `standard-output' points to `current-buffer'."
(prin1 (symbol-value sym))
(insert " ")
(prin1 (symbol-function sym))
(insert " ")
(insert " :count ")
(prin1 (abbrev-get sym :count))
(when (abbrev-get sym :case-fixed)
(insert " :case-fixed ")
(prin1 (abbrev-get sym :case-fixed)))
(when (abbrev-get sym :enable-function)
(insert " :enable-function ")
(prin1 (abbrev-get sym :enable-function)))
(insert ")\n")))
(defun abbrev--describe (sym)
......
......@@ -38,6 +38,12 @@
(abbrev-table-put ert-test-abbrevs :ert-test "ert-test-value")
ert-test-abbrevs)
(defun setup-test-abbrev-table-with-props ()
(defvar ert-test-abbrevs nil)
(define-abbrev-table 'ert-test-abbrevs '(("fb" "fooBar" nil :case-fixed t)))
(abbrev-table-put ert-test-abbrevs :ert-test "ert-test-value")
ert-test-abbrevs)
(ert-deftest abbrev-table-p-test ()
(should-not (abbrev-table-p 42))
(should-not (abbrev-table-p "aoeu"))
......@@ -230,6 +236,17 @@
(should (equal "abbrev-ert-test" (abbrev-expansion "a-e-t" ert-test-abbrevs)))
(delete-file temp-test-file)))
(ert-deftest read-write-abbrev-file-test-with-props ()
"Test reading and writing abbrevs from file"
(let ((temp-test-file (make-temp-file "ert-abbrev-test"))
(ert-test-abbrevs (setup-test-abbrev-table-with-props)))
(write-abbrev-file temp-test-file)
(clear-abbrev-table ert-test-abbrevs)
(should (abbrev-table-empty-p ert-test-abbrevs))
(read-abbrev-file temp-test-file)
(should (equal "fooBar" (abbrev-expansion "fb" ert-test-abbrevs)))
(delete-file temp-test-file)))
(ert-deftest abbrev-edit-save-to-file-test ()
"Test saving abbrev definitions in buffer to file"
(defvar ert-save-test-table nil)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment