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: Tassilo Horn
Subject: Re: doc-view.el ready for inclusion now
Date: Tue, 28 Aug 2007 12:25:21 +0200
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.1.50 (gnu/linux)

David Kastrup <address@hidden> writes:

Hi David,

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

Ok, I removed that.

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

Ok, now I use those and removed most checks.  If the user doesn't click
the image the results may be undesired, but he can easily revert them
with `s r'.

And now it uses dragging.  You press mouse-1 at the top-left corner and
release it at the bottom-left corner.  I think that's more intuitive
than two clicks.

There's only one little thing that could be better.  If the image is
bigger than the screen, it would be superb if the visible part of the
buffer would follow the mouse while dragging.  Currently you cannot use
the mouse slicing when one of the corners isn't visible.

Can that be done somehow?

Bye,
Tassilo

Attachment: doc-view.el
Description: doc-view.el (new mouse slicing behavior)


reply via email to

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