aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorTassilo Horn <[email protected]>2008-01-09 20:16:14 +0000
committerTassilo Horn <[email protected]>2008-01-09 20:16:14 +0000
commitf9adf05bac8484b01da84f18e6053a074509384b (patch)
tree3c6490988bf8336861fd3b8c4e46febcc33a23f6 /lisp
parent6e69aa4d01211c82fbc568bc2d44cc8d2347b6ed (diff)
2008-01-09 Tassilo Horn <[email protected]>
* doc-view.el (doc-view-mode): Support tramp, compressed files and files inside archives uniformly.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/doc-view.el105
2 files changed, 56 insertions, 54 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 9e793bacc5..798ed9ec3a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2008-01-09 Tassilo Horn <[email protected]>
+
+ * doc-view.el (doc-view-mode): Support tramp, compressed files and
+ files inside archives uniformly.
+
2008-01-09 Eric S. Raymond <[email protected]>
* testmodes/sgml-mode.el (sgml-tag-syntax-table): Initialize this
diff --git a/lisp/doc-view.el b/lisp/doc-view.el
index 83f9be53ae..9215977626 100644
--- a/lisp/doc-view.el
+++ b/lisp/doc-view.el
@@ -929,60 +929,57 @@ If BACKWARD is non-nil, jump to the previous match."
You can use \\<doc-view-mode-map>\\[doc-view-toggle-display] to
toggle between displaying the document or editing it as text."
(interactive)
- (if jka-compr-really-do-compress
-
- ;; This is a compressed file uncompressed by auto-compression-mode.
- (when (y-or-n-p (concat "DocView: Cannot convert compressed file. "
- "Save it uncompressed first? "))
- (let ((file (read-file-name
- "File: "
- (file-name-directory buffer-file-name))))
- (write-region (point-min) (point-max) file)
- (kill-buffer nil)
- (find-file file)
- (doc-view-mode)))
-
- ;; When opening a pdf/ps/dvi that's inside an archive (tar, zip, ...) the
- ;; file buffer-file-name doesn't exist, so create the directory and save
- ;; the file.
- (when (not (file-exists-p (file-name-directory buffer-file-name)))
- (dired-create-directory (file-name-directory buffer-file-name)))
- (when (not (file-exists-p buffer-file-name))
- (write-file buffer-file-name))
-
- (let* ((prev-major-mode (if (eq major-mode 'doc-view-mode)
- doc-view-previous-major-mode
- major-mode)))
- (kill-all-local-variables)
- (set (make-local-variable 'doc-view-previous-major-mode) prev-major-mode))
-
- (make-local-variable 'doc-view-current-files)
- (make-local-variable 'doc-view-current-image)
- (make-local-variable 'doc-view-current-page)
- (make-local-variable 'doc-view-current-converter-process)
- (make-local-variable 'doc-view-current-timer)
- (make-local-variable 'doc-view-current-slice)
- (make-local-variable 'doc-view-current-cache-dir)
- (make-local-variable 'doc-view-current-info)
- (make-local-variable 'doc-view-current-search-matches)
- (set (make-local-variable 'doc-view-current-overlay)
- (make-overlay (point-min) (point-max) nil t))
- (add-hook 'change-major-mode-hook
- (lambda () (delete-overlay doc-view-current-overlay))
- nil t)
- (set (make-local-variable 'mode-line-position)
- '(" P" (:eval (number-to-string doc-view-current-page))
- "/" (:eval (number-to-string (length doc-view-current-files)))))
- (set (make-local-variable 'cursor-type) nil)
- (use-local-map doc-view-mode-map)
- (set (make-local-variable 'after-revert-hook) 'doc-view-reconvert-doc)
- (set (make-local-variable 'bookmark-make-cell-function)
- 'doc-view-bookmark-make-cell)
- (setq mode-name "DocView"
- buffer-read-only t
- major-mode 'doc-view-mode)
- (doc-view-initiate-display)
- (run-mode-hooks 'doc-view-mode-hook)))
+ ;; Handle compressed files, TRAMP files, files inside archives
+ (cond
+ (jka-compr-really-do-compress
+ (let ((file (expand-file-name
+ (file-name-nondirectory
+ (file-name-sans-extension buffer-file-name))
+ doc-view-cache-directory)))
+ (write-region nil nil file)
+ (setq buffer-file-name file)))
+ ((or
+ (not (file-exists-p buffer-file-name))
+ (tramp-tramp-file-p buffer-file-name))
+ (let ((file (expand-file-name
+ (file-name-nondirectory buffer-file-name)
+ doc-view-cache-directory)))
+ (write-region nil nil file)
+ (setq buffer-file-name file))))
+
+ (let* ((prev-major-mode (if (eq major-mode 'doc-view-mode)
+ doc-view-previous-major-mode
+ major-mode)))
+ (kill-all-local-variables)
+ (set (make-local-variable 'doc-view-previous-major-mode) prev-major-mode))
+
+ (make-local-variable 'doc-view-current-files)
+ (make-local-variable 'doc-view-current-image)
+ (make-local-variable 'doc-view-current-page)
+ (make-local-variable 'doc-view-current-converter-process)
+ (make-local-variable 'doc-view-current-timer)
+ (make-local-variable 'doc-view-current-slice)
+ (make-local-variable 'doc-view-current-cache-dir)
+ (make-local-variable 'doc-view-current-info)
+ (make-local-variable 'doc-view-current-search-matches)
+ (set (make-local-variable 'doc-view-current-overlay)
+ (make-overlay (point-min) (point-max) nil t))
+ (add-hook 'change-major-mode-hook
+ (lambda () (delete-overlay doc-view-current-overlay))
+ nil t)
+ (set (make-local-variable 'mode-line-position)
+ '(" P" (:eval (number-to-string doc-view-current-page))
+ "/" (:eval (number-to-string (length doc-view-current-files)))))
+ (set (make-local-variable 'cursor-type) nil)
+ (use-local-map doc-view-mode-map)
+ (set (make-local-variable 'after-revert-hook) 'doc-view-reconvert-doc)
+ (set (make-local-variable 'bookmark-make-cell-function)
+ 'doc-view-bookmark-make-cell)
+ (setq mode-name "DocView"
+ buffer-read-only t
+ major-mode 'doc-view-mode)
+ (doc-view-initiate-display)
+ (run-mode-hooks 'doc-view-mode-hook))
;;;###autoload
(define-minor-mode doc-view-minor-mode