From: tomo Date: Fri, 25 Feb 2000 12:15:06 +0000 (+0000) Subject: (mime-situation-examples-file-coding-system): New variable. X-Git-Tag: remi-1_14_1~5 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=8e97fae96f960230f6f2e79bd96163086136e062;p=elisp%2Fsemi.git (mime-situation-examples-file-coding-system): New variable. (mime-save-situation-examples): Use `with-temp-buffer'; try to save as `mime-situation-examples-file-coding-system'. Setup `mime-situation-examples-file-coding-system' when mime-situation-examples-file is loaded. --- diff --git a/mime-view.el b/mime-view.el index ebf3935..6cdabc9 100644 --- a/mime-view.el +++ b/mime-view.el @@ -359,34 +359,37 @@ mother-buffer." (defvar mime-acting-situation-example-list nil) (defvar mime-acting-situation-example-list-max-size 16) +(defvar mime-situation-examples-file-coding-system nil) (defun mime-save-situation-examples () (if (or mime-preview-situation-example-list mime-acting-situation-example-list) - (let* ((file mime-situation-examples-file) - (buffer (get-buffer-create " *mime-example*"))) - (unwind-protect - (save-excursion - (set-buffer buffer) - (setq buffer-file-name file) - (erase-buffer) - (insert ";;; " (file-name-nondirectory file) "\n") - (insert "\n;; This file is generated automatically by " - mime-view-version "\n\n") - (insert ";;; Code:\n\n") - (if mime-preview-situation-example-list - (pp `(setq mime-preview-situation-example-list - ',mime-preview-situation-example-list) - (current-buffer))) - (if mime-acting-situation-example-list - (pp `(setq mime-acting-situation-example-list - ',mime-acting-situation-example-list) - (current-buffer))) - (insert "\n;;; " - (file-name-nondirectory file) - " ends here.\n") - (save-buffer)) - (kill-buffer buffer))))) + (let ((file mime-situation-examples-file)) + (with-temp-buffer + (insert ";;; " (file-name-nondirectory file) "\n") + (insert "\n;; This file is generated automatically by " + mime-view-version "\n\n") + (insert ";;; Code:\n\n") + (if mime-preview-situation-example-list + (pp `(setq mime-preview-situation-example-list + ',mime-preview-situation-example-list) + (current-buffer))) + (if mime-acting-situation-example-list + (pp `(setq mime-acting-situation-example-list + ',mime-acting-situation-example-list) + (current-buffer))) + (insert "\n;;; " + (file-name-nondirectory file) + " ends here.\n") + (static-cond + ((boundp 'buffer-file-coding-system) + (setq buffer-file-coding-system + mime-situation-examples-file-coding-system)) + ((boundp 'file-coding-system) + (setq file-coding-system + mime-situation-examples-file-coding-system))) + (setq buffer-file-name file) + (save-buffer))))) (add-hook 'kill-emacs-hook 'mime-save-situation-examples) @@ -1766,6 +1769,13 @@ It calls function registered in variable (set-buffer buffer) (erase-buffer) (insert-file-contents file) + (setq mime-situation-examples-file-coding-system + (static-cond + ((boundp 'buffer-file-coding-system) + (symbol-value 'buffer-file-coding-system)) + ((boundp 'file-coding-system) + (symbol-value 'file-coding-system)) + (t nil))) (eval-buffer) ;; format check (condition-case nil