emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Please install: Some improvements to doc-view.el


From: Tassilo Horn
Subject: Re: Please install: Some improvements to doc-view.el
Date: Sat, 06 Oct 2007 16:16:25 +0200
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/23.0.50 (gnu/linux)

Tassilo Horn <address@hidden> writes:

> Richard Stallman <address@hidden> writes:
>
>>     So I think that the problem with that was that calling external
>>     programs (which might not be available) is generally not a good
>>     idea.
>>
>> Is it just a matter that they may not be available?
>
> No, probably not.  It was only a wild guess from my side why that
> feature was taken out.  I could only find the messages which discussed
> its inclusion, but not the ones that discussed why it was taken out
> again.  I'll try to find them tomorrow if time allows it.

Ok, this is the thread:

  http://thread.gmane.org/gmane.emacs.devel/31757/focus=31861

It was taken out because the mechanism for invoking external viewers
should be replaced by the one that Gnus already uses.  Unfortunately
that didn't happen and no real discussion followed.

> But what if we use my change in `dired-view-file' and add an
> additional test for (featurep 'doc-view)?  Then users would only be
> asked if doc-view should be used for pdf/ps/dvi files if they required
> it explicitly.  If they do so, we can be sure that they have the
> needed external programs installed.

So I'd say the solution I proposed in the paragraph above is ok.  If you
agree, here's a patch that implements it.

Index: lisp/doc-view.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/doc-view.el,v
retrieving revision 1.4
diff -u -r1.4 doc-view.el
--- lisp/doc-view.el    3 Oct 2007 23:39:58 -0000       1.4
+++ lisp/doc-view.el    6 Oct 2007 14:14:39 -0000
@@ -5,7 +5,7 @@
 ;; Author: Tassilo Horn <address@hidden>
 ;; Maintainer: Tassilo Horn <address@hidden>
 ;; Keywords: files, pdf, ps, dvi
-;; Version: <2007-10-02 Tue 18:21>
+;; Version: <2007-10-06 Sat 16:14>
 
 ;; This file is part of GNU Emacs.
 
@@ -67,8 +67,6 @@
 ;; bottom-right corner of the desired slice.  To reset the slice use
 ;; `doc-view-reset-slice' (bound to `s r').
 ;;
-;; Dired users should have a look at `doc-view-dired'.
-;;
 ;; You can also search within the document.  The command `doc-view-search'
 ;; (bound to `C-s') queries for a search regexp and initializes a list of all
 ;; matching pages and messages how many match-pages were found.  After that you
@@ -80,6 +78,10 @@
 ;; conversion.  When that finishes and you're still viewing the document
 ;; (i.e. you didn't switch to another buffer) you're queried for the regexp
 ;; then.
+;;
+;; Dired users can simply hit `v' on a document file.  If it's a PS, PDF or DVI
+;; file you're asked to open it with `doc-view' instead of `view-file'.
+;;
 
 ;;; Configuration:
 
@@ -332,8 +334,7 @@
 
 (defun doc-view-file-name-to-directory-name (file)
   "Return the directory where the png files of FILE should be saved.
-
-It'a a subdirectory of `doc-view-cache-directory'."
+It's a subdirectory of `doc-view-cache-directory'."
   (if doc-view-current-cache-dir
       doc-view-current-cache-dir
     (file-name-as-directory
@@ -735,16 +736,6 @@
        (message "DocView: using cached files!")
        (doc-view-display doc-view-current-doc)))))
 
-(defun doc-view-dired (no-cache)
-  "View the current dired file with doc-view.
-NO-CACHE is the same as in `doc-view'.
-
-You might want to bind this command to a dired key, e.g.
-
-    (define-key dired-mode-map (kbd \"C-c d\") 'doc-view-dired)"
-  (interactive "P")
-  (doc-view no-cache (dired-get-file-for-visit)))
-
 (defun doc-view-clear-cache ()
   "Delete the whole cache (`doc-view-cache-directory')."
   (interactive)
Index: lisp/dired.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/dired.el,v
retrieving revision 1.369
diff -u -r1.369 dired.el
--- lisp/dired.el       25 Sep 2007 10:45:04 -0000      1.369
+++ lisp/dired.el       6 Oct 2007 14:14:42 -0000
@@ -1771,15 +1771,20 @@
 
 (defun dired-view-file ()
   "In Dired, examine a file in view mode, returning to Dired when done.
-When file is a directory, show it in this buffer if it is inserted.
-Otherwise, display it in another buffer."
+When file is a directory, show it in this buffer if it is
+inserted.  Otherwise, display it in another buffer."
   (interactive)
   (let ((file (dired-get-file-for-visit)))
     (if (file-directory-p file)
        (or (and (cdr dired-subdir-alist)
                 (dired-goto-subdir file))
            (dired file))
-      (view-file file))))
+      ;; for pdf, ps and dvi files doc-view is an appropriate viewer
+      (if (and (featurep 'doc-view)
+              (string-match "\\.\\(pdf\\|ps\\|dvi\\)$" file)
+              (y-or-n-p "Open the file with `doc-view' instead of `view-file'? 
"))
+         (doc-view (y-or-n-p "Use cached PNG files if possible? ") file)
+       (view-file file)))))
 
 (defun dired-find-file-other-window ()
   "In Dired, visit this file or directory in another window."
Index: lisp/ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.11865
diff -u -r1.11865 ChangeLog
--- lisp/ChangeLog      6 Oct 2007 12:00:40 -0000       1.11865
+++ lisp/ChangeLog      6 Oct 2007 14:14:48 -0000
@@ -1,3 +1,10 @@
+2007-10-06  Tassilo Horn  <address@hidden>
+
+       * dired.el (dired-view-file): Ask to use doc-view if file is a
+       pdf/dvi/ps file and doc-view was required by the user.
+
+       * doc-view.el (doc-view-dired): Delete function.
+
 2007-10-06  Michael Albinus  <address@hidden>
 
        * net/tramp.el (top): Move loading of tramp-util.el and
Bye,
Tassilo

reply via email to

[Prev in Thread] Current Thread [Next in Thread]