aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/lispref/abbrevs.texi4
-rw-r--r--etc/NEWS6
-rw-r--r--lisp/abbrev.el85
3 files changed, 54 insertions, 41 deletions
diff --git a/doc/lispref/abbrevs.texi b/doc/lispref/abbrevs.texi
index 087e6945203..4c9e653cb19 100644
--- a/doc/lispref/abbrevs.texi
+++ b/doc/lispref/abbrevs.texi
@@ -122,7 +122,9 @@ System abbrevs are listed and identified as such. Otherwise the
122description is a Lisp expression---a call to @code{define-abbrev-table} 122description is a Lisp expression---a call to @code{define-abbrev-table}
123that would define @var{name} as it is currently defined, but without 123that would define @var{name} as it is currently defined, but without
124the system abbrevs. (The mode or package using @var{name} is supposed 124the system abbrevs. (The mode or package using @var{name} is supposed
125to add these to @var{name} separately.) 125to add these to @var{name} separately.) If the Lisp expression would
126not define any abbrevs (i.e.@: it defines an empty abbrev table), this
127function inserts nothing.
126@end defun 128@end defun
127 129
128@node Defining Abbrevs 130@node Defining Abbrevs
diff --git a/etc/NEWS b/etc/NEWS
index 354072fc814..474af167e83 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -247,6 +247,12 @@ case does not match.
247for abbrevs that have them. 247for abbrevs that have them.
248 248
249+++ 249+++
250** 'insert-abbrev-table-description' skips empty tables.
251'insert-abbrev-table-description' skips inserting empty tables when
252inserting non-readable tables. By extension, this makes
253'write-abbrev-file' skip writing empty tables.
254
255+++
250** The new functions and commands 'text-property-search-forward' and 256** The new functions and commands 'text-property-search-forward' and
251'text-property-search-backward' have been added. These provide an 257'text-property-search-backward' have been added. These provide an
252interface that's more like functions like @code{search-forward}. 258interface that's more like functions like @code{search-forward}.
diff --git a/lisp/abbrev.el b/lisp/abbrev.el
index cddce8f5294..e1fd366ba9e 100644
--- a/lisp/abbrev.el
+++ b/lisp/abbrev.el
@@ -896,24 +896,22 @@ is not undone."
896 896
897(defun abbrev--write (sym) 897(defun abbrev--write (sym)
898 "Write the abbrev in a `read'able form. 898 "Write the abbrev in a `read'able form.
899Only writes the non-system abbrevs.
900Presumes that `standard-output' points to `current-buffer'." 899Presumes that `standard-output' points to `current-buffer'."
901 (unless (or (null (symbol-value sym)) (abbrev-get sym :system)) 900 (insert " (")
902 (insert " (") 901 (prin1 (symbol-name sym))
903 (prin1 (symbol-name sym)) 902 (insert " ")
904 (insert " ") 903 (prin1 (symbol-value sym))
905 (prin1 (symbol-value sym)) 904 (insert " ")
906 (insert " ") 905 (prin1 (symbol-function sym))
907 (prin1 (symbol-function sym)) 906 (insert " :count ")
908 (insert " :count ") 907 (prin1 (abbrev-get sym :count))
909 (prin1 (abbrev-get sym :count)) 908 (when (abbrev-get sym :case-fixed)
910 (when (abbrev-get sym :case-fixed) 909 (insert " :case-fixed ")
911 (insert " :case-fixed ") 910 (prin1 (abbrev-get sym :case-fixed)))
912 (prin1 (abbrev-get sym :case-fixed))) 911 (when (abbrev-get sym :enable-function)
913 (when (abbrev-get sym :enable-function) 912 (insert " :enable-function ")
914 (insert " :enable-function ") 913 (prin1 (abbrev-get sym :enable-function)))
915 (prin1 (abbrev-get sym :enable-function))) 914 (insert ")\n"))
916 (insert ")\n")))
917 915
918(defun abbrev--describe (sym) 916(defun abbrev--describe (sym)
919 (when (symbol-value sym) 917 (when (symbol-value sym)
@@ -934,31 +932,38 @@ Presumes that `standard-output' points to `current-buffer'."
934 "Insert before point a full description of abbrev table named NAME. 932 "Insert before point a full description of abbrev table named NAME.
935NAME is a symbol whose value is an abbrev table. 933NAME is a symbol whose value is an abbrev table.
936If optional 2nd arg READABLE is non-nil, a human-readable description 934If optional 2nd arg READABLE is non-nil, a human-readable description
937is inserted. Otherwise the description is an expression, 935is inserted.
938a call to `define-abbrev-table', which would 936
939define the abbrev table NAME exactly as it is currently defined. 937If READABLE is nil, an expression is inserted. The expression is
940 938a call to `define-abbrev-table' that when evaluated will define
941Abbrevs marked as \"system abbrevs\" are omitted." 939the abbrev table NAME exactly as it is currently defined.
940Abbrevs marked as \"system abbrevs\" are ignored. If the
941resulting expression would not define any abbrevs, nothing is
942inserted."
942 (let ((table (symbol-value name)) 943 (let ((table (symbol-value name))
943 (symbols ())) 944 (symbols ()))
944 (mapatoms (lambda (sym) (if (symbol-value sym) (push sym symbols))) table) 945 (mapatoms (lambda (sym)
945 (setq symbols (sort symbols 'string-lessp)) 946 (if (and (symbol-value sym) (or readable (not (abbrev-get sym :system))))
946 (let ((standard-output (current-buffer))) 947 (push sym symbols)))
947 (if readable 948 table)
948 (progn 949 (when symbols
949 (insert "(") 950 (setq symbols (sort symbols 'string-lessp))
950 (prin1 name) 951 (let ((standard-output (current-buffer)))
951 (insert ")\n\n") 952 (if readable
952 (mapc 'abbrev--describe symbols) 953 (progn
953 (insert "\n\n")) 954 (insert "(")
954 (insert "(define-abbrev-table '") 955 (prin1 name)
955 (prin1 name) 956 (insert ")\n\n")
956 (if (null symbols) 957 (mapc 'abbrev--describe symbols)
957 (insert " '())\n\n") 958 (insert "\n\n"))
958 (insert "\n '(\n") 959 (insert "(define-abbrev-table '")
959 (mapc 'abbrev--write symbols) 960 (prin1 name)
960 (insert " ))\n\n"))) 961 (if (null symbols)
961 nil))) 962 (insert " '())\n\n")
963 (insert "\n '(\n")
964 (mapc 'abbrev--write symbols)
965 (insert " ))\n\n")))
966 nil))))
962 967
963(defun define-abbrev-table (tablename definitions 968(defun define-abbrev-table (tablename definitions
964 &optional docstring &rest props) 969 &optional docstring &rest props)