diff options
| author | Richard M. Stallman | 2002-06-11 19:26:45 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2002-06-11 19:26:45 +0000 |
| commit | 34f30f79b31dbe7e5db45c716e4f34cf9d674542 (patch) | |
| tree | 5dda07e382c81738c1b419f041193c2a18725e56 | |
| parent | 77d18896aac58d7e77b4421971db063b43b58f2d (diff) | |
| download | emacs-34f30f79b31dbe7e5db45c716e4f34cf9d674542.tar.gz emacs-34f30f79b31dbe7e5db45c716e4f34cf9d674542.zip | |
(format-alist): Document new element PRESERVE.
(format-write-file): Implement PRESERVE elt for a format.
| -rw-r--r-- | lisp/format.el | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lisp/format.el b/lisp/format.el index e8298a5d47a..ad7a22bba91 100644 --- a/lisp/format.el +++ b/lisp/format.el | |||
| @@ -140,7 +140,10 @@ MODIFY, if non-nil, means the TO-FN wants to modify the region. If nil, | |||
| 140 | 140 | ||
| 141 | MODE-FN, if specified, is called when visiting a file with that format. | 141 | MODE-FN, if specified, is called when visiting a file with that format. |
| 142 | It is called with a single positive argument, on the assumption | 142 | It is called with a single positive argument, on the assumption |
| 143 | that it turns on some Emacs mode.") | 143 | that it turns on some Emacs mode. |
| 144 | |||
| 145 | PRESERVE, if non-nil, means that `format-write-file' should not remove | ||
| 146 | this format from `buffer-file-formats'.") | ||
| 144 | 147 | ||
| 145 | ;;; Basic Functions (called from Lisp) | 148 | ;;; Basic Functions (called from Lisp) |
| 146 | 149 | ||
| @@ -371,7 +374,16 @@ name as FILENAME, to write a file of the same old name in that directory." | |||
| 371 | (fmt (format-read (format "Write file `%s' in format: " | 374 | (fmt (format-read (format "Write file `%s' in format: " |
| 372 | (file-name-nondirectory file))))) | 375 | (file-name-nondirectory file))))) |
| 373 | (list file fmt))) | 376 | (list file fmt))) |
| 374 | (setq buffer-file-format format) | 377 | (let ((old-formats buffer-file-format) |
| 378 | preserve-formats) | ||
| 379 | (dolist (fmt old-formats) | ||
| 380 | (let ((aelt (assq fmt format-alist))) | ||
| 381 | (if (nth 7 aelt) | ||
| 382 | (push fmt preserve-formats)))) | ||
| 383 | (setq buffer-file-format format) | ||
| 384 | (dolist (fmt preserve-formats) | ||
| 385 | (unless (memq fmt buffer-file-format) | ||
| 386 | (setq buffer-file-format (append buffer-file-format (list fmt)))))) | ||
| 375 | (write-file filename)) | 387 | (write-file filename)) |
| 376 | 388 | ||
| 377 | (defun format-find-file (filename format) | 389 | (defun format-find-file (filename format) |