unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* doc-view.el --- View PDF/PostScript/DVI files in Emacs
@ 2007-08-24 11:03 Tassilo Horn
  2007-08-24 11:47 ` Michaël Cadilhac
  0 siblings, 1 reply; 19+ messages in thread
From: Tassilo Horn @ 2007-08-24 11:03 UTC (permalink / raw)
  To: emacs-devel

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

Hi all,

Richard and Stefan asked me to include my doc-view.el in the emacs
distribution, so here it is together with a ChangeLog entry for
lisp/ChangeLog.

--8<---------------cut here---------------start------------->8---
Index: lisp/ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.11619
diff -u -r1.11619 ChangeLog
--- lisp/ChangeLog	24 Aug 2007 10:50:07 -0000	1.11619
+++ lisp/ChangeLog	24 Aug 2007 11:02:27 -0000
@@ -1,3 +1,7 @@
+2007-08-24  Tassilo Horn  <tassilo@member.fsf.org>
+
+	* doc-view.el: New file.  A in-buffer PDF/PS/DVI viewer.
+
 2007-08-24  Thien-Thi Nguyen  <ttn@gnuvola.org>
 
 	* progmodes/hideshow.el (hs-match-data): Delete alias.
--8<---------------cut here---------------end--------------->8---


[-- Attachment #2: doc-view.el --- View PDF/PostScript/DVI files in Emacs --]
[-- Type: application/emacs-lisp, Size: 10978 bytes --]

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


Bye,
Tassilo
-- 
Chuck Norris' roundhouse kick is so  powerful, it can be seen from outer
space by the naked eye.

[-- Attachment #4: 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] 19+ messages in thread

* Re: doc-view.el --- View PDF/PostScript/DVI files in Emacs
  2007-08-24 11:03 doc-view.el --- View PDF/PostScript/DVI files in Emacs Tassilo Horn
@ 2007-08-24 11:47 ` Michaël Cadilhac
  2007-08-24 15:24   ` Tassilo Horn
  0 siblings, 1 reply; 19+ messages in thread
From: Michaël Cadilhac @ 2007-08-24 11:47 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 1162 bytes --]

Tassilo Horn <tassilo@member.fsf.org> writes:

> Hi all,
>
> Richard and Stefan asked me to include my doc-view.el in the emacs
> distribution, so here it is together with a ChangeLog entry for
> lisp/ChangeLog.

This a good feature, but when I tried it on a 60-page document, my
processor load quickly reached 10 and I was completely stuck. C-g did
nothing, my firefox was killed, and one of the light bulb of my room
exploded (there may be no connection for the last one, I'm just not
sure).

It may be a good thing that every 10 seconds, Emacs says « The DocView
conversion is still running after %d seconds, cancel? », and while the
question is asked, it (signal-process) to SIGSTOP before and then
SIGCONT after if the answer is yes.

Oh, and you wrote `dac-view-' in the :prefix of the doc-view group.
Typo?

-- 
 |   Michaël `Micha' Cadilhac       |    The second-degree,                  |
 |   http://michael.cadilhac.name   |       is kind of                       |
 |   JID/MSN:                       |   the semantic back slang.             |
 `----  michael.cadilhac@gmail.com  |                                   -  --'

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: 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] 19+ messages in thread

* Re: doc-view.el --- View PDF/PostScript/DVI files in Emacs
  2007-08-24 11:47 ` Michaël Cadilhac
@ 2007-08-24 15:24   ` Tassilo Horn
  2007-08-24 21:42     ` David Kastrup
  2007-08-25 20:52     ` Richard Stallman
  0 siblings, 2 replies; 19+ messages in thread
From: Tassilo Horn @ 2007-08-24 15:24 UTC (permalink / raw)
  To: emacs-devel

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

michael@cadilhac.name (Michaël Cadilhac) writes:

Hi Michaël,

> This a good feature, but when I tried it on a 60-page document, my
> processor load quickly reached 10 and I was completely stuck. C-g did
> nothing, my firefox was killed, and one of the light bulb of my room
> exploded (there may be no connection for the last one, I'm just not
> sure).

Yes, that's normal.  Be happy that it caches the page files so that it
will open immediately when you want to view this document again.

You can limit the resources convert uses with some environment variables
or it's -limit option.  See the WARNING in the commentary.  And now it
displays a message while it's converting, too.

> It may be a good thing that every 10 seconds, Emacs says « The DocView
> conversion is still running after %d seconds, cancel? », and while the
> question is asked, it (signal-process) to SIGSTOP before and then
> SIGCONT after if the answer is yes.

Hm, I don't think asking questions is a good thing.  I limit convert's
resources and when I open a doc I hadn't opened before, then I know that
it may take some minutes with large files and continue my work until the
*DocView* buffer eventually pops up.

Granted, doc-view isn't too good for large docs that aren't cached.  I
added a function to cancel the conversion.

> Oh, and you wrote `dac-view-' in the :prefix of the doc-view group.
> Typo?

Oh, yes.  And there was an obsolete variable mentioned in the docs.

And I changed the caching strategy a bit.  Instead of using a md5 sum of
the files path I use a md5 sum of its contents, so viewing 2 identical
files in different filesystem locations or moving of files don't need a
new conversion.

I think now it's much better now.


[-- Attachment #2: Second version of doc-view.el --]
[-- Type: application/emacs-lisp, Size: 12419 bytes --]

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


Bye,
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

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: doc-view.el --- View PDF/PostScript/DVI files in Emacs
  2007-08-24 15:24   ` Tassilo Horn
@ 2007-08-24 21:42     ` David Kastrup
  2007-08-25 17:26       ` Tassilo Horn
  2007-08-25 20:52     ` Richard Stallman
  1 sibling, 1 reply; 19+ messages in thread
From: David Kastrup @ 2007-08-24 21:42 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: emacs-devel

Tassilo Horn <tassilo@member.fsf.org> writes:

> michael@cadilhac.name (Michaël Cadilhac) writes:
>
> Hi Michaël,
>
>> This a good feature, but when I tried it on a 60-page document, my
>> processor load quickly reached 10 and I was completely stuck. C-g
>> did nothing, my firefox was killed, and one of the light bulb of my
>> room exploded (there may be no connection for the last one, I'm
>> just not sure).
>
> Yes, that's normal.  Be happy that it caches the page files so that
> it will open immediately when you want to view this document again.
>
> You can limit the resources convert uses with some environment
> variables or it's -limit option.  See the WARNING in the commentary.
> And now it displays a message while it's converting, too.

Have you tried out preview-latex (integrated with AUCTeX since version
11.80)?  It displays images in Emacs buffers without blocking Emacs at
all, and renders stuff in the background with a focus on material that
is on-screen.  It works using Ghostscript on either PDF or PostScript
files (in the latter case, dvips is used) or dvipng on DVI files.
Ghostscript is used as a daemon in order to render the stuff in a
useful order, and a single Ghostscript session renders all images.

So it would seem like quite a good candidate for borrowing code.  In
particular since the entirety of preview-latex is already
copyright-assigned to the FSF (as opposed to other parts of AUCTeX
where this process is still under work).

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: doc-view.el --- View PDF/PostScript/DVI files in Emacs
  2007-08-24 21:42     ` David Kastrup
@ 2007-08-25 17:26       ` Tassilo Horn
  2007-08-25 18:34         ` David Kastrup
  0 siblings, 1 reply; 19+ messages in thread
From: Tassilo Horn @ 2007-08-25 17:26 UTC (permalink / raw)
  To: emacs-devel

David Kastrup <dak@gnu.org> writes:

Hi David,

> Have you tried out preview-latex (integrated with AUCTeX since version
> 11.80)?  It displays images in Emacs buffers without blocking Emacs at
> all, and renders stuff in the background with a focus on material that
> is on-screen.

I had a look at it but it didn't look that borrowing code there would
simplify doc-view.el.

> It works using Ghostscript on either PDF or PostScript files (in the
> latter case, dvips is used) or dvipng on DVI files.

I changed doc-view.el so that it uses plain ghostscript (plus dvipdfm
for DVI files) which gives good results and is about ten times faster
than with ImageMagick's convert.

The only downside is that I don't know how to cut off the margins.
Those waste a lot of buffer space when displaying the image.  converts
-trim option was very nice for that cause.  Do you know how one can do
that with ghostview?

> Ghostscript is used as a daemon in order to render the stuff in a
> useful order, and a single Ghostscript session renders all images.

Well, the conversion in doc-view.el runs asynchronous, too.  Users can
go on with their work and eventually the *DocView* buffer will pop up.

Bye,
Tassilo

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: doc-view.el --- View PDF/PostScript/DVI files in Emacs
  2007-08-25 17:26       ` Tassilo Horn
@ 2007-08-25 18:34         ` David Kastrup
  2007-08-26 10:20           ` Tassilo Horn
  0 siblings, 1 reply; 19+ messages in thread
From: David Kastrup @ 2007-08-25 18:34 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: emacs-devel

Tassilo Horn <tassilo@member.fsf.org> writes:

> David Kastrup <dak@gnu.org> writes:
>
>> Have you tried out preview-latex (integrated with AUCTeX since
>> version 11.80)?  It displays images in Emacs buffers without
>> blocking Emacs at all, and renders stuff in the background with a
>> focus on material that is on-screen.
>
> I had a look at it but it didn't look that borrowing code there
> would simplify doc-view.el.

I was not thinking about simplification, but rather improvement.

>> It works using Ghostscript on either PDF or PostScript files (in
>> the latter case, dvips is used) or dvipng on DVI files.
>
> I changed doc-view.el so that it uses plain ghostscript (plus
> dvipdfm for DVI files) which gives good results and is about ten
> times faster than with ImageMagick's convert.
>
> The only downside is that I don't know how to cut off the margins.
> Those waste a lot of buffer space when displaying the image.
> converts -trim option was very nice for that cause.  Do you know how
> one can do that with ghostview?

Well, that is one of the things done in preview-latex.  Do you have
the bounding box information for your images (preview-latex takes them
from TeX usually)?

>> Ghostscript is used as a daemon in order to render the stuff in a
>> useful order, and a single Ghostscript session renders all images.
>
> Well, the conversion in doc-view.el runs asynchronous, too.  Users
> can go on with their work and eventually the *DocView* buffer will
> pop up.

preview-latex provides a working view of the buffer straight away,
rendering images and replacing place-holders first on the displayed
screen area, then off-screen.  That way, you get immediate visual
feedback where you need it, even though the rendering of thousands of
images might take a minute or so.

It is really several years of optimizations and user feedback that
went into the code base.  You should take it for a test drive before
deciding that its behavior does not suggest interesting material to
your project.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: doc-view.el --- View PDF/PostScript/DVI files in Emacs
  2007-08-24 15:24   ` Tassilo Horn
  2007-08-24 21:42     ` David Kastrup
@ 2007-08-25 20:52     ` Richard Stallman
  2007-08-26 10:11       ` Tassilo Horn
  1 sibling, 1 reply; 19+ messages in thread
From: Richard Stallman @ 2007-08-25 20:52 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: emacs-devel

    > This a good feature, but when I tried it on a 60-page document, my
    > processor load quickly reached 10 and I was completely stuck. C-g did
    > nothing, my firefox was killed, and one of the light bulb of my room
    > exploded (there may be no connection for the last one, I'm just not
    > sure).

    Yes, that's normal.  Be happy that it caches the page files so that it
    will open immediately when you want to view this document again.

For C-g not to work is a a real problem.  Why does that happen?  Did
you bind inhibit-quit to t?  If so, I think it is a bug in your code.
If not, I think it is a bug in Emacs.

Does it run the subprocess asynchronously?  If not, maybe it should.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: doc-view.el --- View PDF/PostScript/DVI files in Emacs
  2007-08-25 20:52     ` Richard Stallman
@ 2007-08-26 10:11       ` Tassilo Horn
  2007-08-26 22:46         ` Richard Stallman
  0 siblings, 1 reply; 19+ messages in thread
From: Tassilo Horn @ 2007-08-26 10:11 UTC (permalink / raw)
  To: emacs-devel

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

Richard Stallman <rms@gnu.org> writes:


>     > processor load quickly reached 10 and I was completely
>     > stuck. C-g did nothing, my firefox was killed, and one of the
>     > light bulb of my room exploded (there may be no connection for
>     > the last one, I'm just not sure).
>
>     Yes, that's normal.  Be happy that it caches the page files so
>     that it will open immediately when you want to view this document
>     again.
>
> For C-g not to work is a a real problem.  Why does that happen?  Did
> you bind inhibit-quit to t?  If so, I think it is a bug in your code.
> If not, I think it is a bug in Emacs.

No, his computer froze because ImageMagick's convert tool used up all
his resources.  But yesterday I switched to using plain ghostscript
which is about 10 times as fast and gives nearly as good results.

> Does it run the subprocess asynchronously?  If not, maybe it should.

The conversion subprocess runs asynchronously and now it can be killed
if it takes too long.

Anyway, I think I have to look a bit deeper into David's suggestion to
use AuCTEX preview.el.  But that may take some time, as I have a lot of
other stuff to do.

So I think we should lay the inclusion of doc-view.el on ice till I've
done that.  I'll announce when it's ready to go in.

I'll attach the current version, if someone wants to play with it.

Bye,
Tassilo

[-- Attachment #2: doc-view.el now using plain ghostscript --]
[-- Type: application/emacs-lisp, Size: 11006 bytes --]

[-- 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] 19+ messages in thread

* Re: doc-view.el --- View PDF/PostScript/DVI files in Emacs
  2007-08-25 18:34         ` David Kastrup
@ 2007-08-26 10:20           ` Tassilo Horn
  2007-08-26 20:38             ` David Kastrup
  0 siblings, 1 reply; 19+ messages in thread
From: Tassilo Horn @ 2007-08-26 10:20 UTC (permalink / raw)
  To: emacs-devel

David Kastrup <dak@gnu.org> writes:

Hi David,

>> I changed doc-view.el so that it uses plain ghostscript (plus dvipdfm
>> for DVI files) which gives good results and is about ten times faster
>> than with ImageMagick's convert.
>>
>> The only downside is that I don't know how to cut off the margins.
>> Those waste a lot of buffer space when displaying the image.
>> converts -trim option was very nice for that cause.  Do you know how
>> one can do that with ghostview?
>
> Well, that is one of the things done in preview-latex.  Do you have
> the bounding box information for your images (preview-latex takes them
> from TeX usually)?

No, how should I get it?  I only have PDF/PS or DVI files with no
sources at all.

>>> Ghostscript is used as a daemon in order to render the stuff in a
>>> useful order, and a single Ghostscript session renders all images.
>>
>> Well, the conversion in doc-view.el runs asynchronous, too.  Users
>> can go on with their work and eventually the *DocView* buffer will
>> pop up.
>
> preview-latex provides a working view of the buffer straight away,
> rendering images and replacing place-holders first on the displayed
> screen area, then off-screen.  That way, you get immediate visual
> feedback where you need it, even though the rendering of thousands of
> images might take a minute or so.

Yes, I know.  I use it sometimes to check if the LaTeX source I write is
correct, especially for huge math formulas.

> It is really several years of optimizations and user feedback that
> went into the code base.  You should take it for a test drive before
> deciding that its behavior does not suggest interesting material to
> your project.

If it can be useful if everything I have is the plain document with no
additional source or infos about included images, then I'll do it.

So can it do that?

Bye,
Tassilo
-- 
Früher haben wir vor dem Essen  immer gebetet, aber jetzt hat meine Frau
einen Kochkurs gemacht.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: doc-view.el --- View PDF/PostScript/DVI files in Emacs
  2007-08-26 10:20           ` Tassilo Horn
@ 2007-08-26 20:38             ` David Kastrup
  2007-08-27  8:52               ` Tassilo Horn
  0 siblings, 1 reply; 19+ messages in thread
From: David Kastrup @ 2007-08-26 20:38 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: emacs-devel

Tassilo Horn <tassilo@member.fsf.org> writes:

> David Kastrup <dak@gnu.org> writes:
>
> Hi David,
>
>>> I changed doc-view.el so that it uses plain ghostscript (plus dvipdfm
>>> for DVI files) which gives good results and is about ten times faster
>>> than with ImageMagick's convert.
>>>
>>> The only downside is that I don't know how to cut off the margins.
>>> Those waste a lot of buffer space when displaying the image.
>>> converts -trim option was very nice for that cause.  Do you know how
>>> one can do that with ghostview?
>>
>> Well, that is one of the things done in preview-latex.  Do you have
>> the bounding box information for your images (preview-latex takes them
>> from TeX usually)?
>
> No, how should I get it?  I only have PDF/PS or DVI files with no
> sources at all.

I am afraid I can't figure out what you are trying to achieve.  PDF/PS
and DVI files are primarily page-oriented formats.  It does not make
sense to display every page with a different size.  PDF and PS files
can actually change the page format in midstream _if_ that is desired.
Autocropping will complicate the user's handling of page material.
This is different if we are talking about embedded material, graphics
and stuff.  In that case, we will be using PDF (which sets its own
page size) or EPS.  EPS files carry a bounding box comment: extracting
that and using it for setting the rendering bounding box for
Ghostscript should do the trick.

preview-extract-bb in AUCTeX's preview.el can be used for that
purpose.

> If it can be useful if everything I have is the plain document with
> no additional source or infos about included images, then I'll do
> it.
>
> So can it do that?

Can it do what?

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: doc-view.el --- View PDF/PostScript/DVI files in Emacs
  2007-08-26 10:11       ` Tassilo Horn
@ 2007-08-26 22:46         ` Richard Stallman
  0 siblings, 0 replies; 19+ messages in thread
From: Richard Stallman @ 2007-08-26 22:46 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: emacs-devel

    So I think we should lay the inclusion of doc-view.el on ice till I've
    done that.  I'll announce when it's ready to go in.

Ok, I await word.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: doc-view.el --- View PDF/PostScript/DVI files in Emacs
  2007-08-26 20:38             ` David Kastrup
@ 2007-08-27  8:52               ` Tassilo Horn
  2007-08-27 10:23                 ` David Kastrup
  0 siblings, 1 reply; 19+ messages in thread
From: Tassilo Horn @ 2007-08-27  8:52 UTC (permalink / raw)
  To: emacs-devel

David Kastrup <dak@gnu.org> writes:

Hi David,

>>>> I changed doc-view.el so that it uses plain ghostscript (plus
>>>> dvipdfm for DVI files) which gives good results and is about ten
>>>> times faster than with ImageMagick's convert.
>>>>
>>>> The only downside is that I don't know how to cut off the margins.
>>>> Those waste a lot of buffer space when displaying the image.
>>>> converts -trim option was very nice for that cause.  Do you know
>>>> how one can do that with ghostview?
>>>
>>> Well, that is one of the things done in preview-latex.  Do you have
>>> the bounding box information for your images (preview-latex takes
>>> them from TeX usually)?
>>
>> No, how should I get it?  I only have PDF/PS or DVI files with no
>> sources at all.
>
> I am afraid I can't figure out what you are trying to achieve.

Well, when doc-view.el used `convert' I supplied the -trim option to it.
This option cuts off the margins by calculating a mimimum bounding
rectangle around the contents whose outside has background color and
cuts the outside away.

> PDF/PS and DVI files are primarily page-oriented formats.  It does not
> make sense to display every page with a different size.

I don't agree here.  IMO it wastes too much screen estate to display the
margins.  When those were cut off I could split my emacs frame
horizontally and view a PDF doc in one window and have another
80-columns window for work.

Now that's not possible anymore because the images contain those huge
margins.  The only solution is to make the images smaller but that makes
them hard to read.  And I cannot scroll-left to center the image.  Even
`C-u 1 C-x <' scrolls too much.

I think that readability is much more important than displaying a page
exactly as it looks like in xpdf.

> PDF and PS files can actually change the page format in midstream _if_
> that is desired.  Autocropping will complicate the user's handling of
> page material.  This is different if we are talking about embedded
> material, graphics and stuff.  In that case, we will be using PDF
> (which sets its own page size) or EPS.  EPS files carry a bounding box
> comment: extracting that and using it for setting the rendering
> bounding box for Ghostscript should do the trick.
>
> preview-extract-bb in AUCTeX's preview.el can be used for that
> purpose.

Yes, but for other files like PDF or DVI that seems not possible.

Currently I don't really see how preview.el could be useful for
doc-view.  Ok, maybe I could display the first pages before the
conversion of the rest has finished, but with ghostview conversion is so
fast that I don't see any benefit that would justify to make the code
more complex.

For example doc-view on my practicalcommonlisp.pdf which has 528 pages
takes about one minute.  And even this has to be done only one time...

Maybe we confuse each other because we don't see the area of application
correctly.  doc-view.el is intended to view already finished documents
whereas preview.el is intended to view documents you're currently
writing.

So please give some concrete examples how I could enhance doc-view.el
with preview.el.
-- 
Newton's Third  Law is wrong: Although  it states that  for each action,
there is  an equal  and opposite  reaction, there is  no force  equal in
reaction to a Chuck Norris roundhouse kick.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: doc-view.el --- View PDF/PostScript/DVI files in Emacs
  2007-08-27  8:52               ` Tassilo Horn
@ 2007-08-27 10:23                 ` David Kastrup
  2007-08-27 14:37                   ` Tassilo Horn
  0 siblings, 1 reply; 19+ messages in thread
From: David Kastrup @ 2007-08-27 10:23 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: emacs-devel

Tassilo Horn <tassilo@member.fsf.org> writes:

> David Kastrup <dak@gnu.org> writes:
>
> Hi David,
>
>>>>> I changed doc-view.el so that it uses plain ghostscript (plus
>>>>> dvipdfm for DVI files) which gives good results and is about ten
>>>>> times faster than with ImageMagick's convert.
>>>>>
>>>>> The only downside is that I don't know how to cut off the margins.
>>>>> Those waste a lot of buffer space when displaying the image.
>>>>> converts -trim option was very nice for that cause.  Do you know
>>>>> how one can do that with ghostview?
>>>>
>>>> Well, that is one of the things done in preview-latex.  Do you have
>>>> the bounding box information for your images (preview-latex takes
>>>> them from TeX usually)?
>>>
>>> No, how should I get it?  I only have PDF/PS or DVI files with no
>>> sources at all.
>>
>> I am afraid I can't figure out what you are trying to achieve.
>
> Well, when doc-view.el used `convert' I supplied the -trim option to
> it.  This option cuts off the margins by calculating a mimimum
> bounding rectangle around the contents whose outside has background
> color and cuts the outside away.

Sure.  I just think that this is the wrong thing to do for page previews.

>> PDF/PS and DVI files are primarily page-oriented formats.  It does not
>> make sense to display every page with a different size.
>
> I don't agree here.  IMO it wastes too much screen estate to display
> the margins.  When those were cut off I could split my emacs frame
> horizontally and view a PDF doc in one window and have another
> 80-columns window for work.
>
> Now that's not possible anymore because the images contain those
> huge margins.  The only solution is to make the images smaller but
> that makes them hard to read.  And I cannot scroll-left to center
> the image.  Even `C-u 1 C-x <' scrolls too much.

That is an argument for giving better scrolling/margining behavior to
Emacs (you _do_ realize that Emacs can display partial images?).  So
you can add an option for selecting a page area you want to see,
possibly by dragging a rectangle across the image, and then get a
_consistent_ display of margins across your whole document.

>> PDF and PS files can actually change the page format in midstream
>> _if_ that is desired.  Autocropping will complicate the user's
>> handling of page material.  This is different if we are talking
>> about embedded material, graphics and stuff.  In that case, we will
>> be using PDF (which sets its own page size) or EPS.  EPS files
>> carry a bounding box comment: extracting that and using it for
>> setting the rendering bounding box for Ghostscript should do the
>> trick.
>>
>> preview-extract-bb in AUCTeX's preview.el can be used for that
>> purpose.
>
> Yes, but for other files like PDF or DVI that seems not possible.

DVI needs to get converted to PostScript, anyway, doesn't it?

> Currently I don't really see how preview.el could be useful for
> doc-view.  Ok, maybe I could display the first pages before the
> conversion of the rest has finished, but with ghostview conversion
> is so fast that I don't see any benefit that would justify to make
> the code more complex.
>
> For example doc-view on my practicalcommonlisp.pdf which has 528
> pages takes about one minute.  And even this has to be done only one
> time...

preview-latex renders the page you are looking at in a fraction of a
second, even when we are talking about documents with a thousand
pages.  Out of order rendering vastly increases the interactive
response.

> So please give some concrete examples how I could enhance
> doc-view.el with preview.el.

Shrug.  If you don't consider sub-second response times as opposed to
minute delays an enhancement, I am out of my depth guessing what would
qualify as one.

So I am afraid I can't offer anything useful to you.

-- 
David Kastrup

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: doc-view.el --- View PDF/PostScript/DVI files in Emacs
  2007-08-27 10:23                 ` David Kastrup
@ 2007-08-27 14:37                   ` Tassilo Horn
  2007-08-27 15:16                     ` David Kastrup
  2007-08-27 20:17                     ` Stefan Monnier
  0 siblings, 2 replies; 19+ messages in thread
From: Tassilo Horn @ 2007-08-27 14:37 UTC (permalink / raw)
  To: emacs-devel

David Kastrup <dak@gnu.org> writes:

Hi David,

>> I don't agree here.  IMO it wastes too much screen estate to display
>> the margins.  When those were cut off I could split my emacs frame
>> horizontally and view a PDF doc in one window and have another
>> 80-columns window for work.
>>
>> Now that's not possible anymore because the images contain those huge
>> margins.  The only solution is to make the images smaller but that
>> makes them hard to read.  And I cannot scroll-left to center the
>> image.  Even `C-u 1 C-x <' scrolls too much.
>
> That is an argument for giving better scrolling/margining behavior to
> Emacs (you _do_ realize that Emacs can display partial images?).

Not yet, but I'll have a look at how that can be done.  Thanks for the
pointer.

> So you can add an option for selecting a page area you want to see,
> possibly by dragging a rectangle across the image, and then get a
> _consistent_ display of margins across your whole document.

That would be really nice.

>> Currently I don't really see how preview.el could be useful for
>> doc-view.  Ok, maybe I could display the first pages before the
>> conversion of the rest has finished, but with ghostview conversion is
>> so fast that I don't see any benefit that would justify to make the
>> code more complex.
>>
>> For example doc-view on my practicalcommonlisp.pdf which has 528
>> pages takes about one minute.  And even this has to be done only one
>> time...
>
> preview-latex renders the page you are looking at in a fraction of a
> second, even when we are talking about documents with a thousand
> pages.  Out of order rendering vastly increases the interactive
> response.
>
>> So please give some concrete examples how I could enhance doc-view.el
>> with preview.el.
>
> Shrug.  If you don't consider sub-second response times as opposed to
> minute delays an enhancement, I am out of my depth guessing what would
> qualify as one.

The problem is that preview.el is quite complex and till now I don't
have an idea how to use it for my purpose.  And I'm lacking the right
amount of time to study it carefully.

Nevertheless, now doc-view.el can display pages as soon as they're
available, so users can start viewing nearly immediately even if the
file is not in the cache.

Bye,
Tassilo
-- 
In the beginning there was nothing...then Chuck Norris Roundhouse kicked
that nothing in the face and said  "Get a job". That is the story of the
universe.

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: doc-view.el --- View PDF/PostScript/DVI files in Emacs
  2007-08-27 14:37                   ` Tassilo Horn
@ 2007-08-27 15:16                     ` David Kastrup
  2007-08-27 20:14                       ` Tassilo Horn
  2007-08-27 20:17                     ` Stefan Monnier
  1 sibling, 1 reply; 19+ messages in thread
From: David Kastrup @ 2007-08-27 15:16 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: emacs-devel

Tassilo Horn <tassilo@member.fsf.org> writes:

> David Kastrup <dak@gnu.org> writes:
>
> Hi David,
>
>>> I don't agree here.  IMO it wastes too much screen estate to display
>>> the margins.  When those were cut off I could split my emacs frame
>>> horizontally and view a PDF doc in one window and have another
>>> 80-columns window for work.
>>>
>>> Now that's not possible anymore because the images contain those huge
>>> margins.  The only solution is to make the images smaller but that
>>> makes them hard to read.  And I cannot scroll-left to center the
>>> image.  Even `C-u 1 C-x <' scrolls too much.
>>
>> That is an argument for giving better scrolling/margining behavior to
>> Emacs (you _do_ realize that Emacs can display partial images?).
>
> Not yet, but I'll have a look at how that can be done.  Thanks for the
> pointer.

The documentation is somewhat hidden.  Look under
(info "(elisp) Other Display Specs") for the "slice" specification.

-- 
David Kastrup

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: doc-view.el --- View PDF/PostScript/DVI files in Emacs
  2007-08-27 15:16                     ` David Kastrup
@ 2007-08-27 20:14                       ` Tassilo Horn
  2007-08-27 20:31                         ` David Kastrup
  0 siblings, 1 reply; 19+ messages in thread
From: Tassilo Horn @ 2007-08-27 20:14 UTC (permalink / raw)
  To: emacs-devel

David Kastrup <dak@gnu.org> writes:

Hi David,

> The documentation is somewhat hidden.  Look under (info "(elisp) Other
> Display Specs") for the "slice" specification.

That's really nice.  Now one can select the region to display with one
mouse click at the top-left corner and one in the bottom left corner.
But that doesn't work if the window is scrolled up, because the position
in the mouse events is the position in the window (and not the position
in the image).

Any idea how that can be done?

Bye,
Tassilo
-- 
            Wenn Windows die Lösung ist, kann ich dann bitte
                       das Problem zurück haben?

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: doc-view.el --- View PDF/PostScript/DVI files in Emacs
  2007-08-27 14:37                   ` Tassilo Horn
  2007-08-27 15:16                     ` David Kastrup
@ 2007-08-27 20:17                     ` Stefan Monnier
  2007-08-27 20:30                       ` David Kastrup
  1 sibling, 1 reply; 19+ messages in thread
From: Stefan Monnier @ 2007-08-27 20:17 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: emacs-devel

> Nevertheless, now doc-view.el can display pages as soon as they're
> available, so users can start viewing nearly immediately even if the
> file is not in the cache.

I think this is very much good enough for now.  I don't want to wait for
integration with preview.el before integrating it into Emacs.

I do see integration of (some subpart of) the two as a desirable goal, but
that can also be done from within the Emacs repository,


        Stefan

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: doc-view.el --- View PDF/PostScript/DVI files in Emacs
  2007-08-27 20:17                     ` Stefan Monnier
@ 2007-08-27 20:30                       ` David Kastrup
  0 siblings, 0 replies; 19+ messages in thread
From: David Kastrup @ 2007-08-27 20:30 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Tassilo Horn, emacs-devel

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

>> Nevertheless, now doc-view.el can display pages as soon as they're
>> available, so users can start viewing nearly immediately even if the
>> file is not in the cache.
>
> I think this is very much good enough for now.  I don't want to wait
> for integration with preview.el before integrating it into Emacs.

Oh, I was not suggesting integration with preview.el: preview.el is
very much specialized to LaTeX.  I was just suggesting to pick
preview.el for ideas and code fragments.  For example, the Ghostscript
queue management and the display prioritization would seem like good
candidates for stealing: their design and coding took quite a bit of
time.

> I do see integration of (some subpart of) the two as a desirable
> goal, but that can also be done from within the Emacs repository,

It sounds to me like Tassilo addressed some performance/usability
issues already: whether by actually using preview-latex code or by
imitating it or by coopetition: the result is something more useful to
the end user.

But I agree that this can be done from within Emacs CVS as well.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: doc-view.el --- View PDF/PostScript/DVI files in Emacs
  2007-08-27 20:14                       ` Tassilo Horn
@ 2007-08-27 20:31                         ` David Kastrup
  0 siblings, 0 replies; 19+ messages in thread
From: David Kastrup @ 2007-08-27 20:31 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: emacs-devel

Tassilo Horn <tassilo@member.fsf.org> writes:

> David Kastrup <dak@gnu.org> writes:
>
> Hi David,
>
>> The documentation is somewhat hidden.  Look under (info "(elisp) Other
>> Display Specs") for the "slice" specification.
>
> That's really nice.  Now one can select the region to display with one
> mouse click at the top-left corner and one in the bottom left corner.
> But that doesn't work if the window is scrolled up, because the position
> in the mouse events is the position in the window (and not the position
> in the image).
>
> Any idea how that can be done?

posn-object-x-y is a compiled Lisp function in `subr.el'.
(posn-object-x-y POSITION)

Return the x and y coordinates relative to the object of POSITION.
POSITION should be a list of the form returned by the `event-start'
and `event-end' functions.

[back]

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2007-08-27 20:31 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-24 11:03 doc-view.el --- View PDF/PostScript/DVI files in Emacs Tassilo Horn
2007-08-24 11:47 ` Michaël Cadilhac
2007-08-24 15:24   ` Tassilo Horn
2007-08-24 21:42     ` David Kastrup
2007-08-25 17:26       ` Tassilo Horn
2007-08-25 18:34         ` David Kastrup
2007-08-26 10:20           ` Tassilo Horn
2007-08-26 20:38             ` David Kastrup
2007-08-27  8:52               ` Tassilo Horn
2007-08-27 10:23                 ` David Kastrup
2007-08-27 14:37                   ` Tassilo Horn
2007-08-27 15:16                     ` David Kastrup
2007-08-27 20:14                       ` Tassilo Horn
2007-08-27 20:31                         ` David Kastrup
2007-08-27 20:17                     ` Stefan Monnier
2007-08-27 20:30                       ` David Kastrup
2007-08-25 20:52     ` Richard Stallman
2007-08-26 10:11       ` Tassilo Horn
2007-08-26 22:46         ` Richard Stallman

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).