unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#29924: 25.3; write-abbrev-file does not preserve abbrev properties
@ 2018-01-01  3:47 Allen Li
  2018-01-01  4:18 ` bug#29924: [PATCH] Preserve special abbrev properties when writing Allen Li
  0 siblings, 1 reply; 10+ messages in thread
From: Allen Li @ 2018-01-01  3:47 UTC (permalink / raw)
  To: 29924

Steps:

Create abbrevs_defs file with contents:

  (define-abbrev-table 'python-mode-abbrev-table
    '(
      ("NT" "NamedTuple" nil :count 0 :case-fixed t)
     ))

Load abbrevs_defs.  Write abbrevs with write-abbrev-file

Expected: File contains something like:

  (define-abbrev-table 'python-mode-abbrev-table
    '(
      ("NT" "NamedTuple" nil :count 0 :case-fixed t)
     ))

Actual:  :case-fixed is missing:

  (define-abbrev-table 'python-mode-abbrev-table
    '(
      ("NT" "NamedTuple" nil 0)
     ))

In GNU Emacs 25.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.26)
 of 2017-12-04 built on arojas
Windowing system distributor 'The X.Org Foundation', version 11.0.11905000
Configured using:
 'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
 --localstatedir=/var --with-x-toolkit=gtk3 --with-xft --with-modules
 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong
 -fno-plt' CPPFLAGS=-D_FORTIFY_SOURCE=2
 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now'





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#29924: [PATCH] Preserve special abbrev properties when writing
  2018-01-01  3:47 bug#29924: 25.3; write-abbrev-file does not preserve abbrev properties Allen Li
@ 2018-01-01  4:18 ` Allen Li
  2018-01-23  8:19   ` Allen Li
  0 siblings, 1 reply; 10+ messages in thread
From: Allen Li @ 2018-01-01  4:18 UTC (permalink / raw)
  To: 29924

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

Attached patch

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

From 71ff941f82036ecc2136937bec5902d388617634 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.
---
 lisp/abbrev.el | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lisp/abbrev.el b/lisp/abbrev.el
index dbda5b5d2e..5faffd4e17 100644
--- a/lisp/abbrev.el
+++ b/lisp/abbrev.el
@@ -910,6 +910,12 @@ abbrev--write
     (prin1 (symbol-function sym))
     (insert " ")
     (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)
-- 
2.15.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* bug#29924: [PATCH] Preserve special abbrev properties when writing
  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
  0 siblings, 1 reply; 10+ messages in thread
From: Allen Li @ 2018-01-23  8:19 UTC (permalink / raw)
  To: 29924

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

Apologies, the original patch is incorrect because define-abbrev
requires passing :count as a keyword argument unlike the obsolete
calling convention.

Attached is a new patch, which unfortunately does not preserve the old
abbrev file writing format. However, any recent version of Emacs will
be able to accept this format for define-abbrev, and the previously
written abbrev file format is documented as obsolete, so now is as
good a time as any.

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

From 1e7085c87b0ac5726333f6bd88fa3e0fa4417410 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.
---
 lisp/abbrev.el | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lisp/abbrev.el b/lisp/abbrev.el
index 734cefbb7b..f2eaab039e 100644
--- a/lisp/abbrev.el
+++ b/lisp/abbrev.el
@@ -909,7 +909,14 @@ abbrev--write
     (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)
-- 
2.16.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* bug#29924: [PATCH] Preserve special abbrev properties when writing
  2018-01-23  8:19   ` Allen Li
@ 2018-01-27  2:12     ` Noam Postavsky
  2018-01-27  2:48       ` Allen Li
  0 siblings, 1 reply; 10+ messages in thread
From: Noam Postavsky @ 2018-01-27  2:12 UTC (permalink / raw)
  To: Allen Li; +Cc: 29924

Allen Li <vianchielfaura@gmail.com> writes:

> Apologies, the original patch is incorrect because define-abbrev
> requires passing :count as a keyword argument unlike the obsolete
> calling convention.
>
> Attached is a new patch, which unfortunately does not preserve the old
> abbrev file writing format. However, any recent version of Emacs will
> be able to accept this format for define-abbrev, and the previously
> written abbrev file format is documented as obsolete, so now is as
> good a time as any.

I think it would be helpful to have a basic test to ensure we preserve
round-tripping.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#29924: [PATCH] Preserve special abbrev properties when writing
  2018-01-27  2:12     ` Noam Postavsky
@ 2018-01-27  2:48       ` Allen Li
  2018-01-27 12:19         ` Noam Postavsky
  0 siblings, 1 reply; 10+ messages in thread
From: Allen Li @ 2018-01-27  2:48 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 29924

On Fri, Jan 26, 2018 at 6:12 PM, Noam Postavsky
<npostavs@users.sourceforge.net> wrote:
> Allen Li <vianchielfaura@gmail.com> writes:
>
>> Apologies, the original patch is incorrect because define-abbrev
>> requires passing :count as a keyword argument unlike the obsolete
>> calling convention.
>>
>> Attached is a new patch, which unfortunately does not preserve the old
>> abbrev file writing format. However, any recent version of Emacs will
>> be able to accept this format for define-abbrev, and the previously
>> written abbrev file format is documented as obsolete, so now is as
>> good a time as any.
>
> I think it would be helpful to have a basic test to ensure we preserve
> round-tripping.

What round-tripping are you referring to?





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#29924: [PATCH] Preserve special abbrev properties when writing
  2018-01-27  2:48       ` Allen Li
@ 2018-01-27 12:19         ` Noam Postavsky
  2018-01-30 21:49           ` Allen Li
  0 siblings, 1 reply; 10+ messages in thread
From: Noam Postavsky @ 2018-01-27 12:19 UTC (permalink / raw)
  To: Allen Li; +Cc: 29924

Allen Li <vianchielfaura@gmail.com> writes:

>> I think it would be helpful to have a basic test to ensure we preserve
>> round-tripping.
>
> What round-tripping are you referring to?

I meant writing the abbrevs out and then reading them back again should
end up with the same set of abbrevs, which should make a good test case.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#29924: [PATCH] Preserve special abbrev properties when writing
  2018-01-27 12:19         ` Noam Postavsky
@ 2018-01-30 21:49           ` Allen Li
  2018-02-01  2:12             ` Noam Postavsky
  0 siblings, 1 reply; 10+ messages in thread
From: Allen Li @ 2018-01-30 21:49 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 29924

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

On Sat, Jan 27, 2018 at 4:19 AM, Noam Postavsky
<npostavs@users.sourceforge.net> wrote:
> Allen Li <vianchielfaura@gmail.com> writes:
>
>>> I think it would be helpful to have a basic test to ensure we preserve
>>> round-tripping.
>>
>> What round-tripping are you referring to?
>
> I meant writing the abbrevs out and then reading them back again should
> end up with the same set of abbrevs, which should make a good test case.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#29924: [PATCH] Preserve special abbrev properties when writing
  2018-01-30 21:49           ` Allen Li
@ 2018-02-01  2:12             ` Noam Postavsky
  2018-02-16  5:40               ` Allen Li
  0 siblings, 1 reply; 10+ messages in thread
From: Noam Postavsky @ 2018-02-01  2:12 UTC (permalink / raw)
  To: Allen Li; +Cc: 29924

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.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#29924: [PATCH] Preserve special abbrev properties when writing
  2018-02-01  2:12             ` Noam Postavsky
@ 2018-02-16  5:40               ` Allen Li
  2018-02-17 14:11                 ` Noam Postavsky
  0 siblings, 1 reply; 10+ messages in thread
From: Allen Li @ 2018-02-16  5:40 UTC (permalink / raw)
  To: Noam Postavsky; +Cc: 29924

[-- 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


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* bug#29924: [PATCH] Preserve special abbrev properties when writing
  2018-02-16  5:40               ` Allen Li
@ 2018-02-17 14:11                 ` Noam Postavsky
  0 siblings, 0 replies; 10+ messages in thread
From: Noam Postavsky @ 2018-02-17 14:11 UTC (permalink / raw)
  To: Allen Li; +Cc: 29924, Noam Postavsky

tags 29924 fixed
close 29924 27.1
quit

Allen Li <vianchielfaura@gmail.com> writes:

> 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.

Thanks, pushed to master.

[1: 0f5cc9a085]: 2018-02-17 08:47:20 -0500
  Preserve special abbrev properties when writing
  https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=0f5cc9a085565c4f6d6d7e124a8b2965d8800ae5





^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-02-17 14:11 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2018-02-17 14:11                 ` Noam Postavsky

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).