# HG changeset patch # User Karl Heuer # Date 802660981 0 # Node ID 38a933f88c875a7bd0ec124dcc31f4ffa1460159 # Parent 69c24a37a560034b182aad4d16037da8b6176528 (format-find-file, format-insert-file): New functions. diff -r 69c24a37a560 -r 38a933f88c87 lisp/format.el --- a/lisp/format.el Fri Jun 09 01:21:18 1995 +0000 +++ b/lisp/format.el Fri Jun 09 01:23:01 1995 +0000 @@ -251,6 +251,43 @@ (setq buffer-file-format format) (write-file filename)) +(defun format-find-file (filename format) + "Find the file FILE using data format FORMAT. +If FORMAT is nil then do not do any format conversion." + (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))))) + (list file fmt))) + (let ((format-alist nil)) + (find-file filename)) + (if format + (format-decode-buffer format))) + +(defun format-insert-file (filename format &optional beg end) + "Insert the contents of file FILE using data format FORMAT. +If FORMAT is nil then do not do any format conversion. +The optional third and fourth arguments BEG and END specify +the part of the file to read. + +The return value is like the value of `insert-file-contents': +a list (ABSOLUTE-FILE-NAME . SIZE)." + (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))))) + (list file fmt))) + (let (value size) + (let ((format-alist nil)) + (setq value (insert-file-contents filename nil beg end)) + (setq size (nth 1 value))) + (if format + (setq size (format-decode size format) + value (cons (car value) size))) + value)) + (defun format-read (&optional prompt) "Read and return the name of a format. Return value is a list, like `buffer-file-format'; it may be nil.