unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Allen Li <vianchielfaura@gmail.com>
To: Noam Postavsky <npostavs@users.sourceforge.net>
Cc: 29924@debbugs.gnu.org
Subject: bug#29924: [PATCH] Preserve special abbrev properties when writing
Date: Fri, 16 Feb 2018 05:40:35 +0000	[thread overview]
Message-ID: <CAJr1M6cnUSF_X-rh=oyekqT6o+unKZLRmWNZ4kVqS7rN0QM2hA@mail.gmail.com> (raw)
In-Reply-To: <87h8r1h2zx.fsf@users.sourceforge.net>

[-- Attachment #1: Type: text/plain, Size: 450 bytes --]

On Wed, Jan 31, 2018 at 6:12 PM Noam Postavsky <
npostavs@users.sourceforge.net> wrote:

> Allen Li <vianchielfaura@gmail.com> writes:

> > There is already an ERT test for the roundtrip "write, read, compare
> > read to original"

> Ah, so there is.  We should add one testing with abbrev properties then.

Sorry for the delay.  The attached patch contains a test along with the
change.  I have also added a NEWS entry; apologies if I did it wrong.

[-- Attachment #2: 0001-Preserve-special-abbrev-properties-when-writing.patch --]
[-- Type: text/x-patch, Size: 3106 bytes --]

From f9ff4d5828132fe71c495112e943d8438210ea9d Mon Sep 17 00:00:00 2001
From: Allen Li <darkfeline@felesatra.moe>
Date: Sun, 31 Dec 2017 20:14:09 -0800
Subject: [PATCH] Preserve special abbrev properties when writing

Fixes bug#29924

* lisp/abbrev.el (abbrev--write): Write abbrev properties when set.
---
 etc/NEWS                  |  5 +++++
 lisp/abbrev.el            |  8 +++++++-
 test/lisp/abbrev-tests.el | 17 +++++++++++++++++
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/etc/NEWS b/etc/NEWS
index 71569c95ad..e408c00b83 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -103,6 +103,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.
+
 \f
 * Changes in Specialized Modes and Packages in Emacs 27.1
 
diff --git a/lisp/abbrev.el b/lisp/abbrev.el
index 734cefbb7b..197276cc9c 100644
--- a/lisp/abbrev.el
+++ b/lisp/abbrev.el
@@ -908,8 +908,14 @@ abbrev--write
     (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)
diff --git a/test/lisp/abbrev-tests.el b/test/lisp/abbrev-tests.el
index 1187700b84..facf097815 100644
--- a/test/lisp/abbrev-tests.el
+++ b/test/lisp/abbrev-tests.el
@@ -38,6 +38,12 @@ setup-test-abbrev-table
   (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 @@ setup-test-abbrev-table
     (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)
-- 
2.16.1


  reply	other threads:[~2018-02-16  5:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-01  3:47 bug#29924: 25.3; write-abbrev-file does not preserve abbrev properties Allen Li
2018-01-01  4:18 ` bug#29924: [PATCH] Preserve special abbrev properties when writing Allen Li
2018-01-23  8:19   ` Allen Li
2018-01-27  2:12     ` Noam Postavsky
2018-01-27  2:48       ` Allen Li
2018-01-27 12:19         ` Noam Postavsky
2018-01-30 21:49           ` Allen Li
2018-02-01  2:12             ` Noam Postavsky
2018-02-16  5:40               ` Allen Li [this message]
2018-02-17 14:11                 ` Noam Postavsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJr1M6cnUSF_X-rh=oyekqT6o+unKZLRmWNZ4kVqS7rN0QM2hA@mail.gmail.com' \
    --to=vianchielfaura@gmail.com \
    --cc=29924@debbugs.gnu.org \
    --cc=npostavs@users.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).