comparison lisp/abbrev.el @ 4319:74d00c7cc134

Specify coding-system-for-write, add a coding cookie in #'write-abbrev-file. 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 (escape-quoted is aliased to binary on non-Mule). Thank you for the bug report, Uwe Brauer. This bug would have been resolved ages ago if we had merged Dave Love's 2002 changes from GNU. Nope, I didn't merge the whole file when doing this.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 09 Dec 2007 18:31:41 +0100
parents 7147a4dabc02
children d27c1ee1943b 308d34e9f07d
comparison
equal deleted inserted replaced
4318:4d0f773d5e21 4319:74d00c7cc134
419 ;(interactive "fRead abbrev file: ") 419 ;(interactive "fRead abbrev file: ")
420 (read-abbrev-file file t)) 420 (read-abbrev-file file t))
421 421
422 (defun write-abbrev-file (file) 422 (defun write-abbrev-file (file)
423 "Write all abbrev definitions to a file of Lisp code. 423 "Write all abbrev definitions to a file of Lisp code.
424 This does not include system abbrevs; it includes only the abbrev tables
425 listed in listed in `abbrev-table-name-list'.
424 The file written can be loaded in another session to define the same abbrevs. 426 The file written can be loaded in another session to define the same abbrevs.
425 The argument FILE is the file name to write." 427 The argument FILE is the file name to write. If omitted or nil, the file
428 specified in `abbrev-file-name' is used."
426 (interactive 429 (interactive
427 (list 430 (list
428 (read-file-name "Write abbrev file: " 431 (read-file-name "Write abbrev file: "
429 (file-name-directory (expand-file-name abbrev-file-name)) 432 (file-name-directory (expand-file-name abbrev-file-name))
430 abbrev-file-name))) 433 abbrev-file-name)))
431 (or (and file (> (length file) 0)) 434 (or (and file (> (length file) 0))
432 (setq file abbrev-file-name)) 435 (setq file abbrev-file-name))
433 (save-excursion 436 (let ((coding-system-for-write 'escape-quoted))
434 (set-buffer (get-buffer-create " write-abbrev-file")) 437 (with-temp-file file
435 (erase-buffer) 438 ;; XEmacs change; not emacs-mule, and use the coding system
436 (let ((tables abbrev-table-name-list)) 439 ;; escape-quoted resolves to, which will differ depending on whether
437 (while tables 440 ;; the build is Mule or not.
438 (insert-abbrev-table-description (car tables) nil) 441 (insert (format ";;-*-coding: %s;-*-\n"
439 (setq tables (cdr tables)))) 442 (coding-system-name
440 (write-region 1 (point-max) file) 443 (find-coding-system coding-system-for-write))))
441 (erase-buffer))) 444 (dolist (table
445 ;; XEmacs change; we keep the table sorted at runtime, no
446 ;; need to sort it here.
447 abbrev-table-name-list)
448 (insert-abbrev-table-description table nil)))))
442 449
443 (defun abbrev-string-to-be-defined (arg) 450 (defun abbrev-string-to-be-defined (arg)
444 "Return the string for which an abbrev will be defined. 451 "Return the string for which an abbrev will be defined.
445 ARG is the argument to `add-global-abbrev' or `add-mode-abbrev'." 452 ARG is the argument to `add-global-abbrev' or `add-mode-abbrev'."
446 (if (and (not arg) (region-active-p)) (setq arg 0) 453 (if (and (not arg) (region-active-p)) (setq arg 0)