diff lisp/doc-view.el @ 106467:0314d1c68b88

Make it work for non-file buffers (bug#5102). * doc-view.el (doc-view-current-cache-dir): Use doc-view-buffer-file-name rather than buffer-file-name. (doc-view-mode): Use buffer-name when buffer-file-name is nil.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 07 Dec 2009 02:37:42 +0000
parents 8cb95e673f03
children 1d1d5d9bd884
line wrap: on
line diff
--- a/lisp/doc-view.el	Sun Dec 06 23:27:55 2009 +0000
+++ b/lisp/doc-view.el	Mon Dec 07 02:37:42 2009 +0000
@@ -563,7 +563,7 @@
     (setq doc-view-current-cache-dir
 	  (file-name-as-directory
 	   (expand-file-name
-	    (concat (file-name-nondirectory buffer-file-name)
+	    (concat (file-name-nondirectory doc-view-buffer-file-name)
 		    "-"
 		    (let ((file doc-view-buffer-file-name))
 		      (with-temp-buffer
@@ -1228,6 +1228,7 @@
     (set (make-local-variable 'doc-view-buffer-file-name)
 	 (cond
 	  (jka-compr-really-do-compress
+           ;; FIXME: there's a risk of name conflicts here.
 	   (expand-file-name
 	    (file-name-nondirectory
 	     (file-name-sans-extension buffer-file-name))
@@ -1237,10 +1238,13 @@
 	  ;; supposed to return nil for things like local files accessed via
 	  ;; `su' or via file://...
 	  ((let ((file-name-handler-alist nil))
-	     (not (file-readable-p buffer-file-name)))
+	     (not (and buffer-file-name (file-readable-p buffer-file-name))))
+           ;; FIXME: there's a risk of name conflicts here.
 	   (expand-file-name
-	    (file-name-nondirectory buffer-file-name)
-	    doc-view-cache-directory))
+	    (if buffer-file-name
+                (file-name-nondirectory buffer-file-name)
+              (buffer-name))
+            doc-view-cache-directory))
 	  (t buffer-file-name)))
     (when (not (string= doc-view-buffer-file-name buffer-file-name))
       (write-region nil nil doc-view-buffer-file-name))