Message272

Author aidan
Recipients acs, xemacs-beta
Date 2008-01-19.06:43:06
Content
Ar an naoiú lá de mí na Nollaig, scríobh Vin Shelton: 

 > On Dec 9, 2007 12:34 PM, Aidan Kehoe <kehoea@parhasard.net> wrote:
 > >
 > >  Ar an t-ochtú lá de mí na Nollaig, scríobh Uwe Brauer:
 > >
 > >  >    > (setq-default buffer-file-coding-system 'utf-8)
 > >  >
 > >  > Now I remember the problem with this is that it converts my abbrev
 > >  > table using UTF-8 and then I can't use it anymore with xemacs no mule!
 > >
 > > Thanks for the report; I've fixed this in the trunk, but I don't have the
 > > right to apply the change to 21.4.
 > 
 > Can you please send me a 21.4 patch for review?

Sure. This differs from the output of hg tip -p slightly, and provokes a
couple of byte-compile-time warning on no-Mule 21.4.

lisp/ChangeLog addition:

2007-12-09  Aidan Kehoe  <kehoea@parhasard.net>

	* abbrev.el (write-abbrev-file):
	Write FILE using escape-quoted, as a coding system. Add a coding
	cookie to specify exactly what coding system was used; if
        coding-system-name is not used, this will always be binary. 

Index: lisp/abbrev.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lisp/abbrev.el,v
retrieving revision 1.5
diff -u -u -r1.5 abbrev.el
--- lisp/abbrev.el	2001/04/12 18:21:09	1.5
+++ lisp/abbrev.el	2007/12/09 19:46:15
@@ -392,8 +392,11 @@

 (defun write-abbrev-file (file)
   "Write all abbrev definitions to a file of Lisp code.
+This does not include system abbrevs; it includes only the abbrev tables
+listed in listed in `abbrev-table-name-list'.
 The file written can be loaded in another session to define the same abbrevs.
-The argument FILE is the file name to write."
+The argument FILE is the file name to write.  If omitted or nil, the file
+specified in `abbrev-file-name' is used."
   (interactive
    (list
     (read-file-name "Write abbrev file: "
@@ -401,15 +404,21 @@
 		    abbrev-file-name)))
   (or (and file (> (length file) 0))
       (setq file abbrev-file-name))
-  (save-excursion
-   (set-buffer (get-buffer-create " write-abbrev-file"))
-   (erase-buffer)
-   (let ((tables abbrev-table-name-list))
-     (while tables
-       (insert-abbrev-table-description (car tables) nil)
-       (setq tables (cdr tables))))
-   (write-region 1 (point-max) file)
-   (erase-buffer)))
+  (let ((coding-system-for-write 'escape-quoted))
+    (with-temp-file file
+      ;; XEmacs change; not emacs-mule, and use the coding system
+      ;; escape-quoted resolves to, which will differ depending on whether
+      ;; the build is Mule or not.
+      (insert (format ";;-*-coding: %s;-*-\n"
+		      (or (and (fboundp #'coding-system-name)
+			       (coding-system-name
+				(find-coding-system coding-system-for-write)))
+			  "binary")))
+      (dolist (table
+               ;; XEmacs change; we keep the table sorted at runtime, no
+               ;; need to sort it here.
+               abbrev-table-name-list)
+        (insert-abbrev-table-description table nil)))))

 (defun abbrev-string-to-be-defined (arg)
   "Return the string for which an abbrev will be defined.
History
Date User Action Args
2008-01-19 06:43:06aidanlinkissue179 messages
2008-01-19 06:43:06aidancreate