changeset 3950:4cc3828e29bb

[xemacs-hg @ 2007-05-12 13:12:26 by aidan] Have set-buffer-file-coding-system mark the buffer as modified.
author aidan
date Sat, 12 May 2007 13:12:28 +0000
parents 33b9323388c5
children 20ac78313587
files lisp/ChangeLog lisp/code-files.el
diffstat 2 files changed, 41 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Sat May 12 10:59:17 2007 +0000
+++ b/lisp/ChangeLog	Sat May 12 13:12:28 2007 +0000
@@ -1,3 +1,12 @@
+2007-04-30  Aidan Kehoe  <kehoea@parhasard.net>
+
+	* code-files.el (set-buffer-file-coding-system):
+	Make set-buffer-file-coding-system update the buffer's modified
+	flag. Also make it accept a new flag, NOMODIFY, taken from GNU, to
+	suppress this behaviour.
+	* code-files.el (insert-file-contents):
+	Use the NOMODIFY flag when calling set-buffer-file-coding-system.
+
 2007-05-12  Aidan Kehoe  <kehoea@parhasard.net>
 
 	* bytecomp.el (byte-compile-insert-header):
@@ -11,7 +20,7 @@
 	* dumped-lisp.el (preloaded-file-list): Move resize-minibuffer
 	before simple.
 
-	* resize-minibuffer.el: Remove CVS $Id: ChangeLog,v 1.794 2007/05/12 10:17:00 aidan Exp $ cookie..
+	* resize-minibuffer.el: Remove CVS $Id: ChangeLog,v 1.795 2007/05/12 13:12:26 aidan Exp $ cookie..
 
 	* resize-minibuffer.el (resize-minibuffer-mode): Remove autoload.
 
--- a/lisp/code-files.el	Sat May 12 10:59:17 2007 +0000
+++ b/lisp/code-files.el	Sat May 12 13:12:28 2007 +0000
@@ -105,20 +105,36 @@
 `buffer-file-coding-system-for-read', but is overridden by
 `coding-system-for-read'.")
 
-(defun set-buffer-file-coding-system (coding-system &optional force)
-  "Set buffer-file-coding-system of the current buffer to CODING-SYSTEM.
-If optional argument FORCE (interactively, the prefix argument) is not
-given, attempt to match the EOL type of the new coding system to
-the current value of `buffer-file-coding-system'."
-  (interactive "zFile coding system: \nP")
-  (get-coding-system coding-system) ;; correctness check
-  (if (not force)
-      (setq coding-system
+(defun set-buffer-file-coding-system (coding-system &optional force nomodify)
+  "Set the file coding-system of the current buffer to CODING-SYSTEM.
+This means that when you save the buffer, it will be converted
+according to CODING-SYSTEM.  For a list of possible values of CODING-SYSTEM,
+use \\[list-coding-systems].
+
+If CODING-SYSTEM leaves the text conversion unspecified, or if it
+leaves the end-of-line conversion unspecified, FORCE controls what to
+do.  If FORCE is nil, get the unspecified aspect (or aspects) from the
+buffer's previous `buffer-file-coding-system' value (if it is
+specified there).  Otherwise, leave it unspecified.
+
+This marks the buffer modified so that the succeeding \\[save-buffer]
+surely saves the buffer with CODING-SYSTEM.  From a program, if you
+don't want to mark the buffer modified, specify t for NOMODIFY.
+If you know exactly what coding system you want to use,
+just set the variable `buffer-file-coding-system' directly."
+  (interactive "zCoding system for saving file (default nil): \nP")
+  (check-coding-system coding-system)
+  (if (and coding-system buffer-file-coding-system (null force))
+       (setq coding-system
 	    (subsidiary-coding-system
 	     coding-system
 	     (coding-system-eol-type buffer-file-coding-system))))
-  (setq buffer-file-coding-system coding-system)
-  (redraw-modeline t))
+   (setq buffer-file-coding-system coding-system)
+  ;; XEmacs change; remove a call to ucs-set-table-for-input, which we don't
+  ;; have. 
+  (unless nomodify
+    (set-buffer-modified-p t))
+  (force-mode-line-update))
 
 (defun toggle-buffer-file-coding-system ()
   "Set EOL type of buffer-file-coding-system of the current buffer to
@@ -456,10 +472,11 @@
 	      ;; set its eol type to what was found, if it wasn't
 	      ;; set already.
 	      (set-buffer-file-coding-system
-	       (subsidiary-coding-system buffer-file-coding-system
-					 (coding-system-eol-type coding-system)) t)
+	       (subsidiary-coding-system 
+                buffer-file-coding-system
+                (coding-system-eol-type coding-system)) t t)
 	    ;; otherwise actually set buffer-file-coding-system.
-	    (set-buffer-file-coding-system coding-system t)))
+	    (set-buffer-file-coding-system coding-system t t)))
 	;; ... and `buffer-file-coding-system-when-loaded'.  the machinations
 	;; of set-buffer-file-coding-system cause the actual coding system
 	;; object to be stored, so do that here, too.