;;; format.el --- read and save files in multiple formats
-;; Copyright (C) 1994-1995, 1997, 1999, 2001-2013 Free Software
+;; Copyright (C) 1994-1995, 1997, 1999, 2001-2016 Free Software
;; Foundation, Inc.
;; Author: Boris Goldowsky <boris@gnu.org>
(setq selective-display sel-disp)
(set-buffer-multibyte multibyte)
(setq buffer-file-coding-system coding-system))
- (copy-to-buffer copy-buf from to)
- (set-buffer copy-buf)
- (format-insert-annotations write-region-annotations-so-far from)
- (format-encode-run-method to-fn (point-min) (point-max) orig-buf)
+ (let ((inhibit-read-only t)) ; bug#14887
+ (copy-to-buffer copy-buf from to)
+ (set-buffer copy-buf)
+ (format-insert-annotations write-region-annotations-so-far from)
+ (format-encode-run-method to-fn (point-min) (point-max)
+ orig-buf))
(when (buffer-live-p copy-buf)
(with-current-buffer copy-buf
;; Set write-region-post-annotation-function to
(cdr (assq 'default-directory
(buffer-local-variables)))
nil nil (buffer-name))))
- (fmt (format-read (format "Write file `%s' in format: "
- (file-name-nondirectory file)))))
+ (fmt (format-read (format-message "Write file `%s' in format: "
+ (file-name-nondirectory file)))))
(list file fmt (not current-prefix-arg))))
(let ((old-formats buffer-file-format)
preserve-formats)
(interactive
;; Same interactive spec as write-file, plus format question.
(let* ((file (read-file-name "Find file: "))
- (fmt (format-read (format "Read file `%s' in format: "
- (file-name-nondirectory file)))))
+ (fmt (format-read (format-message "Read file `%s' in format: "
+ (file-name-nondirectory file)))))
(list file fmt)))
(let ((format-alist nil))
(find-file filename))
(interactive
;; Same interactive spec as write-file, plus format question.
(let* ((file (read-file-name "Find file: "))
- (fmt (format-read (format "Read file `%s' in format: "
- (file-name-nondirectory file)))))
+ (fmt (format-read (format-message "Read file `%s' in format: "
+ (file-name-nondirectory file)))))
(list file fmt)))
(let (value size old-undo)
;; Record only one undo entry for the insertion. Inhibit point-motion and
(defun format-delq-cons (cons list)
"Remove the given CONS from LIST by side effect and return the new LIST.
Since CONS could be the first element of LIST, write
-`\(setq foo \(format-delq-cons element foo))' to be sure of changing
+\(setq foo \(format-delq-cons element foo)) to be sure of changing
the value of `foo'."
(if (eq cons list)
(cdr list)
Any annotations that are found by NEXT-FN but not defined by TRANSLATIONS
are saved as values of the `unknown' text-property \(which is list-valued).
The TRANSLATIONS list should usually contain an entry of the form
- \(unknown \(nil format-annotate-value))
+ (unknown (nil format-annotate-value))
to write these unknown annotations back into the file."
(save-excursion
(save-restriction
Insert each element of the given LIST of buffer annotations at its
appropriate place. Use second arg OFFSET if the annotations' locations are
not relative to the beginning of the buffer: annotations will be inserted
-at their location-OFFSET+1 \(ie, the offset is treated as the position of
+at their location-OFFSET+1 \(i.e., the offset is treated as the position of
the first character in the buffer)."
(if (not offset)
(setq offset 0)
(setq l (cdr l)))))
(defun format-annotate-value (old new)
- "Return OLD and NEW as a \(CLOSE . OPEN) annotation pair.
+ "Return OLD and NEW as a (CLOSE . OPEN) annotation pair.
Useful as a default function for TRANSLATIONS alist when the value of the text
property is the name of the annotation that you want to use, as it is for the
`unknown' text property."