emacs-pretest-bug
[Top][All Lists]
Advanced

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

RE: moving overlay loses its priority?


From: Drew Adams
Subject: RE: moving overlay loses its priority?
Date: Sat, 12 Aug 2006 17:41:50 -0700

Sorry for forgetting to add this:

#1 is true also for Emacs 20: the mouse-face text property is inhibited over
the entire link by applying the overlay to just one character in the link.

#2, however, is not a problem in Emacs 20. This is the main reason I
reported a bug: the tracking doesn't work in a link. In Emacs 20, it works
perfectly, even within a link.

Thx - Drew

>  -----Original Message-----
> From:         Drew Adams [mailto:address@hidden 
> Sent: Saturday, August 12, 2006 5:34 PM
> To:   Emacs-Pretest-Bug
> Subject:      moving overlay loses its priority?
> 
> I'm not sure this is a bug. It might be user ignorance.
> 
> I have an overlay that has priority 1000000. It has both a face and a
> mouse-face property. When I place it over a face, it shows up. When I
> place it over a mouse-face (e.g. a link in Info), it shows up also
> (takes precedence over the link mouse-face), but I notice two things,
> which I don't understand:
> 
> 1. If applied to just part of some text that has a mouse-face text
>    property, it takes precedence over the entire string of text with
>    that property, not just over the part that has the overlay.
> 
> 2. If I move the overlay slightly, then it no longer has precedence -
>    the text's mouse-face shows again.
> 
> Recipe:
> 
> 1. emacs -Q
> 2. Load the code below.
> 3. C-h i, and enter some Info manual.
> 
> 4. Press and hold mouse-2 on some text in the buffer. You'll see that
>    as long as mouse-2 remains pressed, the red overlay is shown over
>    the yank-position character. Even if you move the mouse, as long as
>    mouse-2 remains pressed, the overlay moves with the mouse position.
> 
> 5. Press and hold mouse-2 over an Info link. You should see the same
>    behavior as with text, because the overlay has identical face and
>    mouse-face properties.
> 
> What you in fact see is this:
> 
> 1. The overlay shows on the yank-position character when you first
>    press mouse-2, but the entire link mouse-face highlighting
>    disappears. That is, there is no highlighting on the link, except
>    for the red mouse-2 highlighting of the yank position. I don't
>    understand why this happens.
> 
> 2. If you move the mouse within the link, keeping mouse-2 pressed, the
>    text's mouse-face comes back over the entire link - there is no
>    tracking of the yank position with the red mouse-face overlay.
> 
> The code for mouse-flash-position and mouse-flash-posn-track was
> inspired from mouse-drag-region and mouse-drag-track, respectively. I
> don't think there is anything in their code that would cause this
> behavior, but I'm not 100% sure.
> 
> Is this a bug? If not, can you perhaps point out my misunderstanding?
> Thx.
> 
> -------------8<--------------------------
> 
> (global-set-key [down-mouse-2] 'mouse-flash-position)
> 
> (defface mouse-flash-position '((t (:background "Red")))
>   "*Face used to highlight mouse position temporarily."
>   :group 'mouse)
> 
> (defconst mouse-flash-posn-overlay
>     ;; Create and immediately delete, to get "overlay in no buffer".
>   (let ((ol (make-overlay (point-min) (point-min))))
>     (delete-overlay ol)
>     (overlay-put ol 'face 'mouse-flash-position)
>     (overlay-put ol 'mouse-face 'mouse-flash-position)
>     (overlay-put ol 'priority 1000000)
>     ol)
>   "Overlay to highlight current mouse position.")
> 
> (defun mouse-move-flash-posn-overlay (ol start end)
>   "Move `mouse-flash-posn-overlay' to position END.
> START is the position of the start of the current drag operation."
>   (unless (= start end)
>     ;; Go to START first, so that when we move to END, if it's in the
> middle
>     ;; of intangible text, point jumps in the direction away from START.
>     ;; Don't do it if START=END, otherwise a single click risks selecting
>     ;; a region if it's on intangible text.  This exception was originally
>     ;; only applied on entry to mouse-drag-region, which had the problem
>     ;; that a tiny move during a single-click would cause the intangible
>     ;; text to be selected.
>     (goto-char start)
>     (goto-char end)
>     (setq end (point)))
>   (move-overlay ol end (min (point-max) (1+ end))))
> 
> ;; Inspired from `mouse-drag-region'.
> ;;;###autoload
> (defun mouse-flash-position (start-event)
>   "Highlight the mouse position as you drag the mouse.
> This must be bound to a button-down mouse event.  If you bind this to
> `down-mouse-2', and `mouse-2' is bound to `mouse-yank-at-click' (the
> default), then the yank occurs just before the highlighted character.
> 
> If you want to prevent the `mouse-2' up-button yank from taking place,
> perhaps because you changed your mind, you can press and hold `C-g'
> while releasing the mouse button (press `mouse-2'; drag; press `C-g';
> release `mouse-2'; release `C-g')."
>   (interactive "e")
>   (run-hooks 'mouse-leave-buffer-hook)  ; Let temporary modes such as
> isearch turn off.
>   (mouse-flash-posn-track start-event))
> 
> (defun mouse-flash-posn-track (start-event)
>   "Track mouse drags by highlighting the mouse position"
>   (mouse-minibuffer-check start-event)
>   (let* ((original-window (selected-window))
>          (echo-keystrokes 0)
>        (start-posn (event-start start-event))
>        (start-point (posn-point start-posn))
>        (start-window (posn-window start-posn))
>        (start-window-start (window-start start-window))
>        (start-hscroll (window-hscroll start-window))
>        (bounds (window-edges start-window))
>        (make-cursor-line-fully-visible nil)
>        (top (nth 1 bounds))
>        (bottom (if (window-minibuffer-p start-window)
>                    (nth 3 bounds)
>                  (1- (nth 3 bounds))))) ; 1-: Don't count the mode line.
>     (mouse-move-flash-posn-overlay mouse-flash-posn-overlay start-point
> start-point)
>     (overlay-put mouse-flash-posn-overlay 'window start-window)
>     (deactivate-mark)
>     (unwind-protect
>          (let (event end end-point last-end-point)
>            (track-mouse
>              (while (progn (setq event (read-event))
>                            (or (mouse-movement-p event)
>                                (memq (car-safe event) '(switch-frame
> select-window))))
>                (unless (memq (car-safe event) '(switch-frame
> select-window))
>                  (setq end (event-end event)
>                        end-point (posn-point end))
>                  (when (numberp end-point) (setq last-end-point
> end-point))
>                  (cond
>                    ((and (eq (posn-window end) start-window) ; Moving
> within original window.
>                          (integer-or-marker-p end-point))
>                     (mouse-move-flash-posn-overlay
> mouse-flash-posn-overlay
>                                                    start-point end-point))
>                    (t
>                     (let ((mouse-row (cddr (mouse-position))))
>                       (cond
>                         ((null mouse-row))
>                         ((< mouse-row top)
>                          (mouse-scroll-subr start-window (- mouse-row top)
>                                             mouse-flash-posn-overlay
> start-point))
>                         ((>= mouse-row bottom)
>                          (mouse-scroll-subr start-window (1+ (- mouse-row
> bottom))
>                                             mouse-flash-posn-overlay
> start-point)))))))))
>            ;; In case we did not get a mouse-motion event for the final
> move of
>            ;; the mouse before a drag event, pretend that we did get one.
>            (when (and (memq 'drag (event-modifiers (car-safe event)))
>                       (setq end (event-end event)  end-point (posn-point
> end))
>                       (eq (posn-window end) start-window)
>                       (integer-or-marker-p end-point))
>              (mouse-move-flash-posn-overlay mouse-flash-posn-overlay
> start-point end-point))
>            (when (consp event)          ; Handle the terminating event.
>              (let ((fun (key-binding (vector (car event)))))
>                ;; Run the binding of the terminating up-event, if
> possible.
>                (let* ((stop-point (if (numberp (posn-point (event-end
> event)))
>                                       (posn-point (event-end event))
>                                     last-end-point))
>                       (drag-end (if (and stop-point (< stop-point
> start-point))
>                                     (overlay-start
> mouse-flash-posn-overlay)
>                                   (overlay-end mouse-flash-posn-overlay)))
>                       (drag-start (- (+ (overlay-end
> mouse-flash-posn-overlay)
>                                         (overlay-start
> mouse-flash-posn-overlay))
>                                      drag-end))
>                       last-command this-command)
>                  (delete-overlay mouse-flash-posn-overlay)
>                  (when (and (= start-hscroll (window-hscroll
> start-window))
>                             (or end-point
>                                 (= (window-start start-window)
> start-window-start)))
>                    (push event unread-command-events))))))
>       (delete-overlay mouse-flash-posn-overlay))))
> 
> -------------8<--------------------------
> 
> 
> 
> 
> 
> In GNU Emacs 22.0.50.1 (i386-msvc-nt5.1.2600)
>  of 2006-07-19 on BOS-CTHEWLAP2
> X server distributor `Microsoft Corp.', version 5.1.2600
> configured using `configure --with-msvc (12.00)'
> 
> Important settings:
>   value of $LC_ALL: nil
>   value of $LC_COLLATE: nil
>   value of $LC_CTYPE: nil
>   value of $LC_MESSAGES: nil
>   value of $LC_MONETARY: nil
>   value of $LC_NUMERIC: nil
>   value of $LC_TIME: nil
>   value of $LANG: ENU
>   locale-coding-system: cp1252
>   default-enable-multibyte-characters: t
> 
> Major mode: Info
> 
> Minor modes in effect:
>   encoded-kbd-mode: t
>   tooltip-mode: t
>   tool-bar-mode: t
>   mouse-wheel-mode: t
>   menu-bar-mode: t
>   file-name-shadow-mode: t
>   global-font-lock-mode: t
>   font-lock-mode: t
>   blink-cursor-mode: t
>   unify-8859-on-encoding-mode: t
>   utf-translate-cjk-mode: t
>   auto-compression-mode: t
>   line-number-mode: t
> 
> Recent input:
> <mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1> <mouse-1> 
> <mouse-1> <mouse-1> <mouse-1> <down-mouse-1> <mouse-1> 
> <help-echo> <down-mouse-1> <down-mouse-1> <mouse-1> 
> C-x 1 u <help-echo> <down-mouse-1> <mouse-1> C-x b 
> <return> M-x r e v e r t - b u <return> y e s <return> 
> C-M-x C-h i <help-echo> <down-mouse-2> <help-echo> 
> <help-echo> <help-echo> <help-echo> <help-echo> C-g 
> C-g <C-drag-mouse-2> C-g C-g C-g C-g C-g C-g C-g C-g 
> C-g C-g C-g C-g <help-echo> <help-echo> <help-echo> 
> <down-mouse-2> <help-echo> C-g <C-drag-mouse-2> C-g 
> C-g C-g C-g <help-echo> C-g <help-echo> C-g <help-echo> 
> C-g C-g C-g C-g C-g C-g C-g C-g C-g C-g C-g <help-echo> 
> <help-echo> <help-echo> <help-echo> <help-echo> <help-echo> 
> <menu-bar> <help-menu> <report-emacs-bug>
> 
> Recent messages:
> Resetting customization items...done
> Creating customization setup...done
> Loading info...done
> Composing main Info directory...done
> Mark set
> mouse-flash-position
> Quit [32 times]
> mouse-flash-posn-overlay
> Quit [32 times]
> Loading emacsbug...done

<<attachment: winmail.dat>>


reply via email to

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