all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tassilo Horn <tassilo@member.fsf.org>
To: emacs-devel@gnu.org
Subject: Please install: Some improvements to doc-view.el
Date: Tue, 02 Oct 2007 11:15:37 +0200	[thread overview]
Message-ID: <87bqbhkhc6.fsf@baldur.tsdh.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 601 bytes --]

Hi all,

would someone with write access please install this patch for me?  It
includes the following improvements:

1. When doing `M-x doc-view' the filename completion doesn't hide pdf,
   ps, and dvi files anymore.

2. I added a simple around advice to `view-file' that asks to use
   `doc-view' instead of `view-file' if file is a pdf, ps or dvi file.
   This enables users to use the normal `v' command in dired to open
   document files.

The patch is a bit large because the current version was indented with
spaces, this one uses both spaces and tabs (width 8) as it's the default
for emacs.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: doc-view.patch --]
[-- Type: text/x-patch, Size: 24922 bytes --]

Index: lisp/doc-view.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/doc-view.el,v
retrieving revision 1.2
diff -u -r1.2 doc-view.el
--- lisp/doc-view.el	10 Sep 2007 11:53:00 -0000	1.2
+++ lisp/doc-view.el	2 Oct 2007 09:06:13 -0000
@@ -5,7 +5,7 @@
 ;; Author: Tassilo Horn <tassilo@member.fsf.org>
 ;; Maintainer: Tassilo Horn <tassilo@member.fsf.org>
 ;; Keywords: files, pdf, ps, dvi
-;; Version: <2007-09-07 Fri 15:28>
+;; Version: <2007-10-02 Tue 10:40>
 
 ;; 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:
 
@@ -150,7 +152,7 @@
   :group 'doc-view)
 
 (defcustom doc-view-cache-directory (concat temporary-file-directory
-                                            "doc-view")
+					    "doc-view")
   "The base directory, where the PNG images will be saved."
   :type '(directory)
   :group 'doc-view)
@@ -246,36 +248,36 @@
   (interactive "nPage: ")
   (let ((len (length doc-view-current-files)))
     (if (< page 1)
-        (setq page 1)
+	(setq page 1)
       (when (> page len)
-        (setq page len)))
+	(setq page len)))
     (setq doc-view-current-page page
-          doc-view-current-info
-          (concat
-           (propertize
-            (format "Page %d of %d."
-                    doc-view-current-page
-                    len) 'face 'bold)
-           ;; Tell user if converting isn't finished yet
-           (if doc-view-current-converter-process
-               " (still converting...)\n"
-             "\n")
-           ;; Display context infos if this page matches the last search
-           (when (and doc-view-current-search-matches
-                      (assq doc-view-current-page
-                            doc-view-current-search-matches))
-             (concat (propertize "Search matches:\n" 'face 'bold)
-                     (let ((contexts ""))
-                       (dolist (m (cdr (assq doc-view-current-page
-                                             doc-view-current-search-matches)))
-                         (setq contexts (concat contexts "  - \"" m "\"\n")))
-                       contexts)))))
+	  doc-view-current-info
+	  (concat
+	   (propertize
+	    (format "Page %d of %d."
+		    doc-view-current-page
+		    len) 'face 'bold)
+	   ;; Tell user if converting isn't finished yet
+	   (if doc-view-current-converter-process
+	       " (still converting...)\n"
+	     "\n")
+	   ;; Display context infos if this page matches the last search
+	   (when (and doc-view-current-search-matches
+		      (assq doc-view-current-page
+			    doc-view-current-search-matches))
+	     (concat (propertize "Search matches:\n" 'face 'bold)
+		     (let ((contexts ""))
+		       (dolist (m (cdr (assq doc-view-current-page
+					     doc-view-current-search-matches)))
+			 (setq contexts (concat contexts "  - \"" m "\"\n")))
+		       contexts)))))
     ;; Update the buffer
     (setq inhibit-read-only t)
     (erase-buffer)
     (let ((beg (point)))
       (doc-view-insert-image (nth (1- page) doc-view-current-files)
-                             :pointer 'arrow)
+			     :pointer 'arrow)
       (put-text-property beg (point) 'help-echo doc-view-current-info))
     (insert "\n" doc-view-current-info)
     (goto-char (point-min))
@@ -315,7 +317,7 @@
   (condition-case nil
       (scroll-down)
     (error (doc-view-previous-page)
-           (goto-char (point-max)))))
+	   (goto-char (point-max)))))
 
 (defun doc-view-kill-proc-and-buffer ()
   "Kill the current converter process and buffer."
@@ -338,13 +340,13 @@
       doc-view-current-cache-dir
     (file-name-as-directory
      (concat (file-name-as-directory doc-view-cache-directory)
-             (with-temp-buffer
-               (insert-file-contents-literally file)
-               (md5 (current-buffer)))))))
+	     (with-temp-buffer
+	       (insert-file-contents-literally file)
+	       (md5 (current-buffer)))))))
 
 (defun doc-view-dvi->pdf-sentinel (proc event)
   "If DVI->PDF conversion was successful, convert the PDF to PNG
-now."
+ now."
   (if (not (string-match "finished" event))
       (message "DocView: dvi->pdf process changed status to %s." event)
     (set-buffer (process-get proc 'buffer))
@@ -352,20 +354,20 @@
     (message "DocView: finished conversion from DVI to PDF!")
     ;; Now go on converting this PDF to a set of PNG files.
     (let* ((pdf (process-get proc 'pdf-file))
-           (png (concat (doc-view-file-name-to-directory-name
-                         doc-view-current-doc)
-                        "page-%d.png")))
+	   (png (concat (doc-view-file-name-to-directory-name
+			 doc-view-current-doc)
+			"page-%d.png")))
       (doc-view-pdf/ps->png pdf png))))
 
 (defun doc-view-dvi->pdf (dvi pdf)
   "Convert DVI to PDF asynchrounously."
   (message "DocView: converting DVI to PDF now!")
   (setq doc-view-current-converter-process
-        (start-process "doc-view-dvi->pdf" doc-view-conversion-buffer
-                       doc-view-dvipdfm-program
-                       "-o" pdf dvi))
+	(start-process "doc-view-dvi->pdf" doc-view-conversion-buffer
+		       doc-view-dvipdfm-program
+		       "-o" pdf dvi))
   (set-process-sentinel doc-view-current-converter-process
-                        'doc-view-dvi->pdf-sentinel)
+			'doc-view-dvi->pdf-sentinel)
   (process-put doc-view-current-converter-process 'buffer   (current-buffer))
   (process-put doc-view-current-converter-process 'pdf-file pdf))
 
@@ -386,44 +388,44 @@
   "Convert PDF-PS to PNG asynchrounously."
   (message "DocView: converting PDF or PS to PNG now!")
   (setq doc-view-current-converter-process
-        (apply 'start-process
-               (append (list "doc-view-pdf/ps->png" doc-view-conversion-buffer
-                             doc-view-ghostscript-program)
-                       doc-view-ghostscript-options
-                       (list (concat "-sOutputFile=" png))
-                       (list pdf-ps))))
+	(apply 'start-process
+	       (append (list "doc-view-pdf/ps->png" doc-view-conversion-buffer
+			     doc-view-ghostscript-program)
+		       doc-view-ghostscript-options
+		       (list (concat "-sOutputFile=" png))
+		       (list pdf-ps))))
   (process-put doc-view-current-converter-process
-               'buffer (current-buffer))
+	       'buffer (current-buffer))
   (set-process-sentinel doc-view-current-converter-process
-                        'doc-view-pdf/ps->png-sentinel)
+			'doc-view-pdf/ps->png-sentinel)
   (when doc-view-conversion-refresh-interval
     (setq doc-view-current-timer
-          (run-at-time "1 secs" doc-view-conversion-refresh-interval
-                       'doc-view-display
-                       doc-view-current-doc))))
+	  (run-at-time "1 secs" doc-view-conversion-refresh-interval
+		       'doc-view-display
+		       doc-view-current-doc))))
 
 (defun doc-view-pdf->txt-sentinel (proc event)
   (if (not (string-match "finished" event))
       (message "DocView: converter process changed status to %s." event)
     (let ((current-buffer (current-buffer))
-          (proc-buffer    (process-get proc 'buffer)))
+	  (proc-buffer    (process-get proc 'buffer)))
       (set-buffer proc-buffer)
       (setq doc-view-current-converter-process nil)
       (message "DocView: finished conversion from PDF to TXT!")
       ;; If the user looks at the DocView buffer where the conversion was
       ;; performed, search anew.  This time it will be queried for a regexp.
       (when (eq current-buffer proc-buffer)
-        (doc-view-search)))))
+	(doc-view-search)))))
 
 (defun doc-view-pdf->txt (pdf txt)
   "Convert PDF to TXT asynchrounously."
   (message "DocView: converting PDF to TXT now!")
   (setq doc-view-current-converter-process
-        (start-process "doc-view-pdf->txt" doc-view-conversion-buffer
-                       doc-view-pdftotext-program "-raw"
-                       pdf txt))
+	(start-process "doc-view-pdf->txt" doc-view-conversion-buffer
+		       doc-view-pdftotext-program "-raw"
+		       pdf txt))
   (set-process-sentinel doc-view-current-converter-process
-                        'doc-view-pdf->txt-sentinel)
+			'doc-view-pdf->txt-sentinel)
   (process-put doc-view-current-converter-process 'buffer (current-buffer)))
 
 (defun doc-view-ps->pdf-sentinel (proc event)
@@ -434,19 +436,19 @@
     (message "DocView: finished conversion from PS to PDF!")
     ;; Now we can transform to plain text.
     (doc-view-pdf->txt (process-get proc 'pdf-file)
-                       (concat (doc-view-file-name-to-directory-name
-                                doc-view-current-doc)
-                               "doc.txt"))))
+		       (concat (doc-view-file-name-to-directory-name
+				doc-view-current-doc)
+			       "doc.txt"))))
 
 (defun doc-view-ps->pdf (ps pdf)
   "Convert PS to PDF asynchronously."
   (message "DocView: converting PS to PDF now!")
   (setq doc-view-current-converter-process
-        (start-process "doc-view-ps->pdf" doc-view-conversion-buffer
-                       doc-view-ps2pdf-program
-                       ps pdf))
+	(start-process "doc-view-ps->pdf" doc-view-conversion-buffer
+		       doc-view-ps2pdf-program
+		       ps pdf))
   (set-process-sentinel doc-view-current-converter-process
-                        'doc-view-ps->pdf-sentinel)
+			'doc-view-ps->pdf-sentinel)
   (process-put doc-view-current-converter-process 'buffer   (current-buffer))
   (process-put doc-view-current-converter-process 'pdf-file pdf))
 
@@ -457,18 +459,18 @@
 `doc-view-file-name-to-directory-name'."
   (clear-image-cache)
   (let* ((dir (doc-view-file-name-to-directory-name doc))
-         (png-file (concat (file-name-as-directory dir) "page-%d.png")))
+	 (png-file (concat (file-name-as-directory dir) "page-%d.png")))
     (when (file-exists-p dir)
       (dired-delete-file dir 'always))
     (make-directory dir t)
     (if (not (string= (file-name-extension doc) "dvi"))
-        ;; Convert to PNG images.
-        (doc-view-pdf/ps->png doc png-file)
+	;; Convert to PNG images.
+	(doc-view-pdf/ps->png doc png-file)
       ;; DVI files have to be converted to PDF before GhostScript can process
       ;; it.
       (doc-view-dvi->pdf doc
-                         (concat (file-name-as-directory dir)
-                                 "doc.pdf")))))
+			 (concat (file-name-as-directory dir)
+				 "doc.pdf")))))
 
 ;;;; DocView Mode
 
@@ -501,10 +503,10 @@
 do that.  To reset the slice use `doc-view-reset-slice'."
   (interactive
    (let* ((size (image-size doc-view-current-image t))
-          (a (read-number (format "Top-left X (0..%d): " (car size))))
-          (b (read-number (format "Top-left Y (0..%d): " (cdr size))))
-          (c (read-number (format "Width (0..%d): " (- (car size) a))))
-          (d (read-number (format "Height (0..%d): " (- (cdr size) b)))))
+	  (a (read-number (format "Top-left X (0..%d): " (car size))))
+	  (b (read-number (format "Top-left Y (0..%d): " (cdr size))))
+	  (c (read-number (format "Width (0..%d): " (- (car size) a))))
+	  (d (read-number (format "Height (0..%d): " (- (cdr size) b)))))
      (list a b c d)))
   (setq doc-view-current-slice (list x y width height))
   ;; Redisplay
@@ -519,14 +521,14 @@
   (let (x y w h done)
     (while (not done)
       (let ((e (read-event
-                (concat "Press mouse-1 at the top-left corner and "
-                        "drag it to the bottom-right corner!"))))
-        (when (eq (car e) 'drag-mouse-1)
-          (setq x (car (posn-object-x-y (event-start e))))
-          (setq y (cdr (posn-object-x-y (event-start e))))
-          (setq w (- (car (posn-object-x-y (event-end e))) x))
-          (setq h (- (cdr (posn-object-x-y (event-end e))) y))
-          (setq done t))))
+		(concat "Press mouse-1 at the top-left corner and "
+			"drag it to the bottom-right corner!"))))
+	(when (eq (car e) 'drag-mouse-1)
+	  (setq x (car (posn-object-x-y (event-start e))))
+	  (setq y (cdr (posn-object-x-y (event-start e))))
+	  (setq w (- (car (posn-object-x-y (event-end e))) x))
+	  (setq h (- (cdr (posn-object-x-y (event-end e))) y))
+	  (setq done t))))
     (doc-view-set-slice x y w h)))
 
 (defun doc-view-reset-slice ()
@@ -553,7 +555,7 @@
   (if (< (length a) (length b))
       t
     (if (> (length a) (length b))
-        nil
+	nil
       (string< a b))))
 
 (defun doc-view-display (doc)
@@ -561,8 +563,8 @@
   (let ((dir (doc-view-file-name-to-directory-name doc)))
     (set-buffer (format "*DocView: %s*" doc))
     (setq doc-view-current-files
-          (sort (directory-files dir t "page-[0-9]+\\.png" t)
-                'doc-view-sort))
+	  (sort (directory-files dir t "page-[0-9]+\\.png" t)
+		'doc-view-sort))
     (when (> (length doc-view-current-files) 0)
       (doc-view-goto-page doc-view-current-page))))
 
@@ -570,8 +572,8 @@
   (setq inhibit-read-only t)
   (erase-buffer)
   (insert (propertize "Welcome to DocView!" 'face 'bold)
-          "\n"
-          "
+	  "\n"
+	  "
 If you  see this buffer  it means that  the document you  want to
 view gets  converted to PNG now  and the conversion  of the first
 page           hasn't          finished           yet          or
@@ -579,8 +581,8 @@
 
 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")
+`q' : Bury this buffer.  Conversion will go on in background.
+`k' : Kill the conversion process and this buffer.\n")
   (setq inhibit-read-only nil))
 
 (defun doc-view-show-tooltip ()
@@ -591,39 +593,35 @@
 
 (defun doc-view-search-internal (regexp file)
   "Return a list of FILE's pages that contain text matching REGEXP.
-The value is an alist of the form
-
-    (PAGE CONTEXTS)
-
-where PAGE is the pagenumber and CONTEXTS are the lines
-containing the match."
+The value is an alist of the form (PAGE CONTEXTS) where PAGE is
+the pagenumber and CONTEXTS are all lines of text containing a match."
   (with-temp-buffer
     (insert-file-contents file)
     (let ((page 1)
-          (lastpage 1)
-          matches)
+	  (lastpage 1)
+	  matches)
       (while (re-search-forward (concat "\\(?:\\([\f]\\)\\|\\("
-                                        regexp "\\)\\)") nil t)
-        (when (match-string 1) (incf page))
-        (when (match-string 2)
-          (if (/= page lastpage)
-              (setq matches (push (cons page
-                                        (list (buffer-substring
-                                               (line-beginning-position)
-                                               (line-end-position))))
-                                  matches))
-            (setq matches (cons
-                           (append
-                            (or
-                             ;; This page already is a match.
-                             (car matches)
-                             ;; This is the first match on page.
-                             (list page))
-                            (list (buffer-substring
-                                   (line-beginning-position)
-                                   (line-end-position))))
-                           (cdr matches))))
-          (setq lastpage page)))
+					regexp "\\)\\)") nil t)
+	(when (match-string 1) (incf page))
+	(when (match-string 2)
+	  (if (/= page lastpage)
+	      (setq matches (push (cons page
+					(list (buffer-substring
+					       (line-beginning-position)
+					       (line-end-position))))
+				  matches))
+	    (setq matches (cons
+			   (append
+			    (or
+			     ;; This page already is a match.
+			     (car matches)
+			     ;; This is the first match on page.
+			     (list page))
+			    (list (buffer-substring
+				   (line-beginning-position)
+				   (line-end-position))))
+			   (cdr matches))))
+	  (setq lastpage page)))
       (nreverse matches))))
 
 (defun doc-view-search-no-of-matches (list)
@@ -642,66 +640,66 @@
   ;; New search, so forget the old results.
   (setq doc-view-current-search-matches nil)
   (let ((txt (concat (doc-view-file-name-to-directory-name
-                      doc-view-current-doc)
-                     "doc.txt")))
+		      doc-view-current-doc)
+		     "doc.txt")))
     (if (file-readable-p txt)
-        (progn
-          (setq doc-view-current-search-matches
-                (doc-view-search-internal
-                 (read-from-minibuffer "Regexp: ")
-                 txt))
-          (message "DocView: search yielded %d matches."
-                   (doc-view-search-no-of-matches
-                    doc-view-current-search-matches)))
+	(progn
+	  (setq doc-view-current-search-matches
+		(doc-view-search-internal
+		 (read-from-minibuffer "Regexp: ")
+		 txt))
+	  (message "DocView: search yielded %d matches."
+		   (doc-view-search-no-of-matches
+		    doc-view-current-search-matches)))
       ;; We must convert to TXT first!
       (if doc-view-current-converter-process
-          (message "DocView: please wait till conversion finished.")
-        (let ((ext (file-name-extension doc-view-current-doc)))
-          (cond
-           ((string= ext "pdf")
-            ;; Doc is a PDF, so convert it to TXT
-            (doc-view-pdf->txt doc-view-current-doc txt))
-           ((string= ext "ps")
-            ;; Doc is a PS, so convert it to PDF (which will be converted to
-            ;; TXT thereafter).
-            (doc-view-ps->pdf doc-view-current-doc
-                              (concat (doc-view-file-name-to-directory-name
-                                       doc-view-current-doc)
-                                      "doc.pdf")))
-           ((string= ext "dvi")
-            ;; Doc is a DVI.  This means that a doc.pdf already exists in its
-            ;; cache subdirectory.
-            (doc-view-pdf->txt (concat (doc-view-file-name-to-directory-name
-                                        doc-view-current-doc)
-                                       "doc.pdf")
-                               txt))
-           (t (error "DocView doesn't know what to do"))))))))
+	  (message "DocView: please wait till conversion finished.")
+	(let ((ext (file-name-extension doc-view-current-doc)))
+	  (cond
+	   ((string= ext "pdf")
+	    ;; Doc is a PDF, so convert it to TXT
+	    (doc-view-pdf->txt doc-view-current-doc txt))
+	   ((string= ext "ps")
+	    ;; Doc is a PS, so convert it to PDF (which will be converted to
+	    ;; TXT thereafter).
+	    (doc-view-ps->pdf doc-view-current-doc
+			      (concat (doc-view-file-name-to-directory-name
+				       doc-view-current-doc)
+				      "doc.pdf")))
+	   ((string= ext "dvi")
+	    ;; Doc is a DVI.  This means that a doc.pdf already exists in its
+	    ;; cache subdirectory.
+	    (doc-view-pdf->txt (concat (doc-view-file-name-to-directory-name
+					doc-view-current-doc)
+				       "doc.pdf")
+			       txt))
+	   (t (error "DocView doesn't know what to do"))))))))
 
 (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))
-         (page (car (nth (1- arg) next-pages))))
+				doc-view-current-search-matches))
+	 (page (car (nth (1- arg) next-pages))))
     (if page
-        (doc-view-goto-page page)
+	(doc-view-goto-page page)
       (when (and
-             doc-view-current-search-matches
-             (y-or-n-p "No more matches after current page.  Wrap to first match? "))
-        (doc-view-goto-page (caar doc-view-current-search-matches))))))
+	     doc-view-current-search-matches
+	     (y-or-n-p "No more matches after current page.  Wrap to first match? "))
+	(doc-view-goto-page (caar doc-view-current-search-matches))))))
 
 (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))
-         (page (car (nth (1- arg) (nreverse prev-pages)))))
+				doc-view-current-search-matches))
+	 (page (car (nth (1- arg) (nreverse prev-pages)))))
     (if page
-        (doc-view-goto-page page)
+	(doc-view-goto-page page)
       (when (and
-             doc-view-current-search-matches
-             (y-or-n-p "No more matches before current page.  Wrap to last match? "))
-        (doc-view-goto-page (caar (last doc-view-current-search-matches)))))))
+	     doc-view-current-search-matches
+	     (y-or-n-p "No more matches before current page.  Wrap to last match? "))
+	(doc-view-goto-page (caar (last doc-view-current-search-matches)))))))
 
 ;;;; User Interface Commands
 
@@ -713,24 +711,31 @@
 cached files and convert anew."
   (interactive "P")
   (if (not (and (image-type-available-p 'png)
-                (display-images-p)))
+		(display-images-p)))
       (message "DocView: your emacs or display doesn't support png images.")
     (let* ((doc (or file
-                    (expand-file-name (read-file-name "File: " nil nil t))))
-           (buffer (get-buffer-create (format "*DocView: %s*" doc)))
-           (dir (doc-view-file-name-to-directory-name doc)))
+		    (expand-file-name
+		     (let ((completion-ignored-extensions
+			    ;; Don't hide files doc-view can display
+			    (remove-if (lambda (str)
+					 (string-match "\\.\\(ps\\|pdf\\|dvi\\)$"
+						       str))
+				       completion-ignored-extensions)))
+		       (read-file-name "File: " nil nil t)))))
+	   (buffer (get-buffer-create (format "*DocView: %s*" doc)))
+	   (dir (doc-view-file-name-to-directory-name doc)))
       (switch-to-buffer buffer)
       (doc-view-buffer-message)
       (doc-view-mode)
       (setq doc-view-current-doc doc)
       (setq doc-view-current-page 1)
       (if (not (and (file-exists-p dir)
-                    (not no-cache)))
-          (progn
-            (setq doc-view-current-cache-dir nil)
-            (doc-view-convert-doc doc-view-current-doc))
-        (message "DocView: using cached files!")
-        (doc-view-display doc-view-current-doc)))))
+		    (not no-cache)))
+	  (progn
+	    (setq doc-view-current-cache-dir nil)
+	    (doc-view-convert-doc doc-view-current-doc))
+	(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.
@@ -738,10 +743,23 @@
 
 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)"
+  (define-key dired-mode-map (kbd \"C-c d\") 'doc-view-dired)
+
+This function is now OBSOLETE because of a more general solution:
+There's an advice to `view-file' which asks to open the file with
+`doc-view' if it's a PS, PDF or DVI file. Simply hit `v' on a
+file in dired to view it."
   (interactive "P")
   (doc-view no-cache (dired-get-file-for-visit)))
 
+(defadvice view-file (around doc-view-file (file) activate)
+  "View FILE with doc-view if it is a PostScript, a PDF or a DVI file.
+Use the the cached image files if possible."
+  (if (and (string-match "\\.\\(ps\\|pdf\\|dvi\\)$" file)
+	   (y-or-n-p "Open with `doc-view' instead of `view-file'? "))
+      (doc-view nil file)
+    ad-do-it))
+
 (defun doc-view-clear-cache ()
   "Delete the whole cache (`doc-view-cache-directory')."
   (interactive)
Index: lisp/ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.11854
diff -u -r1.11854 ChangeLog
--- lisp/ChangeLog	2 Oct 2007 02:05:46 -0000	1.11854
+++ lisp/ChangeLog	2 Oct 2007 09:06:19 -0000
@@ -1,3 +1,11 @@
+2007-10-02  Tassilo Horn  <tassilo@member.fsf.org>
+
+	* doc-view.el (doc-view): Don't hide document files (pdf, dvi, ps)
+	in the filename completion.
+	(doc-view-dired): Mark as obsolete.
+	(view-file): New advise: Offer to open with doc-view instead of
+	view-file for pdf, ps and dvi files.
+
 2007-10-02  Richard Stallman  <rms@gnu.org>
 
 	* frame.el (cursor-in-non-selected-windows): Doc fix.

[-- Attachment #3: Type: text/plain, Size: 71 bytes --]


The patch includes the ChangeLog entry, too.

Bye and thanks,
Tassilo

[-- Attachment #4: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

             reply	other threads:[~2007-10-02  9:15 UTC|newest]

Thread overview: 98+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-02  9:15 Tassilo Horn [this message]
2007-10-02 13:04 ` Please install: Some improvements to doc-view.el Davis Herring
2007-10-02 14:42   ` Tassilo Horn
2007-10-02 16:49   ` Tassilo Horn
2007-10-02 17:33     ` Andreas Schwab
2007-10-02 18:19       ` Tassilo Horn
2007-10-03 18:37     ` Richard Stallman
2007-10-03 23:29       ` Michaël Cadilhac
2007-10-04  7:53       ` Tassilo Horn
2007-10-05 16:13         ` Richard Stallman
2007-10-05 16:43           ` Tassilo Horn
2007-10-06 14:16             ` Tassilo Horn
2007-10-06 23:54               ` Juri Linkov
2007-10-08 15:26                 ` Sascha Wilde
2007-10-08 15:51                   ` Tassilo Horn
2007-10-08 19:34                     ` Juri Linkov
2007-10-09  9:02                       ` Tassilo Horn
2007-10-09 21:55                         ` Juri Linkov
2007-10-11  1:28                           ` Doc-view as default viewer for pdf, ps and dvi files (was: Please install: Some improvements to doc-view.el) Tassilo Horn
2007-10-12  2:46                             ` Richard Stallman
2007-10-12 13:09                               ` Doc-view as default viewer for pdf, ps and dvi files Tassilo Horn
2007-10-13  0:18                                 ` Richard Stallman
2007-10-13  8:25                                   ` Tassilo Horn
2007-10-13 19:48                                     ` Richard Stallman
2007-10-17 23:34                             ` Juri Linkov
2007-10-18  6:47                               ` Tassilo Horn
2007-10-18  8:28                               ` Tassilo Horn
2007-10-07 13:10               ` Please install: Some improvements to doc-view.el Richard Stallman
2007-10-08 19:42                 ` Juri Linkov
2007-10-09 20:03                   ` Richard Stallman
2007-10-09 21:30                     ` Tassilo Horn
2007-10-15 18:31                       ` Richard Stallman
2007-10-15 20:58                         ` Tassilo Horn
2007-10-17 23:49                           ` Scrolling in doc-view Chong Yidong
2007-10-18  6:27                             ` Tassilo Horn
2007-10-18  8:29                             ` Tassilo Horn
2007-10-09 21:54                     ` Please install: Some improvements to doc-view.el Juri Linkov
2007-10-09 22:17                       ` mailcap viewers in dired; gnus-dired.el, mailcap.el (was: Please install: Some improvements to doc-view.el) Reiner Steib
2007-10-09 22:47                         ` Juri Linkov
2007-10-10 21:20                           ` mailcap viewers in dired; gnus-dired.el, mailcap.el Reiner Steib
2007-10-10 23:43                             ` Juri Linkov
2007-10-15  1:37                             ` Richard Stallman
2007-10-15 23:46                               ` Juri Linkov
2007-10-16  6:49                                 ` Tassilo Horn
2007-10-18 17:48                               ` Lars Magne Ingebrigtsen
2007-10-19  5:40                                 ` Richard Stallman
2007-10-15  1:37                       ` Please install: Some improvements to doc-view.el Richard Stallman
2007-10-15 23:45                         ` Juri Linkov
2007-10-16 19:09                           ` Richard Stallman
2007-10-16 19:26                             ` Leo
2007-10-17  5:03                               ` Richard Stallman
2007-10-17 10:15                                 ` Leo
2007-10-17 20:49                                   ` Richard Stallman
2007-10-17 21:12                                     ` Leo
2007-10-19  5:40                                       ` Richard Stallman
2007-10-17 22:04                                     ` doc-view and mailcap (was: Please install: Some improvements to doc-view.el) Reiner Steib
2007-10-17 23:35                                       ` doc-view and mailcap Juri Linkov
2007-10-18  7:31                                         ` Reiner Steib
2007-11-25 22:53                                           ` Reiner Steib
2007-11-26 11:16                                             ` Tassilo Horn
2007-12-01 18:26                                               ` Tassilo Horn
2007-12-01 19:50                                                 ` Reiner Steib
2007-12-03  0:33                                                   ` Juri Linkov
2007-12-03  7:41                                                     ` Reiner Steib
2007-12-03  8:18                                                       ` Tassilo Horn
2007-12-03 18:42                                                         ` Richard Stallman
2007-12-03 22:16                                                           ` Tassilo Horn
2007-12-03 22:55                                                       ` Juri Linkov
2007-12-04  9:20                                                         ` Tassilo Horn
2007-12-04 18:22                                                           ` Reiner Steib
2007-12-04 22:45                                                             ` Juri Linkov
2007-12-05 10:08                                                               ` Tassilo Horn
2007-12-05 20:02                                                                 ` Reiner Steib
2007-12-05 22:45                                                                   ` Juri Linkov
2007-10-16 20:43                             ` doc-view and mailcap (was: Please install: Some improvements to doc-view.el) Reiner Steib
2007-10-17  1:16                               ` doc-view and mailcap Stefan Monnier
2007-10-17 14:10                                 ` Richard Stallman
2007-10-17 14:39                                   ` Stefan Monnier
2007-10-17 16:55                                     ` Reiner Steib
2007-10-17 23:36                                       ` Juri Linkov
2007-10-18  5:02                                     ` Richard Stallman
2007-10-17  5:03                               ` doc-view and mailcap (was: Please install: Some improvements to doc-view.el) Richard Stallman
2007-10-17 17:59                                 ` doc-view and mailcap Reiner Steib
2007-10-17 20:32                                   ` Tassilo Horn
2007-10-17 21:45                                     ` Reiner Steib
2007-10-18  4:19                                       ` Stefan Monnier
2007-10-18  7:33                                         ` Reiner Steib
2007-10-18  8:24                                           ` Tassilo Horn
2007-10-18  6:24                                       ` Tassilo Horn
2007-10-18 20:08                                     ` Richard Stallman
2007-10-18 20:30                                       ` Reiner Steib
2007-10-18 21:22                                         ` Tassilo Horn
2007-10-19  0:42                                           ` Juri Linkov
2007-10-19 17:42                                           ` Richard Stallman
2007-10-16 23:52                             ` Please install: Some improvements to doc-view.el Juri Linkov
2007-10-06 21:47             ` Stefan Monnier
2007-10-07 13:10               ` Richard Stallman
2007-10-07  0:30             ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bqbhkhc6.fsf@baldur.tsdh.de \
    --to=tassilo@member.fsf.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.