"Richard M. Stallman" <[EMAIL PROTECTED]> writes: > I think it is incorrect to use insert-file-contents with VISIT > non-nil on a temp buffer, so I think we don't need to try to fix > this. (It would not be easy, since the unwind-protect cleanup has > to execute before the error message gets displayed.)
drkm was using code from my emacs-wiki program as an example for this. You're right in that using a non-nil VISIT argument was a bad idea. I've also worked around the "prompted to save a temp buffer" problem by making a macro called `emacs-wiki-with-temp-buffer' as follows. The condition-case call is mainly used for displaying diagnostic information, so it might not be generally useful. A part of the cleanup code, (when (buffer-live-p ,temp-buffer) (with-current-buffer ,temp-buffer (set-buffer-modified-p nil)) (... (kill-buffer ,temp-buffer))) might perhaps be generally useful, but this is mostly an FYI rather than a feature request. (defmacro emacs-wiki-with-temp-buffer (&rest body) "Create a temporary buffer, and evaluate BODY there like `progn'. See also `with-temp-file' and `with-output-to-string'. Unlike `with-temp-buffer', this will never attempt to save the temp buffer." (let ((temp-buffer (make-symbol "temp-buffer"))) `(let ((,temp-buffer (generate-new-buffer " *emacs-wiki-temp*"))) (unwind-protect (condition-case err (with-current-buffer ,temp-buffer ,@body) (error (if (fboundp 'display-warning) (display-warning 'emacs-wiki (format "%s: Error occurred: %s" (emacs-wiki-page-name) err) :warning) (message "%s: Error occurred: %s" (emacs-wiki-page-name) err)))) (when (buffer-live-p ,temp-buffer) (with-current-buffer ,temp-buffer (set-buffer-modified-p nil)) (unless debug-on-error (kill-buffer ,temp-buffer))))))) (put 'emacs-wiki-with-temp-buffer 'lisp-indent-function 0) (put 'emacs-wiki-with-temp-buffer 'edebug-form-spec '(body)) -- Michael Olson -- FSF Associate Member #652 -- http://www.mwolson.org/ Interests: anime, Debian, XHTML, wiki, Emacs Lisp /` |\ | | | IRC: mwolson on freenode.net: #hcoop, #muse, #pulug |_] | \| |_| Jabber: mwolson_at_hcoop.net
pgpXsRzdLWssO.pgp
Description: PGP signature
_______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel