emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] Changes to emacs/lisp/doc-view.el,v


From: Juri Linkov
Subject: [Emacs-diffs] Changes to emacs/lisp/doc-view.el,v
Date: Sat, 10 Nov 2007 21:53:25 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Juri Linkov <jurta>     07/11/10 21:53:25

Index: doc-view.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/doc-view.el,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- doc-view.el 1 Nov 2007 03:53:32 -0000       1.18
+++ doc-view.el 10 Nov 2007 21:53:25 -0000      1.19
@@ -71,14 +71,14 @@
 ;; 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
-;; can jump to the next page containing a match with
-;; `doc-view-search-next-match' (bound to `C-S-n') or to the previous matching
-;; page with `doc-view-search-previous-match' (bound to `C-S-p').  This works
-;; by searching a plain text representation of the document.  If that doesn't
-;; already exist the first invokation of `doc-view-search' starts the
-;; 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.
+;; can jump to the next page containing a match with an additional `C-s'.  With
+;; `C-r' you can do the same, but backwards.  To search for a new regexp give a
+;; prefix arg to one of the search functions, e.g. by typing `C-u C-s'.  The
+;; searching works by using a plain text representation of the document.  If
+;; that doesn't already exist the first invokation of `doc-view-search' (or
+;; `doc-view-search-backward') starts the 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
 ;; it will be opened using `doc-view-mode'.
@@ -109,6 +109,7 @@
 
 (require 'dired)
 (require 'image-mode)
+(require 'jka-compr)
 
 ;;;; Customization Options
 
@@ -239,8 +240,7 @@
     ;; Searching
     (define-key map (kbd "C-s")       'doc-view-search)
     (define-key map (kbd "<find>")    'doc-view-search)
-    (define-key map (kbd "C-S-n")     'doc-view-search-next-match)
-    (define-key map (kbd "C-S-p")     'doc-view-search-previous-match)
+    (define-key map (kbd "C-r")       'doc-view-search-backward)
     ;; Scrolling
     (define-key map [remap forward-char]  'image-forward-hscroll)
     (define-key map [remap backward-char] 'image-backward-hscroll)
@@ -264,6 +264,7 @@
     ["Reset Slice"             doc-view-reset-slice]
     "---"
     ["Search"                  doc-view-search]
+    ["Search Backwards"         doc-view-search-backward]
     ["Toggle display"          doc-view-toggle-display]
     ))
 
@@ -502,7 +503,7 @@
       ;; 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 nil)))))
 
 (defun doc-view-pdf->txt (pdf txt)
   "Convert PDF to TXT asynchronously."
@@ -733,12 +734,23 @@
       (setq no (+ no (1- (length p)))))
     no))
 
-(defun doc-view-search ()
-  "Query for a regexp and search the current document.
+(defun doc-view-search-backward (new-query)
+  "Call `doc-view-search' for backward search.
+If prefix NEW-QUERY is given, ask for a new regexp."
+  (interactive "P")
+  (doc-view-search arg t))
+
+(defun doc-view-search (new-query &optional backward)
+  "Jump to the next match or initiate a new search if NEW-QUERY is given.
 If the current document hasn't been transformed to plain text
-till now do that first.  You should try searching anew when the
-conversion finished."
-  (interactive)
+till now do that first.
+If BACKWARD is non-nil, jump to the previous match."
+  (interactive "P")
+  (if (and (not arg)
+          doc-view-current-search-matches)
+      (if backward
+         (doc-view-search-previous-match 1)
+       (doc-view-search-next-match 1))
   ;; New search, so forget the old results.
   (setq doc-view-current-search-matches nil)
   (let ((txt (expand-file-name "doc.txt"
@@ -772,7 +784,7 @@
            (doc-view-pdf->txt (expand-file-name "doc.pdf"
                                                  (doc-view-current-cache-dir))
                               txt))
-          (t (error "DocView doesn't know what to do"))))))))
+            (t (error "DocView doesn't know what to do")))))))))
 
 (defun doc-view-search-next-match (arg)
   "Go to the ARGth next matching page."
@@ -835,6 +847,17 @@
 You can use \\<doc-view-mode-map>\\[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)))
   (let* ((prev-major-mode (if (eq major-mode 'doc-view-mode)
                              doc-view-previous-major-mode
                            major-mode)))
@@ -864,7 +887,7 @@
        buffer-read-only t
        major-mode 'doc-view-mode)
   (doc-view-initiate-display)
-  (run-mode-hooks 'doc-view-mode-hook))
+    (run-mode-hooks 'doc-view-mode-hook)))
 
 ;;;###autoload
 (define-minor-mode doc-view-minor-mode




reply via email to

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