From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.devel Subject: Re: doc-view compilation warnings Date: Wed, 24 Oct 2007 13:40:23 +0200 Message-ID: <877ilckafs.fsf@baldur.tsdh.de> References: <87wsth6vk5.fsf@catnip.gol.com> <878x5wrgnv.fsf@baldur.tsdh.de> <87prz6yn1c.fsf@baldur.tsdh.de> <200710231430.l9NEUk8x012690@oogie-boogie.ics.uci.edu> <87ejflzv18.fsf@baldur.tsdh.de> <200710231607.l9NG7EoD016139@oogie-boogie.ics.uci.edu> <87abq9zpnz.fsf@baldur.tsdh.de> <200710231835.l9NIZ7HB025212@oogie-boogie.ics.uci.edu> <87640xzn9p.fsf@baldur.tsdh.de> <871wblzjn3.fsf@baldur.tsdh.de> <878x5thrjs.fsf@baldur.tsdh.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1193226051 12822 80.91.229.12 (24 Oct 2007 11:40:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 24 Oct 2007 11:40:51 +0000 (UTC) Cc: Richard Stallman To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Oct 24 13:40:51 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IkebN-0001Sx-IK for ged-emacs-devel@m.gmane.org; Wed, 24 Oct 2007 13:40:46 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IkebF-0002js-EW for ged-emacs-devel@m.gmane.org; Wed, 24 Oct 2007 07:40:37 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IkebB-0002gl-2L for emacs-devel@gnu.org; Wed, 24 Oct 2007 07:40:33 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IkebA-0002fQ-1V for emacs-devel@gnu.org; Wed, 24 Oct 2007 07:40:32 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ikeb9-0002fD-Tj for emacs-devel@gnu.org; Wed, 24 Oct 2007 07:40:31 -0400 Original-Received: from out1.smtp.messagingengine.com ([66.111.4.25]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Ikeb5-0001xF-Jt; Wed, 24 Oct 2007 07:40:27 -0400 Original-Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id 549C035597; Wed, 24 Oct 2007 07:40:27 -0400 (EDT) Original-Received: from heartbeat2.messagingengine.com ([10.202.2.161]) by compute1.internal (MEProxy); Wed, 24 Oct 2007 07:40:27 -0400 X-Sasl-enc: +tBPC3VWYfHz0V2esiKmG5C18HpqVtBo9ApaFy1OACt5 1193226026 Original-Received: from baldur.tsdh.de (dslb-084-063-023-116.pools.arcor-ip.net [84.63.23.116]) by mail.messagingengine.com (Postfix) with ESMTP id B9A062436D; Wed, 24 Oct 2007 07:40:25 -0400 (EDT) Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwEAIAAACI8LKTAAAACXBIWXMAAAsSAAALEgHS3X78 AAAATnRFWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYACmV4aWYKICAgICAgMjAKNDU3ODY5NjYwMDAw NGQ0ZDAwMmEwMDAwMDAwODAwMDAwMDAwMDAwMAqJuBZbAAAACXZwQWcAAAAwAAAAMADO7oxXAAAB d0lEQVRo3u2asRHCMAxF/xbswSIZhgmYgoKa0ehpoKagoUlOsqwvKUrjIrnL6V6+v2TJ+Nzep9cS tV6fl8f5vrbGxvZbEQvl/8k2shaAtvWyBi4WE7KhkeM7AKXAhIpoDkCJMAUAkmerdoC0aDLUSqiS 2psCsvvUbgHN1d2u6qC1t00BjW2oRlmsejWE2BN8fh2lKBTlPsXHhFh7zt9gA1873l5WAJBf0Hzb RhU0UZgOQCxA/ATMwYRa2ikJKOoQwKm2UVE7TB01AjQWGypurgKAsg2ID0CL5RCbCJB3ccjvQCZV kPxrjTxIC8XSq3QEJJe3n5qYzVl4zCckAY2FO6t1Ow2QdkA8t3SU/AbvpIExYVu2gMWJJNf3JG5l AqS9d2H3Ju1mtEOUYwJ/UGOpfeTOMsuPMJbItTi011y0yCQQx/QI5iw051RWDYgZyqxLMAGAMgSd YaKPWGHnhGIqFDtAce8ozirzY9v1pLlY9Qk96XZH3e9/ASFbB95TvQYIAAAAGnpUWHRqcGVnOmNv bG9yc3BhY2UAAHjaMwIAADMAM4k4IzUAAAAmelRYdGpwZWc6c2FtcGxpbmctZmFjdG9yAAB42jOq MNIxrDAEYQARgwLpPZcvTwAAAABJRU5ErkJggg== Mail-Followup-To: emacs-devel@gnu.org, Richard Stallman In-Reply-To: <878x5thrjs.fsf@baldur.tsdh.de> (Tassilo Horn's message of "Wed, 24 Oct 2007 09:59:03 +0200") User-Agent: Gnus/5.110007 (No Gnus v0.7) Emacs/23.0.50 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:81646 Archived-At: --=-=-= Tassilo Horn writes: >>> But someone should decide: Is loading doc-view when opening >>> ps/pdf/dvi files ok? >> >> It doesn't look like a problem to me, as long as it doesn't show PS >> files using doc-view by default. >> >> Note that it may be simpler to setup auto-mode-alist to map *.ps to >> ps-mode and dvi and pdf files to doc-view-mode and then change >> ps-mode to activate doc-view-minor-mode explicitly and >> unconditionally. That will save you from defining >> doc-view-mode-maybe. > > Ok, I'll do that. Done! > But still: what keybinding can I use for toggling? ps-mode aldeady > binds `C-c C-c'. Or maybe we should change the binding for > `ps-run-clear' in ps-mode to some other key that `C-c C-c'? Now ps-mode uses C-c C-l for ps-run-clear and doc-view uses C-c C-c as RMS suggested. >> I'd also be very happy to get rid of the >> doc-view-clean-auto-mode-alist monstrosity by just saying "if you're >> not using doc-view-minor-mode, then toggling off doc-view puts you in >> fundamental-mode", > > I don't get you here. If someone has his buffer in d-v-m and toggles to > an editing mode I can activate d-v-minor-mode unconditionally. > >> or if you want to be fancier, then save the previous major-mode when >> entering doc-view-mode (when possible) and reuse that value when >> exiting it (like picture-mode does). > > Ok, that sounds reasonable. And if there was no previous major mode > (or it was doc-view-mode) I can fall back to fundamental mode. Done! Here's the ChangeLog entry: --8<---------------cut here---------------start------------->8--- 2007-10-24 Tassilo Horn * progmodes/ps-mode.el (ps-mode-map): Change bindinc C-c C-c to C-c C-l and remove binding C-c v. * doc-view.el (doc-view-mode): Remove text/image switching code. Use plain defun. (doc-view-minor-mode): New minor mode. (doc-view-minor-mode-map): New keymap. (doc-view-mode-text-map): Remove keymap. (doc-view-mode-map): New binding K to kill the converter process. (doc-view-current-display): Remove variable. (doc-view-buffer-message): Mention new binding K. (doc-view-display-maybe): Remove function. (doc-view-pdf/ps->png): Timer calls d-v-display instead d-v-display-maybe. (doc-view-ps->pdf): Resort args to make ps2pdf happy. (doc-view-current-cache-dir): Better cache dir naming. (doc-view-remove-if): New function. (doc-view-search-next-match, doc-view-search-previous-match): Use it. * files.el (auto-mode-alist): Change entries: pdf/dvi -> doc-view-mode, ps -> ps-mode. --8<---------------cut here---------------end--------------->8--- And here's the patch (or get it from [1]): --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=doc-view.patch Content-Description: doc-view.patch Index: lisp/progmodes/ps-mode.el =================================================================== RCS file: /sources/emacs/emacs/lisp/progmodes/ps-mode.el,v retrieving revision 1.21 diff -u -r1.21 ps-mode.el --- lisp/progmodes/ps-mode.el 26 Jul 2007 05:27:29 -0000 1.21 +++ lisp/progmodes/ps-mode.el 24 Oct 2007 10:34:56 -0000 @@ -408,7 +408,6 @@ (unless ps-mode-map (setq ps-mode-map (make-sparse-keymap)) - (define-key ps-mode-map "\C-cv" 'ps-mode-show-version) (define-key ps-mode-map "\C-c\C-v" 'ps-run-boundingbox) (define-key ps-mode-map "\C-c\C-u" 'ps-mode-uncomment-region) (define-key ps-mode-map "\C-c\C-t" 'ps-mode-epsf-rich) @@ -419,7 +418,7 @@ (define-key ps-mode-map "\C-c\C-o" 'ps-mode-comment-out-region) (define-key ps-mode-map "\C-c\C-k" 'ps-run-kill) (define-key ps-mode-map "\C-c\C-j" 'ps-mode-other-newline) - (define-key ps-mode-map "\C-c\C-c" 'ps-run-clear) + (define-key ps-mode-map "\C-c\C-l" 'ps-run-clear) (define-key ps-mode-map "\C-c\C-b" 'ps-run-buffer) (define-key ps-mode-map ">" 'ps-mode-r-gt) (define-key ps-mode-map "]" 'ps-mode-r-angle) @@ -530,7 +529,10 @@ t)) (set (make-local-variable 'comment-start) "%") ;; NOTE: `\' has a special meaning in strings only - (set (make-local-variable 'comment-start-skip) "%+[ \t]*")) + (set (make-local-variable 'comment-start-skip) "%+[ \t]*") + ;; enable doc-view-minor-mode => C-c C-c starts viewing the current ps file + ;; with doc-view-mode. + (doc-view-minor-mode 1)) (defun ps-mode-show-version () "Show current version of PostScript mode." Index: lisp/files.el =================================================================== RCS file: /sources/emacs/emacs/lisp/files.el,v retrieving revision 1.936 diff -u -r1.936 files.el --- lisp/files.el 21 Oct 2007 10:48:28 -0000 1.936 +++ lisp/files.el 24 Oct 2007 10:35:01 -0000 @@ -2060,7 +2060,8 @@ ("\\.\\(diffs?\\|patch\\|rej\\)\\'" . diff-mode) ("\\.\\(dif\\|pat\\)\\'" . diff-mode) ; for MSDOG ("\\.[eE]?[pP][sS]\\'" . ps-mode) - ("\\.\\(?:PDF\\|DVI\\|pdf\\|dvi\\)" . doc-view-mode) + ("\\.[Dd][Vv][Ii]\\'" . doc-view-mode) + ("\\.[Pp][Dd][Ff]\\'" . doc-view-mode) ("configure\\.\\(ac\\|in\\)\\'" . autoconf-mode) ("BROWSE\\'" . ebrowse-tree-mode) ("\\.ebrowse\\'" . ebrowse-tree-mode) Index: lisp/doc-view.el =================================================================== RCS file: /sources/emacs/emacs/lisp/doc-view.el,v retrieving revision 1.11 diff -u -r1.11 doc-view.el --- lisp/doc-view.el 19 Oct 2007 16:03:09 -0000 1.11 +++ lisp/doc-view.el 24 Oct 2007 10:35:02 -0000 @@ -102,7 +102,6 @@ (require 'dired) (require 'image-mode) -(eval-when-compile (require 'cl)) ;;;; Customization Options @@ -202,7 +201,7 @@ (defvar doc-view-current-info nil "Only used internally.") -(defvar doc-view-current-display nil +(defvar doc-view-previous-major-mode nil "Only used internally.") ;;;; DocView Keymaps @@ -224,6 +223,7 @@ ;; Killing/burying the buffer (and the process) (define-key map (kbd "q") 'bury-buffer) (define-key map (kbd "k") 'doc-view-kill-proc-and-buffer) + (define-key map (kbd "K") 'doc-view-kill-proc) ;; Slicing the image (define-key map (kbd "s s") 'doc-view-set-slice) (define-key map (kbd "s m") 'doc-view-set-slice-using-mouse) @@ -242,24 +242,18 @@ (define-key map (kbd "C-t") 'doc-view-show-tooltip) ;; Toggle between text and image display or editing (define-key map (kbd "C-c C-c") 'doc-view-toggle-display) - (define-key map (kbd "C-c C-e") 'doc-view-edit-doc) ;; Reconvert the current document (define-key map (kbd "g") 'doc-view-reconvert-doc) (suppress-keymap map) map) "Keymap used by `doc-view-mode' when displaying a doc as a set of images.") -(defvar doc-view-mode-text-map +(defvar doc-view-minor-mode-map (let ((map (make-sparse-keymap))) ;; Toggle between text and image display or editing (define-key map (kbd "C-c C-c") 'doc-view-toggle-display) - (define-key map (kbd "C-c C-e") 'doc-view-edit-doc) - ;; Killing/burying the buffer (and the process) - (define-key map (kbd "q") 'bury-buffer) - (define-key map (kbd "k") 'doc-view-kill-proc-and-buffer) - (define-key map (kbd "C-x k") 'doc-view-kill-proc-and-buffer) map) - "Keymap used by `doc-view-mode' when displaying a document as text.") + "Keymap used by `doc-minor-view-mode'.") ;;;; Navigation Commands @@ -339,11 +333,14 @@ (error (doc-view-previous-page) (goto-char (point-max))))) +;;;; Utility Functions + (defun doc-view-kill-proc () "Kill the current converter process." (interactive) (when doc-view-current-converter-process - (kill-process doc-view-current-converter-process)) + (kill-process doc-view-current-converter-process) + (setq doc-view-current-converter-process nil)) (when doc-view-current-timer (cancel-timer doc-view-current-timer) (setq doc-view-current-timer nil)) @@ -356,6 +353,28 @@ (when (eq major-mode 'doc-view-mode) (kill-buffer (current-buffer)))) +(defun doc-view-current-cache-dir () + "Return the directory where the png files of the current doc should be saved. +It's a subdirectory of `doc-view-cache-directory'." + (if doc-view-current-cache-dir + doc-view-current-cache-dir + (setq doc-view-current-cache-dir + (file-name-as-directory + (concat (file-name-as-directory doc-view-cache-directory) + (let ((doc doc-view-current-doc)) + (concat (file-name-nondirectory doc) + "-" + (with-temp-buffer + (insert-file-contents-literally doc) + (md5 (current-buffer)))))))))) + +(defun doc-view-remove-if (predicate list) + "Return LIST with all items removed that satisfy PREDICATE." + (let (new-list) + (dolist (item list (nreverse new-list)) + (when (not (funcall predicate item)) + (setq new-list (cons item new-list)))))) + ;;;; Conversion Functions (defun doc-view-reconvert-doc (&rest args) @@ -368,21 +387,7 @@ ;; Clear the old cached files (when (file-exists-p (doc-view-current-cache-dir)) (dired-delete-file (doc-view-current-cache-dir) 'always)) - (doc-view-kill-proc-and-buffer) - (find-file doc))) - -(defun doc-view-current-cache-dir () - "Return the directory where the png files of the current doc should be saved. -It's a subdirectory of `doc-view-cache-directory'." - (if doc-view-current-cache-dir - doc-view-current-cache-dir - (setq doc-view-current-cache-dir - (file-name-as-directory - (concat (file-name-as-directory doc-view-cache-directory) - (let ((doc doc-view-current-doc)) - (with-temp-buffer - (insert-file-contents-literally doc) - (md5 (current-buffer))))))))) + (doc-view-mode))) (defun doc-view-dvi->pdf-sentinel (proc event) "If DVI->PDF conversion was successful, convert the PDF to PNG now." @@ -439,7 +444,7 @@ (when doc-view-conversion-refresh-interval (setq doc-view-current-timer (run-at-time "1 secs" doc-view-conversion-refresh-interval - 'doc-view-display-maybe + 'doc-view-display doc-view-current-doc)))) (defun doc-view-pdf->txt-sentinel (proc event) @@ -482,10 +487,11 @@ (setq doc-view-current-converter-process (start-process "ps->pdf" doc-view-conversion-buffer doc-view-ps2pdf-program - ps pdf ;; Avoid security problems when rendering files from ;; untrusted sources. - "-dSAFER") + "-dSAFER" + ;; in-file and out-file + ps pdf) mode-line-process (list (format ":%s" doc-view-current-converter-process))) (set-process-sentinel doc-view-current-converter-process 'doc-view-ps->pdf-sentinel) @@ -499,7 +505,7 @@ (clear-image-cache) (let ((png-file (concat (doc-view-current-cache-dir) "page-%d.png"))) - (make-directory doc-view-current-cache-dir t) + (make-directory (doc-view-current-cache-dir) t) (if (not (string= (file-name-extension doc-view-current-doc) "dvi")) ;; Convert to PNG images. (doc-view-pdf/ps->png doc-view-current-doc png-file) @@ -576,11 +582,6 @@ nil (string< a b)))) -(defun doc-view-display-maybe (doc) - "Call `doc-view-display' iff we're in the image display." - (when (eq doc-view-current-display 'image) - (doc-view-display doc))) - (defun doc-view-display (doc) "Start viewing the document DOC." (set-buffer (get-file-buffer doc)) @@ -603,58 +604,39 @@ For now these keys are useful: `q' : Bury this buffer. Conversion will go on in background. -`k' : Kill the conversion process and this buffer.\n") +`k' : Kill the conversion process and this buffer. +`K' : Kill the conversion process.\n") (set-buffer-modified-p nil)) (defun doc-view-show-tooltip () (interactive) (tooltip-show doc-view-current-info)) -;;;;; Toggle between text and image display +;;;;; Toggle between editing and viewing (defun doc-view-toggle-display () - "Start or stop displaying a document file as a set of images. -This command toggles between showing the text of the document -file and showing the document as a set of images." + "Toggle between editing a document as text or viewing it." (interactive) - (if (get-text-property (point-min) 'display) - ;; Switch to text display - (let ((inhibit-read-only t)) + (if (eq major-mode 'doc-view-mode) + ;; Switch to editing mode + (progn + (doc-view-kill-proc) + (setq buffer-read-only nil) (erase-buffer) - (insert-file-contents doc-view-current-doc) - (use-local-map doc-view-mode-text-map) - (setq mode-name "DocView[text]" - doc-view-current-display 'text) - (if (called-interactively-p) - (message "Repeat this command to go back to displaying the file as images"))) - ;; Switch to image display - (let ((inhibit-read-only t)) - (erase-buffer) - (doc-view-buffer-message) - (setq doc-view-current-page (or doc-view-current-page 1)) - (if (file-exists-p (doc-view-current-cache-dir)) - (progn - (message "DocView: using cached files!") - (doc-view-display doc-view-current-doc)) - (doc-view-convert-current-doc)) - (use-local-map doc-view-mode-map) - (setq mode-name (format "DocView") - doc-view-current-display 'image) - (if (called-interactively-p) - (message "Repeat this command to go back to displaying the file as text")))) - (set-buffer-modified-p nil)) - -;;;;; Leave doc-view-mode and open the file for edit - -(defun doc-view-edit-doc () - "Leave `doc-view-mode' and open the current doc with an appropriate editing mode." - (interactive) - (let ((filename doc-view-current-doc) - (auto-mode-alist (append '(("\\.[eE]?[pP][sS]\\'" . ps-mode) - ("\\.\\(pdf\\|PDF\\|dvi\\|DVI\\)$" . fundamental-mode)) - auto-mode-alist))) - (kill-buffer (current-buffer)) - (find-file filename))) + (insert-file-contents buffer-file-name) + ;; Switch to the previously used major mode or fall back to fundamental + ;; mode. + (if doc-view-previous-major-mode + (funcall doc-view-previous-major-mode) + (fundamental-mode)) + (doc-view-minor-mode 1) + (set-buffer-modified-p nil)) + ;; Switch to doc-view-mode + (when (and (buffer-modified-p) + (y-or-n-p "The buffer has been modified. Save the changes? ")) + (save-buffer)) + (erase-buffer) + (doc-view-mode))) ;;;; Searching @@ -742,8 +724,9 @@ (defun doc-view-search-next-match (arg) "Go to the ARGth next matching page." (interactive "p") - (let* ((next-pages (remove-if (lambda (i) (<= (car i) doc-view-current-page)) - doc-view-current-search-matches)) + (let* ((next-pages (doc-view-remove-if + (lambda (i) (<= (car i) doc-view-current-page)) + doc-view-current-search-matches)) (page (car (nth (1- arg) next-pages)))) (if page (doc-view-goto-page page) @@ -755,8 +738,9 @@ (defun doc-view-search-previous-match (arg) "Go to the ARGth previous matching page." (interactive "p") - (let* ((prev-pages (remove-if (lambda (i) (>= (car i) doc-view-current-page)) - doc-view-current-search-matches)) + (let* ((prev-pages (doc-view-remove-if + (lambda (i) (>= (car i) doc-view-current-page)) + doc-view-current-search-matches)) (page (car (nth (1- arg) (nreverse prev-pages))))) (if page (doc-view-goto-page page) @@ -770,37 +754,69 @@ (put 'doc-view-mode 'mode-class 'special) ;;;###autoload -(define-derived-mode doc-view-mode nil "DocView" +(defun doc-view-mode () "Major mode in DocView buffers. You can use \\\\[doc-view-toggle-display] to -toggle between display as a set of images and display as text." - :group 'doc-view - (make-local-variable 'doc-view-current-files) - (make-local-variable 'doc-view-current-doc) - (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) - (setq doc-view-current-doc (buffer-file-name)) +toggle between displaying the document or editing it as text." + (interactive) + (let* ((prev-major-mode (if (eq major-mode 'doc-view-mode) + doc-view-previous-major-mode + major-mode))) + (kill-all-local-variables) + (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-doc) buffer-file-name) + (set (make-local-variable 'doc-view-previous-major-mode) prev-major-mode)) (insert-file-contents doc-view-current-doc) - (use-local-map doc-view-mode-text-map) - (setq mode-name "DocView[text]" - doc-view-current-display 'text + (use-local-map doc-view-mode-map) + (setq mode-name "DocView" buffer-read-only t - revert-buffer-function 'doc-view-reconvert-doc) + revert-buffer-function 'doc-view-reconvert-doc + major-mode 'doc-view-mode) ;; Switch to image display if possible (if (and (display-images-p) - (image-type-available-p 'png) - (not (get-text-property (point-min) 'display))) - (doc-view-toggle-display)) - (message - "%s" - (substitute-command-keys - "Type \\[doc-view-toggle-display] to toggle between image and text display."))) + (image-type-available-p 'png)) + (let ((inhibit-read-only t)) + (erase-buffer) + (doc-view-buffer-message) + (setq doc-view-current-page (or doc-view-current-page 1)) + (if (file-exists-p (doc-view-current-cache-dir)) + (progn + (message "DocView: using cached files!") + (doc-view-display doc-view-current-doc)) + (doc-view-convert-current-doc)) + (use-local-map doc-view-mode-map) + (message + "%s" + (substitute-command-keys + (concat "Type \\[doc-view-toggle-display] to toggle between " + "editing or viewing the document.")))) + (message + "%s" + (substitute-command-keys + (concat "No image (png) support available. Type \\[doc-view-toggle-display] " + "to switch to an editing mode."))))) + +;;;###autoload +(define-minor-mode doc-view-minor-mode + "Toggle Doc view minor mode. +With arg, turn Doc view minor mode on if arg is positive, off otherwise. +See the command `doc-view-mode' for more information on this mode." + nil " DocView" doc-view-minor-mode-map + :group 'doc-view + (when doc-view-minor-mode + (add-hook 'change-major-mode-hook (lambda () (doc-view-minor-mode -1)) nil t) + (message + "%s" + (substitute-command-keys + "Type \\[doc-view-toggle-display] to toggle between editing or viewing the document.")))) (defun doc-view-clear-cache () "Delete the whole cache (`doc-view-cache-directory')." --=-=-= Bye, Tassilo __________ [1] http://www.tsdh.de/stuff/doc-view.patch --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --=-=-=--