* doc-view.el: about cursor and filename display @ 2007-10-15 8:27 William Xu 2007-10-15 9:20 ` Tassilo Horn 0 siblings, 1 reply; 34+ messages in thread From: William Xu @ 2007-10-15 8:27 UTC (permalink / raw) To: emacs-devel Just began to use doc-view.el, some suggestions: 1. Hide the cursor Cursor in a image buffer looks peculiar, maybe better hide it just like image-mode? namely, (setq cursor-type nil) 2. Filename on mode line Why not simply display the filename on mode line as usual, like `foo.pdf'? At present, the filename on the mode line is very long, occupies lots of space of mode line, and is inconvenient to switch to by ido, for instance. 3. Add auto-revert-mode support? -- William http://williamxu.net9.org 天下皆知美之为美,斯恶已。 皆知善之为善,斯不善已。 有无相生,难易相成,长短相形 ,高下相盈,音声相和, 前后相随。恒也。 是以圣人处无为之事, 行不言之教;万物作而弗始,生 而弗有,为而弗恃,功成而不居。夫唯弗居,是以不去。 ---- 老子第二章 ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-15 8:27 doc-view.el: about cursor and filename display William Xu @ 2007-10-15 9:20 ` Tassilo Horn 2007-10-15 11:15 ` William Xu 2007-10-15 14:00 ` Stefan Monnier 0 siblings, 2 replies; 34+ messages in thread From: Tassilo Horn @ 2007-10-15 9:20 UTC (permalink / raw) To: emacs-devel William Xu <william.xwl@gmail.com> writes: Hi William, > Just began to use doc-view.el, some suggestions: > > 1. Hide the cursor > > Cursor in a image buffer looks peculiar, maybe better hide it just > like image-mode? namely, (setq cursor-type nil) But you need the cursor for slicing. Ok, I could enable it only for this command. But what happens with the tooltips if there's no cursor? > 2. Filename on mode line > > Why not simply display the filename on mode line as usual, like > `foo.pdf'? At present, the filename on the mode line is very long, > occupies lots of space of mode line, and is inconvenient to switch > to by ido, for instance. My last patch, that makes doc-view the default viewer for pdf/ps/dvi files uses only the filename. You can get the patch from my mail <87r6k2l9sr.fsf_-_@baldur.tsdh.de>. There you don't use `doc-view' anymore, but simply find the file using C-x C-f. > 3. Add auto-revert-mode support? I don't know if that's a good idea. a-r-m checks files periodically and reverts if something changed. Since "reverting" means reconverting for doc-view, it's possible that it blows your computer because it may happen that a new conversion is started before the last one finished (e.g. every 5 seconds a new conversion is started). My last patch added a new binding `g' which reconverts the current document. Bye, Tassilo ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-15 9:20 ` Tassilo Horn @ 2007-10-15 11:15 ` William Xu 2007-10-15 15:13 ` Tassilo Horn 2007-10-15 14:00 ` Stefan Monnier 1 sibling, 1 reply; 34+ messages in thread From: William Xu @ 2007-10-15 11:15 UTC (permalink / raw) To: emacs-devel Tassilo Horn <tassilo@member.fsf.org> writes: > But what happens with the tooltips if there's no cursor? What kind of tooltips would it show? Hmm, it won't work here. (maybe since carbon emacs is broken..) ,---- | Error while displaying tooltip: (wrong-type-argument frame-live-p #<dead frame tooltip 0x62bb190>) | Page 1 of 4. `---- > My last patch, that makes doc-view the default viewer for pdf/ps/dvi > files uses only the filename. You can get the patch from my mail > <87r6k2l9sr.fsf_-_@baldur.tsdh.de>. There you don't use `doc-view' > anymore, but simply find the file using C-x C-f. Nice. I wonder why this is not commited into the trunk.. >> 3. Add auto-revert-mode support? > > I don't know if that's a good idea. a-r-m checks files periodically and > reverts if something changed. When i'm generating .pdf from .tex, i thought it would be useful if the generated .pdf file buffer could be refreshed automatically. -- William http://williamxu.net9.org ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-15 11:15 ` William Xu @ 2007-10-15 15:13 ` Tassilo Horn 2007-10-16 4:10 ` Richard Stallman 0 siblings, 1 reply; 34+ messages in thread From: Tassilo Horn @ 2007-10-15 15:13 UTC (permalink / raw) To: emacs-devel William Xu <william.xwl@gmail.com> writes: Hi William, >> But what happens with the tooltips if there's no cursor? > > What kind of tooltips would it show? > > Hmm, it won't work here. (maybe since carbon emacs is broken..) > > ,---- > | Error while displaying tooltip: (wrong-type-argument frame-live-p #<dead frame tooltip 0x62bb190>) > | Page 1 of 4. > `---- The second line is what the tooltip should show and it works here. So it seems to be a problem with the carbon port. >> My last patch, that makes doc-view the default viewer for pdf/ps/dvi >> files uses only the filename. You can get the patch from my mail >> <87r6k2l9sr.fsf_-_@baldur.tsdh.de>. There you don't use `doc-view' >> anymore, but simply find the file using C-x C-f. > > Nice. I wonder why this is not commited into the trunk.. It'll be committed when RMS says so. ;-) But it'll help if people (YOU!) apply the patch and give feedback if it works. >>> 3. Add auto-revert-mode support? >> >> I don't know if that's a good idea. a-r-m checks files periodically >> and reverts if something changed. > > When i'm generating .pdf from .tex, i thought it would be useful if > the generated .pdf file buffer could be refreshed automatically. Indeed, this could be useful, but I'll wait till the path makes it into CVS before addressing new feature requests in order to keep the patch small and easy to review. Bye, Tassilo ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-15 15:13 ` Tassilo Horn @ 2007-10-16 4:10 ` Richard Stallman 0 siblings, 0 replies; 34+ messages in thread From: Richard Stallman @ 2007-10-16 4:10 UTC (permalink / raw) To: Tassilo Horn; +Cc: emacs-devel >> My last patch, that makes doc-view the default viewer for pdf/ps/dvi >> files uses only the filename. You can get the patch from my mail >> <87r6k2l9sr.fsf_-_@baldur.tsdh.de>. There you don't use `doc-view' >> anymore, but simply find the file using C-x C-f. > > Nice. I wonder why this is not commited into the trunk.. It'll be committed when RMS says so. ;-) I am all in favor of that change. ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-15 9:20 ` Tassilo Horn 2007-10-15 11:15 ` William Xu @ 2007-10-15 14:00 ` Stefan Monnier 2007-10-15 14:20 ` Tassilo Horn 2007-10-16 4:10 ` Richard Stallman 1 sibling, 2 replies; 34+ messages in thread From: Stefan Monnier @ 2007-10-15 14:00 UTC (permalink / raw) To: emacs-devel > I don't know if that's a good idea. a-r-m checks files periodically and > reverts if something changed. Since "reverting" means reconverting for > doc-view, it's possible that it blows your computer because it may > happen that a new conversion is started before the last one finished > (e.g. every 5 seconds a new conversion is started). That can happen if the user calls revert explicitly as well (yes, less likely and less severe, but still: the user might do M-x revert-buffer, then get annoyed that it doesn't see the result, so do it again and again and again). It shouldn't be too difficult to protect against it by detecting the situation and "reacting appropriately". Stefan ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-15 14:00 ` Stefan Monnier @ 2007-10-15 14:20 ` Tassilo Horn 2007-10-16 4:10 ` Richard Stallman 1 sibling, 0 replies; 34+ messages in thread From: Tassilo Horn @ 2007-10-15 14:20 UTC (permalink / raw) To: emacs-devel Stefan Monnier <monnier@iro.umontreal.ca> writes: Hi Stefan, >> I don't know if that's a good idea. a-r-m checks files periodically >> and reverts if something changed. Since "reverting" means >> reconverting for doc-view, it's possible that it blows your computer >> because it may happen that a new conversion is started before the >> last one finished (e.g. every 5 seconds a new conversion is started). > > That can happen if the user calls revert explicitly as well (yes, less > likely and less severe, but still: the user might do M-x > revert-buffer, then get annoyed that it doesn't see the result, so do > it again and again and again). > > It shouldn't be too difficult to protect against it by detecting the > situation and "reacting appropriately". Right. But I'd like to wait till my last patch is included before I'll address those (IMO minor) glitches. Bye, Tassilo ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-15 14:00 ` Stefan Monnier 2007-10-15 14:20 ` Tassilo Horn @ 2007-10-16 4:10 ` Richard Stallman 2007-10-16 6:34 ` Tassilo Horn 1 sibling, 1 reply; 34+ messages in thread From: Richard Stallman @ 2007-10-16 4:10 UTC (permalink / raw) To: Stefan Monnier; +Cc: emacs-devel That can happen if the user calls revert explicitly as well (yes, less likely and less severe, but still: the user might do M-x revert-buffer, then get annoyed that it doesn't see the result, so do it again and again and again). It shouldn't be too difficult to protect against it by detecting the situation and "reacting appropriately". I don't see how it is possible to detect such a situation. M-x revert-buffer could at most detect that input is pending; it cannot tell what that input will do when executed, so there is really nothing it can do. The best solution I know of is to display a message in the echo area saying that it is reformatting the file. That way the user could know to type C-g if he does not want to let it finish. It would be even better to print percentage progress messages, but it may be hard for Emacs to get the information. ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-16 4:10 ` Richard Stallman @ 2007-10-16 6:34 ` Tassilo Horn 2007-10-17 5:02 ` Richard Stallman 0 siblings, 1 reply; 34+ messages in thread From: Tassilo Horn @ 2007-10-16 6:34 UTC (permalink / raw) To: rms; +Cc: Stefan Monnier, emacs-devel Richard Stallman <rms@gnu.org> writes: > That can happen if the user calls revert explicitly as well (yes, > less likely and less severe, but still: the user might do M-x > revert-buffer, then get annoyed that it doesn't see the result, so > do it again and again and again). > > It shouldn't be too difficult to protect against it by detecting > the situation and "reacting appropriately". > > I don't see how it is possible to detect such a situation. M-x > revert-buffer could at most detect that input is pending; it cannot > tell what that input will do when executed, so there is really nothing > it can do. I'm not completely sure, but the docs lead me to the impression that I can set `revert-buffer-function' in doc-view buffers to the function that reconverts a file. In that function I could check for currently running processes and revert/reconvert only if no process is already running. If there's a conversion process underway, I could inform the user with a message. Bye, Tassilo ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-16 6:34 ` Tassilo Horn @ 2007-10-17 5:02 ` Richard Stallman 2007-10-17 8:39 ` Tassilo Horn 0 siblings, 1 reply; 34+ messages in thread From: Richard Stallman @ 2007-10-17 5:02 UTC (permalink / raw) To: Tassilo Horn; +Cc: monnier, emacs-devel I'm not completely sure, but the docs lead me to the impression that I can set `revert-buffer-function' in doc-view buffers to the function that reconverts a file. In that function I could check for currently running processes and revert/reconvert only if no process is already running. Is the conversion done asynchronously? If so, then yes you could easily check this way. I think the right action is to kill the existing process and start a new one, because that's what the user asked for. You could also indicate in the mode line that the process is running. ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-17 5:02 ` Richard Stallman @ 2007-10-17 8:39 ` Tassilo Horn 2007-10-17 13:57 ` Stefan Monnier 2007-10-17 20:49 ` Richard Stallman 0 siblings, 2 replies; 34+ messages in thread From: Tassilo Horn @ 2007-10-17 8:39 UTC (permalink / raw) To: rms; +Cc: monnier, emacs-devel Richard Stallman <rms@gnu.org> writes: > I'm not completely sure, but the docs lead me to the impression > that I can set `revert-buffer-function' in doc-view buffers to the > function that reconverts a file. In that function I could check > for currently running processes and revert/reconvert only if no > process is already running. > > Is the conversion done asynchronously? Yes. > If so, then yes you could easily check this way. I think the right > action is to kill the existing process and start a new one, because > that's what the user asked for. Yes, that wouldn't be a problem. > You could also indicate in the mode line that the process is running. doc-view indicates with a message and in the tooltip that conversion hasn't finished yet. Bye, Tassilo ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-17 8:39 ` Tassilo Horn @ 2007-10-17 13:57 ` Stefan Monnier 2007-10-17 16:19 ` Tassilo Horn 2007-10-17 19:54 ` Tassilo Horn 2007-10-17 20:49 ` Richard Stallman 1 sibling, 2 replies; 34+ messages in thread From: Stefan Monnier @ 2007-10-17 13:57 UTC (permalink / raw) To: rms; +Cc: emacs-devel >> You could also indicate in the mode line that the process is running. > doc-view indicates with a message and in the tooltip that conversion > hasn't finished yet. I'm not sure I understand what kind of message, when it's displayed, and where's the tooltip, but Richard is talking about using `mode-line-process', which is a standard feature and would make a lot of sense here. A quick grep for it will show you how it's commonly used. Stefan ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-17 13:57 ` Stefan Monnier @ 2007-10-17 16:19 ` Tassilo Horn 2007-10-18 5:02 ` Richard Stallman 2007-10-17 19:54 ` Tassilo Horn 1 sibling, 1 reply; 34+ messages in thread From: Tassilo Horn @ 2007-10-17 16:19 UTC (permalink / raw) To: emacs-devel Stefan Monnier <monnier@iro.umontreal.ca> writes: >>> You could also indicate in the mode line that the process is >>> running. >> >> doc-view indicates with a message and in the tooltip that conversion >> hasn't finished yet. > > I'm not sure I understand what kind of message, when it's displayed, > and where's the tooltip, While conversion there's a message Page 12 of 123. (still converting...) below the already displayed image to indicate, that the document has more than 123 pages, but only 123 pages have been converted so far. > but Richard is talking about using `mode-line-process', which is a > standard feature and would make a lot of sense here. A quick grep for > it will show you how it's commonly used. Ah, ok. I didn't know about it and I'll have a look at its usage and implement that feature. Bye, Tassilo ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-17 16:19 ` Tassilo Horn @ 2007-10-18 5:02 ` Richard Stallman 2007-10-18 6:50 ` Tassilo Horn 0 siblings, 1 reply; 34+ messages in thread From: Richard Stallman @ 2007-10-18 5:02 UTC (permalink / raw) To: Tassilo Horn; +Cc: emacs-devel While conversion there's a message Page 12 of 123. (still converting...) below the already displayed image to indicate, that the document has more than 123 pages, but only 123 pages have been converted so far. That might be sufficient to the user notification of the progress. However, using mode-line-process is a good idea anyway. ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-18 5:02 ` Richard Stallman @ 2007-10-18 6:50 ` Tassilo Horn 0 siblings, 0 replies; 34+ messages in thread From: Tassilo Horn @ 2007-10-18 6:50 UTC (permalink / raw) To: rms; +Cc: emacs-devel Richard Stallman <rms@gnu.org> writes: > While conversion there's a message > > Page 12 of 123. (still converting...) > > below the already displayed image to indicate, that the document has > more than 123 pages, but only 123 pages have been converted so far. > > That might be sufficient to the user notification of the progress. > However, using mode-line-process is a good idea anyway. Done! ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-17 13:57 ` Stefan Monnier 2007-10-17 16:19 ` Tassilo Horn @ 2007-10-17 19:54 ` Tassilo Horn 2007-10-17 23:29 ` Dan Nicolaescu 1 sibling, 1 reply; 34+ messages in thread From: Tassilo Horn @ 2007-10-17 19:54 UTC (permalink / raw) To: Stefan Monnier; +Cc: rms, emacs-devel [-- Attachment #1: Type: text/plain, Size: 800 bytes --] Stefan Monnier <monnier@iro.umontreal.ca> writes: > I'm not sure I understand what kind of message, when it's displayed, > and where's the tooltip, but Richard is talking about using > `mode-line-process', which is a standard feature and would make a lot > of sense here. A quick grep for it will show you how it's commonly > used. Ok, here's a new version of my patch. It includes - mode-line-process support: The currently active process is shown in the mode line, e.g. dvi->pdf, pdf->txt, pdf/ps->png... - revert-buffer support: The current doc will be reconverted - When revert-buffer or the reconvert command is called multiple times, the old processes will be killed first, so that there's at most one process per document/buffer. - Some code cleanups Bye, Tassilo [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: doc-view.patch --] [-- Type: text/x-patch, Size: 25006 bytes --] Index: lisp/files.el =================================================================== RCS file: /sources/emacs/emacs/lisp/files.el,v retrieving revision 1.932 diff -u -r1.932 files.el --- lisp/files.el 15 Oct 2007 02:07:46 -0000 1.932 +++ lisp/files.el 17 Oct 2007 19:51:46 -0000 @@ -2059,7 +2059,7 @@ ("\\.\\(as\\|mi\\|sm\\)2\\'" . snmpv2-mode) ("\\.\\(diffs?\\|patch\\|rej\\)\\'" . diff-mode) ("\\.\\(dif\\|pat\\)\\'" . diff-mode) ; for MSDOG - ("\\.[eE]?[pP][sS]\\'" . ps-mode) + ("\\(?:DVI\\|EPS\\|P\\(?:DF\\|S\\)\\|dvi\\|eps\\|p\\(?:df\\|s\\)\\)" . doc-view-mode) ("configure\\.\\(ac\\|in\\)\\'" . autoconf-mode) ("BROWSE\\'" . ebrowse-tree-mode) ("\\.ebrowse\\'" . ebrowse-tree-mode) 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 17 Oct 2007 19:51:48 -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-10-02 Tue 18:21> +;; Version: <2007-10-17 Wed 21:22> ;; This file is part of GNU Emacs. @@ -37,16 +37,19 @@ ;; inside an Emacs buffer. This buffer uses `doc-view-mode' which provides ;; convenient key bindings for browsing the document. ;; -;; To use it simply do +;; To use it simply open a document file with ;; -;; M-x doc-view RET +;; C-x C-f ~/path/to/document RET ;; -;; and you'll be queried for a document to open. +;; and the document will be converted and displayed, if your emacs supports png +;; images. With `C-c C-c' you can toggle between the rendered images +;; representation and the source text representation of the document. With +;; `C-c C-e' you can switch to an appropriate editing mode for the document. ;; ;; Since conversion may take some time all the PNG images are cached in a ;; subdirectory of `doc-view-cache-directory' and reused when you want to view -;; that file again. This reusing can be omitted if you provide a prefx -;; argument to `doc-view'. To delete all cached files use +;; that file again. To reconvert a document hit `g' (`doc-view-reconvert-doc') +;; when displaying the document. To delete all cached files use ;; `doc-view-clear-cache'. To open the cache with dired, so that you can tidy ;; it out use `doc-view-dired-cache'. ;; @@ -67,8 +70,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,17 +81,16 @@ ;; 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'. +;; ;;; Configuration: -;; Basically doc-view should be quite usable with its standard settings, so -;; putting -;; -;; (require 'doc-view) -;; -;; into your `user-init-file' should be enough. If the images are too small or -;; too big you should set the "-rXXX" option in `doc-view-ghostscript-options' -;; to another value. (The bigger your screen, the higher the value.) +;; If the images are too small or too big you should set the "-rXXX" option in +;; `doc-view-ghostscript-options' to another value. (The bigger your screen, +;; the higher the value.) ;; ;; This and all other options can be set with the customization interface. ;; Simply do @@ -201,7 +201,10 @@ (defvar doc-view-current-info nil "Only used internally.") -;;;; DocView Keymap +(defvar doc-view-current-display nil + "Only used internally.") + +;;;; DocView Keymaps (defvar doc-view-mode-map (let ((map (make-sparse-keymap))) @@ -235,9 +238,26 @@ (define-key map (kbd "M-v") 'scroll-down) ;; Show the tooltip (define-key map (kbd "C-t") 'doc-view-show-tooltip) + ;; Toggle between text and image display or editing + (define-key map (kbd "C-c C-c") 'doc-view-toggle-display) + (define-key map (kbd "C-c C-e") 'doc-view-edit-doc) + ;; Reconvert the current document + (define-key map (kbd "g") 'doc-view-reconvert-doc) (suppress-keymap map) map) - "Keymap used by `doc-view-mode'.") + "Keymap used by `doc-view-mode' when displaying a doc as a set of images.") + +(defvar doc-view-mode-text-map + (let ((map (make-sparse-keymap))) + ;; Toggle between text and image display or editing + (define-key map (kbd "C-c C-c") 'doc-view-toggle-display) + (define-key map (kbd "C-c C-e") 'doc-view-edit-doc) + ;; Killing/burying the buffer (and the process) + (define-key map (kbd "q") 'bury-buffer) + (define-key map (kbd "k") 'doc-view-kill-proc-and-buffer) + (define-key map (kbd "C-x k") 'doc-view-kill-proc-and-buffer) + map) + "Keymap used by `doc-view-mode' when displaying a document as text.") ;;;; Navigation Commands @@ -271,16 +291,16 @@ (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) - (put-text-property beg (point) 'help-echo doc-view-current-info)) - (insert "\n" doc-view-current-info) - (goto-char (point-min)) - (forward-char) - (setq inhibit-read-only nil))) + (let ((inhibit-read-only t)) + (erase-buffer) + (let ((beg (point))) + (doc-view-insert-image (nth (1- page) doc-view-current-files) + :pointer 'arrow) + (put-text-property beg (point) 'help-echo doc-view-current-info)) + (insert "\n" doc-view-current-info) + (goto-char (point-min)) + (forward-char)) + (set-buffer-modified-p nil))) (defun doc-view-next-page (&optional arg) "Browse ARG pages forward." @@ -317,42 +337,62 @@ (error (doc-view-previous-page) (goto-char (point-max))))) +(defun doc-view-kill-proc () + "Kill the current converter process." + (interactive) + (when doc-view-current-converter-process + (kill-process doc-view-current-converter-process)) + (when doc-view-current-timer + (cancel-timer doc-view-current-timer) + (setq doc-view-current-timer nil)) + (setq mode-line-process nil)) + (defun doc-view-kill-proc-and-buffer () "Kill the current converter process and buffer." (interactive) + (doc-view-kill-proc) (when (eq major-mode 'doc-view-mode) - (when doc-view-current-converter-process - (kill-process doc-view-current-converter-process)) - (when doc-view-current-timer - (cancel-timer doc-view-current-timer) - (setq doc-view-current-timer nil)) (kill-buffer (current-buffer)))) ;;;; Conversion Functions -(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'." +(defun doc-view-reconvert-doc (&rest args) + "Reconvert the current document. +Should be invoked when the cached images aren't up-to-date." + (interactive) + (let ((inhibit-read-only t) + (doc doc-view-current-doc)) + (doc-view-kill-proc) + ;; Clear the old cached files + (when (file-exists-p (doc-view-current-cache-dir)) + (dired-delete-file (doc-view-current-cache-dir) 'always)) + (doc-view-kill-proc-and-buffer) + (find-file doc))) + +(defun doc-view-current-cache-dir () + "Return the directory where the png files of the current doc should be saved. +It's a subdirectory of `doc-view-cache-directory'." (if doc-view-current-cache-dir 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))))))) + (setq doc-view-current-cache-dir + (file-name-as-directory + (concat (file-name-as-directory doc-view-cache-directory) + (let ((doc doc-view-current-doc)) + (with-temp-buffer + (insert-file-contents-literally doc) + (md5 (current-buffer))))))))) (defun doc-view-dvi->pdf-sentinel (proc event) "If DVI->PDF conversion was successful, convert the PDF to PNG now." (if (not (string-match "finished" event)) (message "DocView: dvi->pdf process changed status to %s." event) (set-buffer (process-get proc 'buffer)) - (setq doc-view-current-converter-process nil) + (setq doc-view-current-converter-process nil + mode-line-process nil) (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) + (png (concat (doc-view-current-cache-dir) "page-%d.png"))) (doc-view-pdf/ps->png pdf png)))) @@ -360,9 +400,10 @@ "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 + (start-process "dvi->pdf" doc-view-conversion-buffer doc-view-dvipdfm-program - "-o" pdf dvi)) + "-o" pdf dvi) + mode-line-process (list (format ":%s" doc-view-current-converter-process))) (set-process-sentinel doc-view-current-converter-process 'doc-view-dvi->pdf-sentinel) (process-put doc-view-current-converter-process 'buffer (current-buffer)) @@ -373,7 +414,8 @@ (if (not (string-match "finished" event)) (message "DocView: converter process changed status to %s." event) (set-buffer (process-get proc 'buffer)) - (setq doc-view-current-converter-process nil) + (setq doc-view-current-converter-process nil + mode-line-process nil) (when doc-view-current-timer (cancel-timer doc-view-current-timer) (setq doc-view-current-timer nil)) @@ -386,11 +428,12 @@ (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 + (append (list "pdf/ps->png" doc-view-conversion-buffer doc-view-ghostscript-program) doc-view-ghostscript-options (list (concat "-sOutputFile=" png)) - (list pdf-ps)))) + (list pdf-ps))) + mode-line-process (list (format ":%s" doc-view-current-converter-process))) (process-put doc-view-current-converter-process 'buffer (current-buffer)) (set-process-sentinel doc-view-current-converter-process @@ -398,7 +441,7 @@ (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-display-maybe doc-view-current-doc)))) (defun doc-view-pdf->txt-sentinel (proc event) @@ -407,7 +450,8 @@ (let ((current-buffer (current-buffer)) (proc-buffer (process-get proc 'buffer))) (set-buffer proc-buffer) - (setq doc-view-current-converter-process nil) + (setq doc-view-current-converter-process nil + mode-line-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. @@ -418,9 +462,10 @@ "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 + (start-process "pdf->txt" doc-view-conversion-buffer doc-view-pdftotext-program "-raw" - pdf txt)) + pdf txt) + mode-line-process (list (format ":%s" doc-view-current-converter-process))) (set-process-sentinel doc-view-current-converter-process 'doc-view-pdf->txt-sentinel) (process-put doc-view-current-converter-process 'buffer (current-buffer))) @@ -429,65 +474,44 @@ (if (not (string-match "finished" event)) (message "DocView: converter process changed status to %s." event) (set-buffer (process-get proc 'buffer)) - (setq doc-view-current-converter-process nil) + (setq doc-view-current-converter-process nil + mode-line-process nil) (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) + (concat (doc-view-current-cache-dir) "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 + (start-process "ps->pdf" doc-view-conversion-buffer doc-view-ps2pdf-program - ps pdf)) + ps pdf) + mode-line-process (list (format ":%s" doc-view-current-converter-process))) (set-process-sentinel doc-view-current-converter-process '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)) -(defun doc-view-convert-doc (doc) - "Convert DOC to a set of png files, one file per page. - -Those files are saved in the directory given by -`doc-view-file-name-to-directory-name'." +(defun doc-view-convert-current-doc () + "Convert `doc-view-current-doc' to a set of png files, one file per page. +Those files are saved in the directory given by the function +`doc-view-current-cache-dir'." (clear-image-cache) - (let* ((dir (doc-view-file-name-to-directory-name doc)) - (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")) + (let ((png-file (concat (doc-view-current-cache-dir) + "page-%d.png"))) + (make-directory doc-view-current-cache-dir t) + (if (not (string= (file-name-extension doc-view-current-doc) "dvi")) ;; Convert to PNG images. - (doc-view-pdf/ps->png doc png-file) + (doc-view-pdf/ps->png doc-view-current-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-view-dvi->pdf doc-view-current-doc + (concat (file-name-as-directory doc-view-current-cache-dir) "doc.pdf"))))) -;;;; DocView Mode - -(define-derived-mode doc-view-mode nil "DocView" - "Major mode in DocView buffers. - -\\{doc-view-mode-map}" - :group 'doc-view - (setq buffer-read-only t) - (make-local-variable 'doc-view-current-files) - (make-local-variable 'doc-view-current-doc) - (make-local-variable 'doc-view-current-image) - (make-local-variable 'doc-view-current-page) - (make-local-variable 'doc-view-current-converter-process) - (make-local-variable 'doc-view-current-timer) - (make-local-variable 'doc-view-current-slice) - (make-local-variable 'doc-view-current-cache-dir) - (make-local-variable 'doc-view-current-info) - (make-local-variable 'doc-view-current-search-matches)) - ;;;; Slicing (defun doc-view-set-slice (x y width height) @@ -555,19 +579,22 @@ nil (string< a b)))) +(defun doc-view-display-maybe (doc) + "Call `doc-view-display' iff we're in the image display." + (when (eq doc-view-current-display 'image) + (doc-view-display doc))) + (defun doc-view-display (doc) "Start viewing the document DOC." - (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)) - (when (> (length doc-view-current-files) 0) - (doc-view-goto-page doc-view-current-page)))) + (set-buffer (get-file-buffer doc)) + (setq doc-view-current-files + (sort (directory-files (doc-view-current-cache-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))) (defun doc-view-buffer-message () - (setq inhibit-read-only t) - (erase-buffer) (insert (propertize "Welcome to DocView!" 'face 'bold) "\n" " @@ -580,12 +607,58 @@ `q' : Bury this buffer. Conversion will go on in background. `k' : Kill the conversion process and this buffer.\n") - (setq inhibit-read-only nil)) + (set-buffer-modified-p nil)) (defun doc-view-show-tooltip () (interactive) (tooltip-show doc-view-current-info)) +;;;;; Toggle between text and image display + +(defun doc-view-toggle-display () + "Start or stop displaying a document file as a set of images. +This command toggles between showing the text of the document +file and showing the document as a set of images." + (interactive) + (if (get-text-property (point-min) 'display) + ;; Switch to text display + (let ((inhibit-read-only t)) + (erase-buffer) + (insert-file-contents doc-view-current-doc) + (use-local-map doc-view-mode-text-map) + (setq mode-name "DocView[text]" + doc-view-current-display 'text) + (if (called-interactively-p) + (message "Repeat this command to go back to displaying the file as images"))) + ;; Switch to image display + (let ((inhibit-read-only t)) + (erase-buffer) + (doc-view-buffer-message) + (setq doc-view-current-page (or doc-view-current-page 1)) + (if (file-exists-p (doc-view-current-cache-dir)) + (progn + (message "DocView: using cached files!") + (doc-view-display doc-view-current-doc)) + (doc-view-convert-current-doc)) + (use-local-map doc-view-mode-map) + (setq mode-name (format "DocView") + doc-view-current-display 'image) + (if (called-interactively-p) + (message "Repeat this command to go back to displaying the file as text")))) + (set-buffer-modified-p nil)) + +;;;;; Leave doc-view-mode and open the file for edit + +(defun doc-view-edit-doc () + "Leave `doc-view-mode' and open the current doc with an appropriate editing mode." + (interactive) + (let ((filename doc-view-current-doc) + (auto-mode-alist (append '(("\\.[eE]?[pP][sS]\\'" . ps-mode) + ("\\.\\(pdf\\|PDF\\|dvi\\|DVI\\)$" . fundamental-mode)) + auto-mode-alist))) + (kill-buffer (current-buffer)) + (find-file filename))) + ;;;; Searching (defun doc-view-search-internal (regexp file) @@ -636,8 +709,7 @@ (interactive) ;; 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) + (let ((txt (concat (doc-view-current-cache-dir) "doc.txt"))) (if (file-readable-p txt) (progn @@ -660,14 +732,12 @@ ;; 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) + (concat (doc-view-current-cache-dir) "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-view-pdf->txt (concat (doc-view-current-cache-dir) "doc.pdf") txt)) (t (error "DocView doesn't know what to do")))))))) @@ -698,52 +768,42 @@ (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 +;;;; User interface commands and the mode + +(put 'doc-view-mode 'mode-class 'special) ;;;###autoload -(defun doc-view (no-cache &optional file) - "Convert FILE to png and start viewing it. -If no FILE is given, query for on. -If this FILE is still in the cache, don't convert and use the -existing page files. With prefix arg NO-CACHE, don't use the -cached files and convert anew." - (interactive "P") - (if (not (and (image-type-available-p 'png) - (display-images-p))) - (message "DocView: your emacs or display doesn't support png images.") - (let* ((doc (or file - (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))))) - -(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))) +(define-derived-mode doc-view-mode nil "DocView" + "Major mode in DocView buffers. +You can use \\<doc-view-mode-map>\\[doc-view-toggle-display] to +toggle between display as a set of images and display as text." + :group 'doc-view + (make-local-variable 'doc-view-current-files) + (make-local-variable 'doc-view-current-doc) + (make-local-variable 'doc-view-current-image) + (make-local-variable 'doc-view-current-page) + (make-local-variable 'doc-view-current-converter-process) + (make-local-variable 'doc-view-current-timer) + (make-local-variable 'doc-view-current-slice) + (make-local-variable 'doc-view-current-cache-dir) + (make-local-variable 'doc-view-current-info) + (make-local-variable 'doc-view-current-search-matches) + (setq doc-view-current-doc (buffer-file-name)) + (insert-file-contents doc-view-current-doc) + (use-local-map doc-view-mode-text-map) + (setq mode-name "DocView[text]" + doc-view-current-display 'text + buffer-read-only t + revert-buffer-function 'doc-view-reconvert-doc) + ;; Switch to image display if possible + (if (and (display-images-p) + (image-type-available-p 'png) + (not (get-text-property (point-min) 'display))) + (doc-view-toggle-display)) + (message + "%s" + (substitute-command-keys + "Type \\[doc-view-toggle-display] to toggle between image and text display."))) (defun doc-view-clear-cache () "Delete the whole cache (`doc-view-cache-directory')." Index: lisp/bindings.el =================================================================== RCS file: /sources/emacs/emacs/lisp/bindings.el,v retrieving revision 1.185 diff -u -r1.185 bindings.el --- lisp/bindings.el 6 Oct 2007 22:15:43 -0000 1.185 +++ lisp/bindings.el 17 Oct 2007 19:51:49 -0000 @@ -536,7 +536,7 @@ '(".elc" ".lof" ".glo" ".idx" ".lot" ;; TeX-related - ".dvi" ".fmt" ".tfm" ".pdf" + ".fmt" ".tfm" ;; Java compiled ".class" ;; CLISP Index: lisp/ChangeLog =================================================================== RCS file: /sources/emacs/emacs/lisp/ChangeLog,v retrieving revision 1.11948 diff -u -r1.11948 ChangeLog --- lisp/ChangeLog 17 Oct 2007 16:24:33 -0000 1.11948 +++ lisp/ChangeLog 17 Oct 2007 19:51:55 -0000 @@ -1,3 +1,16 @@ +2007-10-17 Tassilo Horn <tassilo@member.fsf.org> + + * bindings.el (completion-ignored-extensions): Remove pdf and dvi + extensions since they can be viewed with doc-view. + + * files.el (auto-mode-alist): Make doc-view-mode the default mode + for pdf, ps and dvi files. + + * doc-view.el: Make doc-view-mode the standard mode for viewing + pdf, [e]ps and dvi files and add binding C-c C-c to toggle between + text and image display. Add binding C-c C-e to switch to an + editing mode. + 2007-10-17 Stefan Monnier <monnier@iro.umontreal.ca> * progmodes/compile.el (compilation-next-error-function): Fix timestamp [-- Attachment #3: Type: text/plain, Size: 142 bytes --] _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-17 19:54 ` Tassilo Horn @ 2007-10-17 23:29 ` Dan Nicolaescu 2007-10-18 1:47 ` Miles Bader 2007-10-18 6:56 ` Tassilo Horn 0 siblings, 2 replies; 34+ messages in thread From: Dan Nicolaescu @ 2007-10-17 23:29 UTC (permalink / raw) To: Stefan Monnier; +Cc: rms, emacs-devel Tassilo Horn <tassilo@member.fsf.org> writes: > Index: lisp/files.el > =================================================================== > RCS file: /sources/emacs/emacs/lisp/files.el,v > retrieving revision 1.932 > diff -u -r1.932 files.el > --- lisp/files.el 15 Oct 2007 02:07:46 -0000 1.932 > +++ lisp/files.el 17 Oct 2007 19:51:46 -0000 > @@ -2059,7 +2059,7 @@ > ("\\.\\(as\\|mi\\|sm\\)2\\'" . snmpv2-mode) > ("\\.\\(diffs?\\|patch\\|rej\\)\\'" . diff-mode) > ("\\.\\(dif\\|pat\\)\\'" . diff-mode) ; for MSDOG > - ("\\.[eE]?[pP][sS]\\'" . ps-mode) > + ("\\(?:DVI\\|EPS\\|P\\(?:DF\\|S\\)\\|dvi\\|eps\\|p\\(?:df\\|s\\)\\)" . doc-view-mode) Is this a good idea? PostScript is not only used for documents, but it is also a programming language. How likely is it that someone that does a C-x C-f for a ps file does it in order to view it, not to edit it? I haven't done it in a long time, but I used to regularly have to tweak ps files generated by various utilities... ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-17 23:29 ` Dan Nicolaescu @ 2007-10-18 1:47 ` Miles Bader 2007-10-19 5:40 ` Richard Stallman 2007-10-18 6:56 ` Tassilo Horn 1 sibling, 1 reply; 34+ messages in thread From: Miles Bader @ 2007-10-18 1:47 UTC (permalink / raw) To: emacs-devel Dan Nicolaescu <dann@ics.uci.edu> writes: > Is this a good idea? > PostScript is not only used for documents, but it is also a > programming language. How likely is it that someone that does a C-x > C-f for a ps file does it in order to view it, not to edit it? > I haven't done it in a long time, but I used to regularly have to > tweak ps files generated by various utilities... Yeah, I agree -- it's a fine programming language in its own way, and quite reasonable as a real source language. I'd guess in such cases, given that Emacs is fundamentally a text-editor, it seems best to do something like Emacs already does for .xpm files: display as text (in postscript-mode or whatever) with a message saying "Type C-c C-c to view the printed form of this document." Indeed, for hacking on postscript, this would be great -- just make a change, then hit C-c C-c to see the effect in the same window! -Miles -- "Though they may have different meanings, the cries of 'Yeeeee-haw!' and 'Allahu akbar!' are, in spirit, not actually all that different." ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-18 1:47 ` Miles Bader @ 2007-10-19 5:40 ` Richard Stallman 2007-10-19 7:50 ` David Kastrup 0 siblings, 1 reply; 34+ messages in thread From: Richard Stallman @ 2007-10-19 5:40 UTC (permalink / raw) To: Miles Bader; +Cc: emacs-devel I'd guess in such cases, given that Emacs is fundamentally a text-editor, it seems best to do something like Emacs already does for .xpm files: display as text (in postscript-mode or whatever) with a message saying "Type C-c C-c to view the printed form of this document." Thus, for PS, we would show the text initially; for PDF and DVI, we would show the rendered form initially. That seems ok. ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-19 5:40 ` Richard Stallman @ 2007-10-19 7:50 ` David Kastrup 2007-10-20 1:31 ` Miles Bader 2007-10-20 3:29 ` Richard Stallman 0 siblings, 2 replies; 34+ messages in thread From: David Kastrup @ 2007-10-19 7:50 UTC (permalink / raw) To: rms; +Cc: emacs-devel, Miles Bader Richard Stallman <rms@gnu.org> writes: > I'd guess in such cases, given that Emacs is fundamentally a > text-editor, it seems best to do something like Emacs already does for > .xpm files: display as text (in postscript-mode or whatever) with a > message saying "Type C-c C-c to view the printed form of this document." > > Thus, for PS, we would show the text initially; for PDF and DVI, we > would show the rendered form initially. That seems ok. I am actually looking at PDF source quite often. It is, after all, more or less a restricted form of PostScript as long as one does not use compression (but compression can be used in PostScript, too). -- David Kastrup ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-19 7:50 ` David Kastrup @ 2007-10-20 1:31 ` Miles Bader 2007-10-21 14:56 ` David Kastrup 2007-10-20 3:29 ` Richard Stallman 1 sibling, 1 reply; 34+ messages in thread From: Miles Bader @ 2007-10-20 1:31 UTC (permalink / raw) To: David Kastrup; +Cc: rms, emacs-devel David Kastrup <dak@gnu.org> writes: >> Thus, for PS, we would show the text initially; for PDF and DVI, we >> would show the rendered form initially. That seems ok. > > I am actually looking at PDF source quite often. It is, after all, > more or less a restricted form of PostScript as long as one does not > use compression (but compression can be used in PostScript, too). Unlike postscript, I think editing of pdf files as text is vanishingly rare, even if it's possible, and clearly shouldn't be the default. Clearly it would be nice if choosing the default action for any given file type was easy though... -Miles -- "1971 pickup truck; will trade for guns" ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-20 1:31 ` Miles Bader @ 2007-10-21 14:56 ` David Kastrup 2007-10-21 19:23 ` Stefan Monnier 0 siblings, 1 reply; 34+ messages in thread From: David Kastrup @ 2007-10-21 14:56 UTC (permalink / raw) To: Miles Bader; +Cc: rms, emacs-devel Miles Bader <miles@gnu.org> writes: > David Kastrup <dak@gnu.org> writes: >>> Thus, for PS, we would show the text initially; for PDF and DVI, we >>> would show the rendered form initially. That seems ok. >> >> I am actually looking at PDF source quite often. It is, after all, >> more or less a restricted form of PostScript as long as one does not >> use compression (but compression can be used in PostScript, too). > > Unlike postscript, I think editing of pdf files as text is vanishingly > rare, even if it's possible, and clearly shouldn't be the default. > > Clearly it would be nice if choosing the default action for any given > file type was easy though... There is a difference to PostScript, actually: when I am looking at PDF, I am only _reading_ it, ever (PDF contains file offset tables at the end which makes it rather inconvenient to hand-edit). One can actually write PostScript, in contrast. -- David Kastrup, Kriemhildstr. 15, 44793 Bochum ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-21 14:56 ` David Kastrup @ 2007-10-21 19:23 ` Stefan Monnier 2007-10-21 20:26 ` David Kastrup 0 siblings, 1 reply; 34+ messages in thread From: Stefan Monnier @ 2007-10-21 19:23 UTC (permalink / raw) To: David Kastrup; +Cc: emacs-devel, rms, Miles Bader > There is a difference to PostScript, actually: when I am looking at > PDF, I am only _reading_ it, ever (PDF contains file offset tables at > the end which makes it rather inconvenient to hand-edit). Is there a pdf-mode somewhere? Maybe one which could decompress the PDF to show the underlying postscript-like text-form? Stefan ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-21 19:23 ` Stefan Monnier @ 2007-10-21 20:26 ` David Kastrup 2007-10-22 0:48 ` Stefan Monnier 0 siblings, 1 reply; 34+ messages in thread From: David Kastrup @ 2007-10-21 20:26 UTC (permalink / raw) To: Stefan Monnier; +Cc: emacs-devel, rms, Miles Bader Stefan Monnier <monnier@iro.umontreal.ca> writes: >> There is a difference to PostScript, actually: when I am looking at >> PDF, I am only _reading_ it, ever (PDF contains file offset tables at >> the end which makes it rather inconvenient to hand-edit). > > Is there a pdf-mode somewhere? Maybe one which could decompress the > PDF to show the underlying postscript-like text-form? PDF is not per se compressed. It can include compressed streams and objects, though. pdftk can be used for uncompressing this kind of stuff. The result is still a valid PDF file, just larger. -- David Kastrup, Kriemhildstr. 15, 44793 Bochum ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-21 20:26 ` David Kastrup @ 2007-10-22 0:48 ` Stefan Monnier 0 siblings, 0 replies; 34+ messages in thread From: Stefan Monnier @ 2007-10-22 0:48 UTC (permalink / raw) To: David Kastrup; +Cc: emacs-devel, rms, Miles Bader >>> There is a difference to PostScript, actually: when I am looking at >>> PDF, I am only _reading_ it, ever (PDF contains file offset tables at >>> the end which makes it rather inconvenient to hand-edit). >> >> Is there a pdf-mode somewhere? Maybe one which could decompress the >> PDF to show the underlying postscript-like text-form? > PDF is not per se compressed. It can include compressed streams and > objects, though. > pdftk can be used for uncompressing this kind of stuff. The result is > still a valid PDF file, just larger. Yes, I understand that, which is why we'd need a special major mode to uncompress the various parts (and recompress them when saving, I guess, although as you say, this would first imply the ability to update the offset tables). Stefan ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-19 7:50 ` David Kastrup 2007-10-20 1:31 ` Miles Bader @ 2007-10-20 3:29 ` Richard Stallman 1 sibling, 0 replies; 34+ messages in thread From: Richard Stallman @ 2007-10-20 3:29 UTC (permalink / raw) To: David Kastrup; +Cc: emacs-devel, miles > Thus, for PS, we would show the text initially; for PDF and DVI, we > would show the rendered form initially. That seems ok. I am actually looking at PDF source quite often. I think you are unusual, so you should customize the settings. ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-17 23:29 ` Dan Nicolaescu 2007-10-18 1:47 ` Miles Bader @ 2007-10-18 6:56 ` Tassilo Horn 2007-10-18 8:10 ` David Kastrup 1 sibling, 1 reply; 34+ messages in thread From: Tassilo Horn @ 2007-10-18 6:56 UTC (permalink / raw) To: Dan Nicolaescu; +Cc: emacs-devel, Stefan Monnier, rms Dan Nicolaescu <dann@ics.uci.edu> writes: > Tassilo Horn <tassilo@member.fsf.org> writes: > > > Index: lisp/files.el > > =================================================================== > > RCS file: /sources/emacs/emacs/lisp/files.el,v > > retrieving revision 1.932 > > diff -u -r1.932 files.el > > --- lisp/files.el 15 Oct 2007 02:07:46 -0000 1.932 > > +++ lisp/files.el 17 Oct 2007 19:51:46 -0000 > > @@ -2059,7 +2059,7 @@ > > ("\\.\\(as\\|mi\\|sm\\)2\\'" . snmpv2-mode) > > ("\\.\\(diffs?\\|patch\\|rej\\)\\'" . diff-mode) > > ("\\.\\(dif\\|pat\\)\\'" . diff-mode) ; for MSDOG > > - ("\\.[eE]?[pP][sS]\\'" . ps-mode) > > + ("\\(?:DVI\\|EPS\\|P\\(?:DF\\|S\\)\\|dvi\\|eps\\|p\\(?:df\\|s\\)\\)" . doc-view-mode) > > Is this a good idea? > PostScript is not only used for documents, but it is also a > programming language. How likely is it that someone that does a C-x > C-f for a ps file does it in order to view it, not to edit it? When people know doc-view it's very likely. To open a PS file for editing you can do C-c C-e in doc-view-mode. To view the file after you made some changes M-x revert-buffer should do the trick. Bye, Tassilo ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-18 6:56 ` Tassilo Horn @ 2007-10-18 8:10 ` David Kastrup 2007-10-18 8:19 ` Tassilo Horn 0 siblings, 1 reply; 34+ messages in thread From: David Kastrup @ 2007-10-18 8:10 UTC (permalink / raw) To: Dan Nicolaescu; +Cc: emacs-devel, Stefan Monnier, rms Tassilo Horn <tassilo@member.fsf.org> writes: > Dan Nicolaescu <dann@ics.uci.edu> writes: > >> Tassilo Horn <tassilo@member.fsf.org> writes: >> >> > Index: lisp/files.el >> > =================================================================== >> > RCS file: /sources/emacs/emacs/lisp/files.el,v >> > retrieving revision 1.932 >> > diff -u -r1.932 files.el >> > --- lisp/files.el 15 Oct 2007 02:07:46 -0000 1.932 >> > +++ lisp/files.el 17 Oct 2007 19:51:46 -0000 >> > @@ -2059,7 +2059,7 @@ >> > ("\\.\\(as\\|mi\\|sm\\)2\\'" . snmpv2-mode) >> > ("\\.\\(diffs?\\|patch\\|rej\\)\\'" . diff-mode) >> > ("\\.\\(dif\\|pat\\)\\'" . diff-mode) ; for MSDOG >> > - ("\\.[eE]?[pP][sS]\\'" . ps-mode) >> > + ("\\(?:DVI\\|EPS\\|P\\(?:DF\\|S\\)\\|dvi\\|eps\\|p\\(?:df\\|s\\)\\)" . doc-view-mode) >> >> Is this a good idea? >> PostScript is not only used for documents, but it is also a >> programming language. How likely is it that someone that does a C-x >> C-f for a ps file does it in order to view it, not to edit it? > > When people know doc-view it's very likely. No, it isn't. We can do a poll if you think otherwise. -- David Kastrup ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-18 8:10 ` David Kastrup @ 2007-10-18 8:19 ` Tassilo Horn 2007-10-18 8:33 ` David Kastrup 2007-10-18 20:37 ` Reiner Steib 0 siblings, 2 replies; 34+ messages in thread From: Tassilo Horn @ 2007-10-18 8:19 UTC (permalink / raw) To: David Kastrup; +Cc: Dan Nicolaescu, Stefan Monnier, rms, emacs-devel David Kastrup <dak@gnu.org> writes: >>> > Index: lisp/files.el >>> > =================================================================== >>> > RCS file: /sources/emacs/emacs/lisp/files.el,v >>> > retrieving revision 1.932 >>> > diff -u -r1.932 files.el >>> > --- lisp/files.el 15 Oct 2007 02:07:46 -0000 1.932 >>> > +++ lisp/files.el 17 Oct 2007 19:51:46 -0000 >>> > @@ -2059,7 +2059,7 @@ >>> > ("\\.\\(as\\|mi\\|sm\\)2\\'" . snmpv2-mode) >>> > ("\\.\\(diffs?\\|patch\\|rej\\)\\'" . diff-mode) >>> > ("\\.\\(dif\\|pat\\)\\'" . diff-mode) ; for MSDOG >>> > - ("\\.[eE]?[pP][sS]\\'" . ps-mode) >>> > + ("\\(?:DVI\\|EPS\\|P\\(?:DF\\|S\\)\\|dvi\\|eps\\|p\\(?:df\\|s\\)\\)" . doc-view-mode) >>> >>> Is this a good idea? >>> PostScript is not only used for documents, but it is also a >>> programming language. How likely is it that someone that does a C-x >>> C-f for a ps file does it in order to view it, not to edit it? >> >> When people know doc-view it's very likely. > > No, it isn't. We can do a poll if you think otherwise. Ok, ok. On my todo list is an entry that inside doc-view-mode `C-c C-c' should toggle between "a real editing major mode" (e.g. ps-mode) and doc-view-mode. Bye, Tassilo ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-18 8:19 ` Tassilo Horn @ 2007-10-18 8:33 ` David Kastrup 2007-10-19 0:45 ` Juri Linkov 2007-10-18 20:37 ` Reiner Steib 1 sibling, 1 reply; 34+ messages in thread From: David Kastrup @ 2007-10-18 8:33 UTC (permalink / raw) To: Dan Nicolaescu; +Cc: Stefan Monnier, rms, emacs-devel Tassilo Horn <tassilo@member.fsf.org> writes: > David Kastrup <dak@gnu.org> writes: > >>>> > Index: lisp/files.el >>>> > =================================================================== >>>> > RCS file: /sources/emacs/emacs/lisp/files.el,v >>>> > retrieving revision 1.932 >>>> > diff -u -r1.932 files.el >>>> > --- lisp/files.el 15 Oct 2007 02:07:46 -0000 1.932 >>>> > +++ lisp/files.el 17 Oct 2007 19:51:46 -0000 >>>> > @@ -2059,7 +2059,7 @@ >>>> > ("\\.\\(as\\|mi\\|sm\\)2\\'" . snmpv2-mode) >>>> > ("\\.\\(diffs?\\|patch\\|rej\\)\\'" . diff-mode) >>>> > ("\\.\\(dif\\|pat\\)\\'" . diff-mode) ; for MSDOG >>>> > - ("\\.[eE]?[pP][sS]\\'" . ps-mode) >>>> > + ("\\(?:DVI\\|EPS\\|P\\(?:DF\\|S\\)\\|dvi\\|eps\\|p\\(?:df\\|s\\)\\)" . doc-view-mode) >>>> >>>> Is this a good idea? >>>> PostScript is not only used for documents, but it is also a >>>> programming language. How likely is it that someone that does a C-x >>>> C-f for a ps file does it in order to view it, not to edit it? >>> >>> When people know doc-view it's very likely. >> >> No, it isn't. We can do a poll if you think otherwise. > > Ok, ok. On my todo list is an entry that inside doc-view-mode `C-c C-c' > should toggle between "a real editing major mode" (e.g. ps-mode) and > doc-view-mode. I think for our various image view modes, C-x C-r should preferably start the viewer, but C-x C-f should possibly start the editor. At the very least, C-u C-x C-f should start the editor, "I mean it!". -- David Kastrup ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-18 8:33 ` David Kastrup @ 2007-10-19 0:45 ` Juri Linkov 0 siblings, 0 replies; 34+ messages in thread From: Juri Linkov @ 2007-10-19 0:45 UTC (permalink / raw) To: David Kastrup; +Cc: emacs-devel > I think for our various image view modes, C-x C-r should preferably > start the viewer, but C-x C-f should possibly start the editor. At > the very least, C-u C-x C-f should start the editor, "I mean it!". Or maybe, if a file is opened in read-only mode (even C-x C-f on a non-writable file), then start the viewer. -- Juri Linkov http://www.jurta.org/emacs/ ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-18 8:19 ` Tassilo Horn 2007-10-18 8:33 ` David Kastrup @ 2007-10-18 20:37 ` Reiner Steib 1 sibling, 0 replies; 34+ messages in thread From: Reiner Steib @ 2007-10-18 20:37 UTC (permalink / raw) To: emacs-devel On Thu, Oct 18 2007, Tassilo Horn wrote: > On my todo list is an entry that inside doc-view-mode `C-c C-c' > should toggle between "a real editing major mode" (e.g. ps-mode) and > doc-view-mode. I modified the change to `auto-mode-alist' (don't open PS and EPS with doc-view by default) as this seem to be controversial. Bye, Reiner. -- ,,, (o o) ---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/ ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-17 8:39 ` Tassilo Horn 2007-10-17 13:57 ` Stefan Monnier @ 2007-10-17 20:49 ` Richard Stallman 2007-10-17 20:54 ` Tassilo Horn 1 sibling, 1 reply; 34+ messages in thread From: Richard Stallman @ 2007-10-17 20:49 UTC (permalink / raw) To: Tassilo Horn; +Cc: monnier, emacs-devel > You could also indicate in the mode line that the process is running. doc-view indicates with a message and in the tooltip that conversion hasn't finished yet. If users are happy with that, then good. But maybe it should indicate in the mode line as M-x compile does. It shows "Compiling" in all buffers' mode lines. ^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: doc-view.el: about cursor and filename display 2007-10-17 20:49 ` Richard Stallman @ 2007-10-17 20:54 ` Tassilo Horn 0 siblings, 0 replies; 34+ messages in thread From: Tassilo Horn @ 2007-10-17 20:54 UTC (permalink / raw) To: rms; +Cc: monnier, emacs-devel Richard Stallman <rms@gnu.org> writes: > > You could also indicate in the mode line that the process is running. > > doc-view indicates with a message and in the tooltip that conversion > hasn't finished yet. > > If users are happy with that, then good. But maybe it should indicate > in the mode line as M-x compile does. It shows "Compiling" in all > buffers' mode lines. Stefan pointed me to mode-line-process, and the newest patch uses that to indicate that (and what for) a conversion process is running. Bye, Tassilo ^ permalink raw reply [flat|nested] 34+ messages in thread
end of thread, other threads:[~2007-10-22 0:48 UTC | newest] Thread overview: 34+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-10-15 8:27 doc-view.el: about cursor and filename display William Xu 2007-10-15 9:20 ` Tassilo Horn 2007-10-15 11:15 ` William Xu 2007-10-15 15:13 ` Tassilo Horn 2007-10-16 4:10 ` Richard Stallman 2007-10-15 14:00 ` Stefan Monnier 2007-10-15 14:20 ` Tassilo Horn 2007-10-16 4:10 ` Richard Stallman 2007-10-16 6:34 ` Tassilo Horn 2007-10-17 5:02 ` Richard Stallman 2007-10-17 8:39 ` Tassilo Horn 2007-10-17 13:57 ` Stefan Monnier 2007-10-17 16:19 ` Tassilo Horn 2007-10-18 5:02 ` Richard Stallman 2007-10-18 6:50 ` Tassilo Horn 2007-10-17 19:54 ` Tassilo Horn 2007-10-17 23:29 ` Dan Nicolaescu 2007-10-18 1:47 ` Miles Bader 2007-10-19 5:40 ` Richard Stallman 2007-10-19 7:50 ` David Kastrup 2007-10-20 1:31 ` Miles Bader 2007-10-21 14:56 ` David Kastrup 2007-10-21 19:23 ` Stefan Monnier 2007-10-21 20:26 ` David Kastrup 2007-10-22 0:48 ` Stefan Monnier 2007-10-20 3:29 ` Richard Stallman 2007-10-18 6:56 ` Tassilo Horn 2007-10-18 8:10 ` David Kastrup 2007-10-18 8:19 ` Tassilo Horn 2007-10-18 8:33 ` David Kastrup 2007-10-19 0:45 ` Juri Linkov 2007-10-18 20:37 ` Reiner Steib 2007-10-17 20:49 ` Richard Stallman 2007-10-17 20:54 ` Tassilo Horn
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).