X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/4f9d7df139695e97cd1772d41940500480585df7..19998f14b67de66754081cacdbca5668680c41ba:/lisp/format.el diff --git a/lisp/format.el b/lisp/format.el index b58a265dcc..27253a2c47 100644 --- a/lisp/format.el +++ b/lisp/format.el @@ -1,7 +1,7 @@ ;;; format.el --- read and save files in multiple formats ;; Copyright (C) 1994, 1995, 1997, 1999, 2001, 2002, 2003, 2004, -;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +;; 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. ;; Author: Boris Goldowsky @@ -96,7 +96,8 @@ nil iso-spanish iso-cvt-read-only t nil)) "List of information about understood file formats. -Elements are of the form \(NAME DOC-STR REGEXP FROM-FN TO-FN MODIFY MODE-FN). +Elements are of the form +\(NAME DOC-STR REGEXP FROM-FN TO-FN MODIFY MODE-FN PRESERVE). NAME is a symbol, which is stored in `buffer-file-format'. @@ -217,6 +218,9 @@ For most purposes, consider using `format-encode-region' instead." (multibyte enable-multibyte-characters) (coding-system buffer-file-coding-system)) (with-current-buffer copy-buf + (set (make-local-variable + 'write-region-post-annotation-function) + 'kill-buffer) (setq selective-display sel-disp) (set-buffer-multibyte multibyte) (setq buffer-file-coding-system coding-system)) @@ -358,13 +362,19 @@ one of the formats defined in `format-alist', or a list of such symbols." (setq format (cdr format))))))) (defun format-write-file (filename format &optional confirm) - "Write current buffer into file FILENAME using some FORMAT. -Make buffer visit that file and set the format as the default for future -saves. If the buffer is already visiting a file, you can specify a directory -name as FILENAME, to write a file of the same old name in that directory. - -If optional third arg CONFIRM is non-nil, ask for confirmation before -overwriting an existing file. Interactively, confirmation is required + "Write current buffer into FILENAME, using a format based on FORMAT. +Constructs the actual format starting from FORMAT, then appending +any elements from the value of `buffer-file-format' with a non-nil +`preserve' flag (see the documentation of `format-alist'), if they +are not already present in FORMAT. It then updates `buffer-file-format' +with this format, making it the default for future saves. + +If the buffer is already visiting a file, you can specify a +directory name as FILENAME, to write a file of the same old name +in that directory. + +If optional third arg CONFIRM is non-nil, asks for confirmation before +overwriting an existing file. Interactively, requires confirmation unless you supply a prefix argument." (interactive ;; Same interactive spec as write-file, plus format question.