* Jakub Wilk <[email protected]>, 2009-12-12, 19:49:
I have a potential fix for this bug. My approach is based on the premise that the make-temp-file function provided from Emacs 22 onwards is safe. So, I backport the method to the rst.el file, and bind it to the symbol rst--make-temp-file as follows:Thank you very much for your patch!I think we could avoid backporting code, if we created a temporary directory (and then a file with an arbitrary name and proper suffix inside it) rather than a temporary file.I don't see a solution for removing the temporary files, though.Is it possible to somehow store the name of temporary thing that has been created? That way maybe we could re-use it on next invocation of the preview function and delete it in some kind of exit hook.
I attach my patch proposition. For a reason I don't understand, temporary directory is removed whenI kill a buffer (C-x k), but not when I kill Emacs (C-x C-c)... On the other hand, with this patch we are not cluttering /tmp any more than the original rst.el.
-- Jakub Wilk
--- /usr/share/emacs/site-lisp/rst.el 2008-07-24 11:44:16.000000000 +0200
+++ rst.el 2009-12-13 17:05:13.000000000 +0100
@@ -3273,13 +3273,31 @@
"rst2pseudoxml"
standard-output)))
+(defvar rst-temp-dir nil)
+(make-variable-buffer-local 'rst-temp-dir)
+
+(defun rst-get-temp-dir ()
+ (or rst-temp-dir
+ (setq rst-temp-dir
+ (file-name-as-directory (make-temp-file "rst-" t))
+ )
+ )
+)
+
+(defun rst-remove-temp-dir ()
+ (require 'dired)
+ (if rst-temp-dir (dired-delete-file rst-temp-dir 'always))
+)
+
+(add-hook 'kill-buffer-hook 'rst-remove-temp-dir)
+
(defvar rst-pdf-program "xpdf"
"Program used to preview PDF files.")
(defun rst-compile-pdf-preview ()
"Convert the document to a PDF file and launch a preview program."
(interactive)
- (let* ((tmp-filename "/tmp/out.pdf")
+ (let* ((tmp-filename (concat (rst-get-temp-dir) "out.pdf"))
(command (format "rst2pdf.py %s %s && %s %s"
buffer-file-name tmp-filename
rst-pdf-program tmp-filename)))
@@ -3294,7 +3312,7 @@
(defun rst-compile-slides-preview ()
"Convert the document to an S5 slide presentation and launch a preview program."
(interactive)
- (let* ((tmp-filename "/tmp/slides.html")
+ (let* ((tmp-filename (concat (rst-get-temp-dir) "slides.html"))
(command (format "rst2s5 %s %s && %s %s"
buffer-file-name tmp-filename
rst-slides-program tmp-filename)))
signature.asc
Description: Digital signature
_______________________________________________ Python-modules-team mailing list [email protected] http://lists.alioth.debian.org/mailman/listinfo/python-modules-team

