aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTassilo Horn2008-01-09 20:16:14 +0000
committerTassilo Horn2008-01-09 20:16:14 +0000
commitf9adf05bac8484b01da84f18e6053a074509384b (patch)
tree3c6490988bf8336861fd3b8c4e46febcc33a23f6
parent6e69aa4d01211c82fbc568bc2d44cc8d2347b6ed (diff)
downloademacs-f9adf05bac8484b01da84f18e6053a074509384b.tar.gz
emacs-f9adf05bac8484b01da84f18e6053a074509384b.zip
2008-01-09 Tassilo Horn <tassilo@member.fsf.org>
* doc-view.el (doc-view-mode): Support tramp, compressed files and files inside archives uniformly.
-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 9e793bacc5c..798ed9ec3a6 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12008-01-09 Tassilo Horn <tassilo@member.fsf.org>
2
3 * doc-view.el (doc-view-mode): Support tramp, compressed files and
4 files inside archives uniformly.
5
12008-01-09 Eric S. Raymond <esr@snark.thyrsus.com> 62008-01-09 Eric S. Raymond <esr@snark.thyrsus.com>
2 7
3 * testmodes/sgml-mode.el (sgml-tag-syntax-table): Initialize this 8 * 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."
929You can use \\<doc-view-mode-map>\\[doc-view-toggle-display] to 929You can use \\<doc-view-mode-map>\\[doc-view-toggle-display] to
930toggle between displaying the document or editing it as text." 930toggle between displaying the document or editing it as text."
931 (interactive) 931 (interactive)
932 (if jka-compr-really-do-compress 932 ;; Handle compressed files, TRAMP files, files inside archives
933 933 (cond
934 ;; This is a compressed file uncompressed by auto-compression-mode. 934 (jka-compr-really-do-compress
935 (when (y-or-n-p (concat "DocView: Cannot convert compressed file. " 935 (let ((file (expand-file-name
936 "Save it uncompressed first? ")) 936 (file-name-nondirectory
937 (let ((file (read-file-name 937 (file-name-sans-extension buffer-file-name))
938 "File: " 938 doc-view-cache-directory)))
939 (file-name-directory buffer-file-name)))) 939 (write-region nil nil file)
940 (write-region (point-min) (point-max) file) 940 (setq buffer-file-name file)))
941 (kill-buffer nil) 941 ((or
942 (find-file file) 942 (not (file-exists-p buffer-file-name))
943 (doc-view-mode))) 943 (tramp-tramp-file-p buffer-file-name))
944 944 (let ((file (expand-file-name
945 ;; When opening a pdf/ps/dvi that's inside an archive (tar, zip, ...) the 945 (file-name-nondirectory buffer-file-name)
946 ;; file buffer-file-name doesn't exist, so create the directory and save 946 doc-view-cache-directory)))
947 ;; the file. 947 (write-region nil nil file)
948 (when (not (file-exists-p (file-name-directory buffer-file-name))) 948 (setq buffer-file-name file))))
949 (dired-create-directory (file-name-directory buffer-file-name))) 949
950 (when (not (file-exists-p buffer-file-name)) 950 (let* ((prev-major-mode (if (eq major-mode 'doc-view-mode)
951 (write-file buffer-file-name)) 951 doc-view-previous-major-mode
952 952 major-mode)))
953 (let* ((prev-major-mode (if (eq major-mode 'doc-view-mode) 953 (kill-all-local-variables)
954 doc-view-previous-major-mode 954 (set (make-local-variable 'doc-view-previous-major-mode) prev-major-mode))
955 major-mode))) 955
956 (kill-all-local-variables) 956 (make-local-variable 'doc-view-current-files)
957 (set (make-local-variable 'doc-view-previous-major-mode) prev-major-mode)) 957 (make-local-variable 'doc-view-current-image)
958 958 (make-local-variable 'doc-view-current-page)
959 (make-local-variable 'doc-view-current-files) 959 (make-local-variable 'doc-view-current-converter-process)
960 (make-local-variable 'doc-view-current-image) 960 (make-local-variable 'doc-view-current-timer)
961 (make-local-variable 'doc-view-current-page) 961 (make-local-variable 'doc-view-current-slice)
962 (make-local-variable 'doc-view-current-converter-process) 962 (make-local-variable 'doc-view-current-cache-dir)
963 (make-local-variable 'doc-view-current-timer) 963 (make-local-variable 'doc-view-current-info)
964 (make-local-variable 'doc-view-current-slice) 964 (make-local-variable 'doc-view-current-search-matches)
965 (make-local-variable 'doc-view-current-cache-dir) 965 (set (make-local-variable 'doc-view-current-overlay)
966 (make-local-variable 'doc-view-current-info) 966 (make-overlay (point-min) (point-max) nil t))
967 (make-local-variable 'doc-view-current-search-matches) 967 (add-hook 'change-major-mode-hook
968 (set (make-local-variable 'doc-view-current-overlay) 968 (lambda () (delete-overlay doc-view-current-overlay))
969 (make-overlay (point-min) (point-max) nil t)) 969 nil t)
970 (add-hook 'change-major-mode-hook 970 (set (make-local-variable 'mode-line-position)
971 (lambda () (delete-overlay doc-view-current-overlay)) 971 '(" P" (:eval (number-to-string doc-view-current-page))
972 nil t) 972 "/" (:eval (number-to-string (length doc-view-current-files)))))
973 (set (make-local-variable 'mode-line-position) 973 (set (make-local-variable 'cursor-type) nil)
974 '(" P" (:eval (number-to-string doc-view-current-page)) 974 (use-local-map doc-view-mode-map)
975 "/" (:eval (number-to-string (length doc-view-current-files))))) 975 (set (make-local-variable 'after-revert-hook) 'doc-view-reconvert-doc)
976 (set (make-local-variable 'cursor-type) nil) 976 (set (make-local-variable 'bookmark-make-cell-function)
977 (use-local-map doc-view-mode-map) 977 'doc-view-bookmark-make-cell)
978 (set (make-local-variable 'after-revert-hook) 'doc-view-reconvert-doc) 978 (setq mode-name "DocView"
979 (set (make-local-variable 'bookmark-make-cell-function) 979 buffer-read-only t
980 'doc-view-bookmark-make-cell) 980 major-mode 'doc-view-mode)
981 (setq mode-name "DocView" 981 (doc-view-initiate-display)
982 buffer-read-only t 982 (run-mode-hooks 'doc-view-mode-hook))
983 major-mode 'doc-view-mode)
984 (doc-view-initiate-display)
985 (run-mode-hooks 'doc-view-mode-hook)))
986 983
987;;;###autoload 984;;;###autoload
988(define-minor-mode doc-view-minor-mode 985(define-minor-mode doc-view-minor-mode