changeset 45749:8dd957dbfbcc

(format-alist): Document new element PRESERVE. (format-write-file): Implement PRESERVE elt for a format.
author Richard M. Stallman <rms@gnu.org>
date Tue, 11 Jun 2002 19:26:45 +0000
parents b082a134b8bc
children 73b33fa2ec78
files lisp/format.el
diffstat 1 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/format.el	Tue Jun 11 19:25:48 2002 +0000
+++ b/lisp/format.el	Tue Jun 11 19:26:45 2002 +0000
@@ -140,7 +140,10 @@
 
 MODE-FN, if specified, is called when visiting a file with that format.
          It is called with a single positive argument, on the assumption
-         that it turns on some Emacs mode.")
+         that it turns on some Emacs mode.
+
+PRESERVE, if non-nil, means that `format-write-file' should not remove
+          this format from `buffer-file-formats'.")
 
 ;;; Basic Functions (called from Lisp)
 
@@ -371,7 +374,16 @@
 	  (fmt (format-read (format "Write file `%s' in format: "
 				    (file-name-nondirectory file)))))
      (list file fmt)))
-  (setq buffer-file-format format)
+  (let ((old-formats buffer-file-format)
+	preserve-formats)
+    (dolist (fmt old-formats)
+      (let ((aelt (assq fmt format-alist)))
+	(if (nth 7 aelt)
+	    (push fmt preserve-formats))))
+    (setq buffer-file-format format)
+    (dolist (fmt preserve-formats)
+      (unless (memq fmt buffer-file-format)
+	(setq buffer-file-format (append buffer-file-format (list fmt))))))
   (write-file filename))
 
 (defun format-find-file (filename format)