aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeo Liu2011-03-22 23:38:40 +0800
committerLeo Liu2011-03-22 23:38:40 +0800
commit4b978a677c2f684d7988cdd2dccb73d109c6bb1e (patch)
tree2953389f2b2714bdd00afbbd00604361dcc4feea
parent0b1596c6ad031990c4c73029d235840ad6cbb536 (diff)
downloademacs-4b978a677c2f684d7988cdd2dccb73d109c6bb1e.tar.gz
emacs-4b978a677c2f684d7988cdd2dccb73d109c6bb1e.zip
Use utf-8 if safe for writing to abbrev file
and fall back on emacs-mule or utf-8-emacs.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/abbrev.el36
2 files changed, 28 insertions, 14 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c90d4e5e3ba..6b7dd5a0463 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12011-03-22 Leo Liu <sdl.web@gmail.com>
2
3 * abbrev.el (write-abbrev-file): Use utf-8 for writing if it can
4 encode all chars in abbrevs; otherwise use emacs-mule or
5 utf-8-emacs. (Bug#8308)
6
12011-03-22 Juanma Barranquero <lekktu@gmail.com> 72011-03-22 Juanma Barranquero <lekktu@gmail.com>
2 8
3 * simple.el (backward-delete-char-untabify): 9 * simple.el (backward-delete-char-untabify):
diff --git a/lisp/abbrev.el b/lisp/abbrev.el
index fbca214a649..3b383a5f5b8 100644
--- a/lisp/abbrev.el
+++ b/lisp/abbrev.el
@@ -225,21 +225,29 @@ specified in `abbrev-file-name' is used."
225 abbrev-file-name))) 225 abbrev-file-name)))
226 (or (and file (> (length file) 0)) 226 (or (and file (> (length file) 0))
227 (setq file abbrev-file-name)) 227 (setq file abbrev-file-name))
228 (let ((coding-system-for-write 'emacs-mule)) 228 (let ((coding-system-for-write 'utf-8))
229 (with-temp-file file 229 (with-temp-buffer
230 (insert ";;-*-coding: emacs-mule;-*-\n")
231 (dolist (table 230 (dolist (table
232 ;; We sort the table in order to ease the automatic 231 ;; We sort the table in order to ease the automatic
233 ;; merging of different versions of the user's abbrevs 232 ;; merging of different versions of the user's abbrevs
234 ;; file. This is useful, for example, for when the 233 ;; file. This is useful, for example, for when the
235 ;; user keeps their home directory in a revision 234 ;; user keeps their home directory in a revision
236 ;; control system, and is therefore keeping multiple 235 ;; control system, and is therefore keeping multiple
237 ;; slightly-differing copies loosely synchronized. 236 ;; slightly-differing copies loosely synchronized.
238 (sort (copy-sequence abbrev-table-name-list) 237 (sort (copy-sequence abbrev-table-name-list)
239 (lambda (s1 s2) 238 (lambda (s1 s2)
240 (string< (symbol-name s1) 239 (string< (symbol-name s1)
241 (symbol-name s2))))) 240 (symbol-name s2)))))
242 (insert-abbrev-table-description table nil))))) 241 (insert-abbrev-table-description table nil))
242 (when (unencodable-char-position (point-min) (point-max) 'utf-8)
243 (setq coding-system-for-write
244 (if (> emacs-major-version 24)
245 'utf-8-emacs
246 ;; For compatibility with Emacs 22 (See Bug#8308)
247 'emacs-mule)))
248 (goto-char (point-min))
249 (insert (format ";;-*-coding: %s;-*-\n" coding-system-for-write))
250 (write-region nil nil file nil 0))))
243 251
244(defun add-mode-abbrev (arg) 252(defun add-mode-abbrev (arg)
245 "Define mode-specific abbrev for last word(s) before point. 253 "Define mode-specific abbrev for last word(s) before point.