From: Tassilo Horn Date: Wed, 9 Jan 2008 20:16:14 +0000 (+0000) Subject: 2008-01-09 Tassilo Horn X-Git-Tag: emacs-pretest-23.0.90~8616 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f9adf05bac8484b01da84f18e6053a074509384b;p=emacs.git 2008-01-09 Tassilo Horn * doc-view.el (doc-view-mode): Support tramp, compressed files and files inside archives uniformly. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9e793bacc5c..798ed9ec3a6 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2008-01-09 Tassilo Horn + + * doc-view.el (doc-view-mode): Support tramp, compressed files and + files inside archives uniformly. + 2008-01-09 Eric S. Raymond * testmodes/sgml-mode.el (sgml-tag-syntax-table): Initialize this diff --git a/lisp/doc-view.el b/lisp/doc-view.el index 83f9be53ae3..92159776269 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-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