emacs-devel
[Top][All Lists]
Advanced

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

Re: doc-view.el ready for inclusion now


From: David Kastrup
Subject: Re: doc-view.el ready for inclusion now
Date: Tue, 28 Aug 2007 10:06:52 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux)

Tassilo Horn <address@hidden> writes:

> Hi all,
>
> doc-view.el is ready for inclusion now.
>
> Since the last posting the following things have changed:
>
>   - Now it uses plain GhostScript (plus dvipdfm for DVI files) which
>     makes it about ten times faster than the old version that used
>     ImageMagick's convert.
>
>   - The first page gets displayed as soon as it is available and every
>     few seconds the available pages are refreshed.  This can be
>     suppressed with an option.
>
>   - You can set the region (slice) of the image that should be
>     displayed.  This allows cutting off the margins to save some display
>     space.

The following code is rather ugly:

   (track-mouse
      (let (a b)
        (while (not a)
          (let ((e (read-event "Click on the top-left corner!")))
            (when (and (listp e)
                       (eq (car e) 'mouse-1)   ;; Button 1 clicked...
                       (nth 7 (cadr e))        ;; ...on an image...
                       (string-match           ;; ...in the current...
                        (concat "\\*DocView: " ;; ...doc-view buffer.
                                (regexp-quote doc-view-current-doc))
                        (buffer-name (window-buffer (car (cadr e))))))
              (setq x (car (posn-object-x-y (cadr e))))
              (setq y (cdr (posn-object-x-y (cadr e))))
              (setq a t))))
        (while (not b)
          (let ((e (read-event "Click on the bottom-right corner!")))
            (when (and (listp e)
                       (eq (car e) 'mouse-1)   ;; Button 1 clicked...
                       (nth 7 (cadr e))        ;; ...on an image...
                       (string-match           ;; ...in the current...
                        (concat "\\*DocView: " ;; ...doc-view buffer.
                                (regexp-quote doc-view-current-doc))
                        (buffer-name (window-buffer (car (cadr e))))))
              (setq w (- (car (posn-object-x-y (cadr e))) x))
              (setq h (- (cdr (posn-object-x-y (cadr e))) y))
              (setq b t))))))

First, you call track-mouse, but actually never use it.  Its purpose
is to deliver "mouse-movement" events which could be used for showing
the selected rectangle (if one finds a suitable combination of borders
and stuff useful for that) while it is not yet fixed.  As long as you
don't actually do anything of the sort, it only causes useless CPU
cycles.  And then you should pick events read with "read-event" apart
by using event-start, event-end and similar: that makes the code safer
for future uses and more readable.

-- 
David Kastrup




reply via email to

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