From 2c1c56d553df6ee1973134fdb90543454b1146ca Mon Sep 17 00:00:00 2001 From: Michael Olson Date: Wed, 5 Aug 2009 08:07:03 -0700 Subject: Introduce emms-insert-file-contents. This function is a safe way to insert the contents of a file without triggering major mode detection, and has been tested on several versions of Emacs and XEmacs. --- lisp/emms.el | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'lisp/emms.el') diff --git a/lisp/emms.el b/lisp/emms.el index 750781d..3c5402d 100644 --- a/lisp/emms.el +++ b/lisp/emms.el @@ -527,6 +527,27 @@ See `completing-read' for a description of ARGS." (require 'emms-compat) + +;;; Utility functions + +(defun emms-insert-file-contents (filename &optional visit) + "Insert the contents of file FILENAME after point. +Do character code conversion and end-of-line conversion, but none +of the other unnecessary things like format decoding or +`find-file-hook'. + +If VISIT is non-nil, the buffer's visited filename +and last save file modtime are set, and it is marked unmodified. +If visiting and the file does not exist, visiting is completed +before the error is signaled." + (let ((format-alist nil) + (after-insert-file-functions nil) + (inhibit-file-name-handlers + (append '(jka-compr-handler image-file-handler epa-file-handler) + inhibit-file-name-handlers)) + (inhibit-file-name-operation 'insert-file-contents)) + (insert-file-contents filename visit))) + ;;; Dictionaries -- cgit v1.2.3