aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog11
-rw-r--r--lisp/doc-view.el84
2 files changed, 55 insertions, 40 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 85574e28651..cb0d980e0b0 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,14 @@
12007-12-06 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * doc-view.el (doc-view-dvi->pdf-sentinel)
4 (doc-view-pdf/ps->png-sentinel, doc-view-pdf->txt-sentinel)
5 (doc-view-ps->pdf-sentinel, doc-view-display): Don't change buffer
6 within a sentinel or timer.
7 (doc-view-display): Don't try to display before the requested page
8 is available, unless told to do so explicitly.
9 (doc-view-pdf/ps->png-sentinel, doc-view-initiate-display):
10 Force display even if the requested page is not available.
11
12007-12-06 Richard Stallman <rms@gnu.org> 122007-12-06 Richard Stallman <rms@gnu.org>
2 13
3 * help-fns.el (describe-function-1): Call ad-get-advice-info 14 * help-fns.el (describe-function-1): Call ad-get-advice-info
diff --git a/lisp/doc-view.el b/lisp/doc-view.el
index 0e336b12dd5..9073ce1536a 100644
--- a/lisp/doc-view.el
+++ b/lisp/doc-view.el
@@ -508,14 +508,14 @@ Should be invoked when the cached images aren't up-to-date."
508 "If DVI->PDF conversion was successful, convert the PDF to PNG now." 508 "If DVI->PDF conversion was successful, convert the PDF to PNG now."
509 (if (not (string-match "finished" event)) 509 (if (not (string-match "finished" event))
510 (message "DocView: dvi->pdf process changed status to %s." event) 510 (message "DocView: dvi->pdf process changed status to %s." event)
511 (set-buffer (process-get proc 'buffer)) 511 (with-current-buffer (process-get proc 'buffer)
512 (setq doc-view-current-converter-process nil 512 (setq doc-view-current-converter-process nil
513 mode-line-process nil) 513 mode-line-process nil)
514 ;; Now go on converting this PDF to a set of PNG files. 514 ;; Now go on converting this PDF to a set of PNG files.
515 (let* ((pdf (process-get proc 'pdf-file)) 515 (let* ((pdf (process-get proc 'pdf-file))
516 (png (expand-file-name "page-%d.png" 516 (png (expand-file-name "page-%d.png"
517 (doc-view-current-cache-dir)))) 517 (doc-view-current-cache-dir))))
518 (doc-view-pdf/ps->png pdf png)))) 518 (doc-view-pdf/ps->png pdf png)))))
519 519
520(defun doc-view-dvi->pdf (dvi pdf) 520(defun doc-view-dvi->pdf (dvi pdf)
521 "Convert DVI to PDF asynchronously." 521 "Convert DVI to PDF asynchronously."
@@ -533,14 +533,14 @@ Should be invoked when the cached images aren't up-to-date."
533 "If PDF/PS->PNG conversion was successful, update the display." 533 "If PDF/PS->PNG conversion was successful, update the display."
534 (if (not (string-match "finished" event)) 534 (if (not (string-match "finished" event))
535 (message "DocView: converter process changed status to %s." event) 535 (message "DocView: converter process changed status to %s." event)
536 (set-buffer (process-get proc 'buffer)) 536 (with-current-buffer (process-get proc 'buffer)
537 (setq doc-view-current-converter-process nil 537 (setq doc-view-current-converter-process nil
538 mode-line-process nil) 538 mode-line-process nil)
539 (when doc-view-current-timer 539 (when doc-view-current-timer
540 (cancel-timer doc-view-current-timer) 540 (cancel-timer doc-view-current-timer)
541 (setq doc-view-current-timer nil)) 541 (setq doc-view-current-timer nil))
542 ;; Yippie, finished. Update the display! 542 ;; Yippie, finished. Update the display!
543 (doc-view-display buffer-file-name))) 543 (doc-view-display buffer-file-name 'force))))
544 544
545(defun doc-view-pdf/ps->png (pdf-ps png) 545(defun doc-view-pdf/ps->png (pdf-ps png)
546 "Convert PDF-PS to PNG asynchronously." 546 "Convert PDF-PS to PNG asynchronously."
@@ -568,13 +568,13 @@ Should be invoked when the cached images aren't up-to-date."
568 (message "DocView: converter process changed status to %s." event) 568 (message "DocView: converter process changed status to %s." event)
569 (let ((current-buffer (current-buffer)) 569 (let ((current-buffer (current-buffer))
570 (proc-buffer (process-get proc 'buffer))) 570 (proc-buffer (process-get proc 'buffer)))
571 (set-buffer proc-buffer) 571 (with-current-buffer proc-buffer
572 (setq doc-view-current-converter-process nil 572 (setq doc-view-current-converter-process nil
573 mode-line-process nil) 573 mode-line-process nil)
574 ;; If the user looks at the DocView buffer where the conversion was 574 ;; If the user looks at the DocView buffer where the conversion was
575 ;; performed, search anew. This time it will be queried for a regexp. 575 ;; performed, search anew. This time it will be queried for a regexp.
576 (when (eq current-buffer proc-buffer) 576 (when (eq current-buffer proc-buffer)
577 (doc-view-search nil))))) 577 (doc-view-search nil))))))
578 578
579(defun doc-view-pdf->txt (pdf txt) 579(defun doc-view-pdf->txt (pdf txt)
580 "Convert PDF to TXT asynchronously." 580 "Convert PDF to TXT asynchronously."
@@ -590,13 +590,13 @@ Should be invoked when the cached images aren't up-to-date."
590(defun doc-view-ps->pdf-sentinel (proc event) 590(defun doc-view-ps->pdf-sentinel (proc event)
591 (if (not (string-match "finished" event)) 591 (if (not (string-match "finished" event))
592 (message "DocView: converter process changed status to %s." event) 592 (message "DocView: converter process changed status to %s." event)
593 (set-buffer (process-get proc 'buffer)) 593 (with-current-buffer (process-get proc 'buffer)
594 (setq doc-view-current-converter-process nil 594 (setq doc-view-current-converter-process nil
595 mode-line-process nil) 595 mode-line-process nil)
596 ;; Now we can transform to plain text. 596 ;; Now we can transform to plain text.
597 (doc-view-pdf->txt (process-get proc 'pdf-file) 597 (doc-view-pdf->txt (process-get proc 'pdf-file)
598 (expand-file-name "doc.txt" 598 (expand-file-name "doc.txt"
599 (doc-view-current-cache-dir))))) 599 (doc-view-current-cache-dir))))))
600 600
601(defun doc-view-ps->pdf (ps pdf) 601(defun doc-view-ps->pdf (ps pdf)
602 "Convert PS to PDF asynchronously." 602 "Convert PS to PDF asynchronously."
@@ -707,15 +707,19 @@ Predicate for sorting `doc-view-current-files'."
707 (and (= (length a) (length b)) 707 (and (= (length a) (length b))
708 (string< a b)))) 708 (string< a b))))
709 709
710(defun doc-view-display (doc) 710(defun doc-view-display (doc &optional force)
711 "Start viewing the document DOC." 711 "Start viewing the document DOC.
712 (set-buffer (get-file-buffer doc)) 712If FORCE is non-nil, start viewing even if the document does not
713 (setq doc-view-current-files 713have the page we want to view."
714 (sort (directory-files (doc-view-current-cache-dir) t 714 (with-current-buffer (get-file-buffer doc)
715 "page-[0-9]+\\.png" t) 715 (setq doc-view-current-files
716 'doc-view-sort)) 716 (sort (directory-files (doc-view-current-cache-dir) t
717 (when (> (length doc-view-current-files) 0) 717 "page-[0-9]+\\.png" t)
718 (doc-view-goto-page doc-view-current-page))) 718 'doc-view-sort))
719 (when (or force
720 (>= (length doc-view-current-files)
721 (or doc-view-current-page 1)))
722 (doc-view-goto-page doc-view-current-page))))
719 723
720(defun doc-view-buffer-message () 724(defun doc-view-buffer-message ()
721 ;; Only show this message initially, not when refreshing the buffer (in which 725 ;; Only show this message initially, not when refreshing the buffer (in which
@@ -898,7 +902,7 @@ If BACKWARD is non-nil, jump to the previous match."
898 (if (file-exists-p (doc-view-current-cache-dir)) 902 (if (file-exists-p (doc-view-current-cache-dir))
899 (progn 903 (progn
900 (message "DocView: using cached files!") 904 (message "DocView: using cached files!")
901 (doc-view-display buffer-file-name)) 905 (doc-view-display buffer-file-name 'force))
902 (doc-view-convert-current-doc)) 906 (doc-view-convert-current-doc))
903 (message 907 (message
904 "%s" 908 "%s"