X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/0157c761391e63e3cd79a6757bbb1e5a494fae8c..986bd52a31d3ef5a9cc35ecfb8463d758d1e5e6c:/lisp/doc-view.el diff --git a/lisp/doc-view.el b/lisp/doc-view.el index 06c3b70a3a..53e7811bad 100644 --- a/lisp/doc-view.el +++ b/lisp/doc-view.el @@ -1,7 +1,7 @@ ;;; doc-view.el --- View PDF/PostScript/DVI files in Emacs -*- lexical-binding: t -*- -;; Copyright (C) 2007-2011 Free Software Foundation, Inc. +;; Copyright (C) 2007-2012 Free Software Foundation, Inc. ;; ;; Author: Tassilo Horn ;; Maintainer: Tassilo Horn @@ -124,7 +124,7 @@ ;; (except the tooltip) if the next match is on the same page. ;; And it's much slower than the current search facility, because -;; isearch really searches for each step forward or backward wheras +;; isearch really searches for each step forward or backward whereas ;; the current approach searches once and then it knows to which ;; pages to jump. @@ -149,7 +149,7 @@ :group 'multimedia :prefix "doc-view-") -(defcustom doc-view-ghostscript-program (executable-find "gs") +(defcustom doc-view-ghostscript-program "gs" "Program to convert PS and PDF files to PNG." :type 'file :group 'doc-view) @@ -172,10 +172,11 @@ Higher values result in larger images." (defcustom doc-view-image-width 850 "Default image width. Has only an effect if imagemagick support is compiled into emacs." + :version "24.1" :type 'number :group 'doc-view) -(defcustom doc-view-dvipdfm-program (executable-find "dvipdfm") +(defcustom doc-view-dvipdfm-program "dvipdfm" "Program to convert DVI files to PDF. DVI file will be converted to PDF before the resulting PDF is @@ -186,7 +187,7 @@ If this and `doc-view-dvipdf-program' are set, :type 'file :group 'doc-view) -(defcustom doc-view-dvipdf-program (executable-find "dvipdf") +(defcustom doc-view-dvipdf-program "dvipdf" "Program to convert DVI files to PDF. DVI file will be converted to PDF before the resulting PDF is @@ -197,21 +198,22 @@ If this and `doc-view-dvipdfm-program' are set, :type 'file :group 'doc-view) -(defcustom doc-view-unoconv-program (executable-find "unoconv") +(defcustom doc-view-unoconv-program "unoconv" "Program to convert any file type readable by OpenOffice.org to PDF. Needed for viewing OpenOffice.org (and MS Office) files." + :version "24.1" :type 'file :group 'doc-view) -(defcustom doc-view-ps2pdf-program (executable-find "ps2pdf") +(defcustom doc-view-ps2pdf-program "ps2pdf" "Program to convert PS files to PDF. PS files will be converted to PDF before searching is possible." :type 'file :group 'doc-view) -(defcustom doc-view-pdftotext-program (executable-find "pdftotext") +(defcustom doc-view-pdftotext-program "pdftotext" "Program to convert PDF files to plain text. Needed for searching." @@ -569,18 +571,18 @@ at the top edge of the page moves to the previous page." (defun doc-view-make-safe-dir (dir) (condition-case nil (let ((umask (default-file-modes))) - (unwind-protect - (progn - ;; Create temp files with strict access rights. It's easy to - ;; loosen them later, whereas it's impossible to close the - ;; time-window of loose permissions otherwise. - (set-default-file-modes #o0700) - (make-directory dir)) - ;; Reset the umask. - (set-default-file-modes umask))) + (unwind-protect + (progn + ;; Create temp files with strict access rights. It's easy to + ;; loosen them later, whereas it's impossible to close the + ;; time-window of loose permissions otherwise. + (set-default-file-modes #o0700) + (make-directory dir)) + ;; Reset the umask. + (set-default-file-modes umask))) (file-already-exists - (if (file-symlink-p dir) - (error "Danger: %s points to a symbolic link" dir)) + (when (file-symlink-p dir) + (error "Danger: %s points to a symbolic link" dir)) ;; In case it was created earlier with looser rights. ;; We could check the mode info returned by file-attributes, but it's ;; a pain to parse and it may not tell you what we want under @@ -589,7 +591,12 @@ at the top edge of the page moves to the previous page." ;; This also ends up checking a bunch of useful conditions: it makes ;; sure we have write-access to the directory and that we own it, thus ;; closing a bunch of security holes. - (set-file-modes dir #o0700)))) + (condition-case error + (set-file-modes dir #o0700) + (file-error + (error + (format "Unable to use temporary directory %s: %s" + dir (mapconcat 'identity (cdr error) " ")))))))) (defun doc-view-current-cache-dir () "Return the directory where the png files of the current doc should be saved. @@ -876,7 +883,7 @@ Start by converting PAGES, and then the rest." (defun doc-view-pdf->txt (pdf txt callback) "Convert PDF to TXT asynchronously and call CALLBACK when finished." - (or doc-view-pdftotext-program + (or (executable-find doc-view-pdftotext-program) (error "You need the `pdftotext' program to convert a PDF to text")) (doc-view-start-process "pdf->txt" doc-view-pdftotext-program (list "-raw" pdf txt) @@ -912,7 +919,7 @@ Start by converting PAGES, and then the rest." (defun doc-view-ps->pdf (ps pdf callback) "Convert PS to PDF asynchronously and call CALLBACK when finished." - (or doc-view-ps2pdf-program + (or (executable-find doc-view-ps2pdf-program) (error "You need the `ps2pdf' program to convert PS to PDF")) (doc-view-start-process "ps->pdf" doc-view-ps2pdf-program (list @@ -1497,8 +1504,11 @@ to the next best 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. + "Toggle displaying buffer via Doc View (Doc View minor mode). +With a prefix argument ARG, enable Doc View minor mode if ARG is +positive, and disable it otherwise. If called from Lisp, enable +the mode if ARG is omitted or nil. + See the command `doc-view-mode' for more information on this mode." nil " DocView" doc-view-minor-mode-map :group 'doc-view @@ -1550,7 +1560,7 @@ See the command `doc-view-mode' for more information on this mode." (provide 'doc-view) ;; Local Variables: -;; eval: (outline-minor-mode) +;; eval: (outline-minor-mode 1) ;; End: ;;; doc-view.el ends here