comparison lisp/files.el @ 365:30d2cfa1092a r21-1-12

Import from CVS: tag r21-1-12
author cvs
date Mon, 13 Aug 2007 11:00:12 +0200
parents 972bbb6d6ca2
children 1d62742628b6
comparison
equal deleted inserted replaced
364:63c3368d1275 365:30d2cfa1092a
876 found)))) 876 found))))
877 877
878 (defun insert-file-contents-literally (filename &optional visit beg end replace) 878 (defun insert-file-contents-literally (filename &optional visit beg end replace)
879 "Like `insert-file-contents', q.v., but only reads in the file. 879 "Like `insert-file-contents', q.v., but only reads in the file.
880 A buffer may be modified in several ways after reading into the buffer due 880 A buffer may be modified in several ways after reading into the buffer due
881 to advanced Emacs features, such as file-name-handlers, format decoding, 881 to advanced Emacs features, such as format decoding, character code
882 find-file-hooks, etc. 882 conversion,find-file-hooks, automatic uncompression, etc.
883
883 This function ensures that none of these modifications will take place." 884 This function ensures that none of these modifications will take place."
884 (let ((file-name-handler-alist nil) 885 (let ((wrap-func (find-file-name-handler filename
885 (format-alist nil) 886 'insert-file-contents-literally)))
886 (after-insert-file-functions nil) 887 (if wrap-func
887 (coding-system-for-read 'binary) 888 (funcall wrap-func 'insert-file-contents-literally filename
888 (find-buffer-file-type-function 889 visit beg end replace)
889 (if (fboundp 'find-buffer-file-type) 890 (let ((file-name-handler-alist nil)
890 (symbol-function 'find-buffer-file-type) 891 (format-alist nil)
891 nil))) 892 (after-insert-file-functions nil)
892 (unwind-protect 893 (coding-system-for-read 'binary)
893 (progn 894 (coding-system-for-write 'binary)
894 (fset 'find-buffer-file-type (lambda (filename) t)) 895 (find-buffer-file-type-function
895 (insert-file-contents filename visit beg end replace)) 896 (if (fboundp 'find-buffer-file-type)
896 (if find-buffer-file-type-function 897 (symbol-function 'find-buffer-file-type)
897 (fset 'find-buffer-file-type find-buffer-file-type-function) 898 nil)))
898 (fmakunbound 'find-buffer-file-type))))) 899 (unwind-protect
900 (progn
901 (fset 'find-buffer-file-type (lambda (filename) t))
902 (insert-file-contents filename visit beg end replace))
903 (if find-buffer-file-type-function
904 (fset 'find-buffer-file-type find-buffer-file-type-function)
905 (fmakunbound 'find-buffer-file-type)))))))
899 906
900 (defun find-file-noselect (filename &optional nowarn rawfile) 907 (defun find-file-noselect (filename &optional nowarn rawfile)
901 "Read file FILENAME into a buffer and return the buffer. 908 "Read file FILENAME into a buffer and return the buffer.
902 If a buffer exists visiting FILENAME, return that one, but 909 If a buffer exists visiting FILENAME, return that one, but
903 verify that the file has not changed since visited or saved. 910 verify that the file has not changed since visited or saved.