unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Mouse Sel mode and mouse-1-click-follows-link
@ 2005-05-08 15:09 Chong Yidong
  2005-05-08 16:55 ` Luc Teirlinck
  0 siblings, 1 reply; 5+ messages in thread
From: Chong Yidong @ 2005-05-08 15:09 UTC (permalink / raw)


I've been working on the "Adapt mouse-sel-mode to
mouse-1-click-follows-link" item in FOR-RELEASE.  I have gotten it to work
for clicking on buttons in *Help* and *Info* buffers.  (Double-clicking is
currently not implemented, and seems difficult to implement given how
Mouse Sel mode works.)

The trouble is, I can't get it to work with *Customize* buffers.  This is
probably due to some widget magic that I'm ignorant of.  Can someone help
me figure it out?  (How does the normal mouse.el stuff deal with
Customize?)  The current patch is below.


*** emacs/lisp/mouse-sel.el~	Tue Apr 26 12:37:38 2005
--- emacs/lisp/mouse-sel.el	Sun May  8 22:52:13 2005
***************
*** 465,474 ****

  This should be bound to a down-mouse event."
    (interactive "@e")
!   (let (direction)
      (unwind-protect
! 	(setq direction (mouse-select-internal 'PRIMARY event))
!       (mouse-sel-primary-to-region direction))))

  (defun mouse-select-secondary (event)
    "Set secondary selection using the mouse.
--- 465,476 ----

  This should be bound to a down-mouse event."
    (interactive "@e")
!   (let (select)
      (unwind-protect
!     	(setq select (mouse-select-internal 'PRIMARY event))
!       (if (and select (listp select))
! 	  (push (cons 'mouse-2 (cdr event)) unread-command-events)
! 	(mouse-sel-primary-to-region select)))))

  (defun mouse-select-secondary (event)
    "Set secondary selection using the mouse.
***************
*** 487,493 ****
    (mouse-select-internal 'SECONDARY event))

  (defun mouse-select-internal (selection event)
!   "Set SELECTION using the mouse."
    (mouse-sel-eval-at-event-end event
      (let ((thing-symbol (mouse-sel-selection-thing selection))
  	  (overlay (mouse-sel-selection-overlay selection)))
--- 489,502 ----
    (mouse-select-internal 'SECONDARY event))

  (defun mouse-select-internal (selection event)
!   "Set SELECTION using the mouse, with EVENT as the initial down-event.
! Normally, this returns the direction in which the selection was
! made: a value of 1 indicates that the mouse was dragged
! left-to-right, otherwise it was dragged right-to-left.
!
! However, if `mouse-1-click-follows-link' is non-nil and the
! subsequent mouse events specify following a link, this returns
! the final mouse-event.  In that case, the selection is not set."
    (mouse-sel-eval-at-event-end event
      (let ((thing-symbol (mouse-sel-selection-thing selection))
  	  (overlay (mouse-sel-selection-overlay selection)))
***************
*** 501,507 ****
  			    (car object-bounds) (cdr object-bounds)
  			    (current-buffer)))
  	  (move-overlay overlay (point) (point) (current-buffer)))))
!     (mouse-extend-internal selection)))

  ;;=== Extend ==============================================================

--- 510,517 ----
  			    (car object-bounds) (cdr object-bounds)
  			    (current-buffer)))
  	  (move-overlay overlay (point) (point) (current-buffer)))))
!     (catch 'follow-link
!       (mouse-extend-internal selection event t))))

  ;;=== Extend ==============================================================

***************
*** 523,533 ****
    (save-window-excursion
      (mouse-extend-internal 'SECONDARY event)))

! (defun mouse-extend-internal (selection &optional initial-event)
    "Extend specified SELECTION using the mouse.
  Track mouse-motion events, adjusting the SELECTION appropriately.
! Optional argument INITIAL-EVENT specifies an initial down-mouse event to
! process.

  See documentation for mouse-select-internal for more details."
    (mouse-sel-eval-at-event-end initial-event
--- 533,544 ----
    (save-window-excursion
      (mouse-extend-internal 'SECONDARY event)))

! (defun mouse-extend-internal (selection &optional initial-event no-process)
    "Extend specified SELECTION using the mouse.
  Track mouse-motion events, adjusting the SELECTION appropriately.
! Optional argument INITIAL-EVENT specifies an initial down-mouse event.
! Optional argument NO-PROCESS means not to process the initial
! event.

  See documentation for mouse-select-internal for more details."
    (mouse-sel-eval-at-event-end initial-event
***************
*** 564,570 ****
  	    ;; Handle dragging
  	    (track-mouse

! 	      (while (if initial-event	; Use initial event
  			 (prog1
  			     (setq event initial-event)
  			   (setq initial-event nil))
--- 575,582 ----
  	    ;; Handle dragging
  	    (track-mouse

! 	      (while (if (and initial-event (not no-process))
! 			 ;; Use initial event
  			 (prog1
  			     (setq event initial-event)
  			   (setq initial-event nil))
***************
*** 643,648 ****
--- 655,664 ----

  		  )))			; end track-mouse

+ 	    ;; Detect follow-link events
+ 	    (when (mouse-follow-link-p initial-event event)
+ 	      (throw 'follow-link event))
+
  	    ;; Finish up after dragging
  	    (let ((overlay-start (overlay-start overlay))
  		  (overlay-end (overlay-end overlay)))
***************
*** 678,683 ****
--- 694,718 ----
  	     (selected-frame) (list (cons 'cursor-type orig-cursor-type))))

  	))))
+
+ (defun mouse-follow-link-p (initial final)
+   "Return t if we should follow a link, given INITIAL and FINAL mouse
events.
+ See `mouse-1-click-follows-link' for details.  Currently, Mouse
+ Sel mode does not support using a `double' value to follow links
+ using double-clicks."
+   (and initial final mouse-1-click-follows-link
+        (eq (car initial) 'down-mouse-1)
+        (mouse-on-link-p	(posn-point (event-start initial)))
+        (= (posn-point (event-start initial))
+ 	  (posn-point (event-end final)))
+        (= (event-click-count initial) 1)
+        (or (not (integerp mouse-1-click-follows-link))
+ 	   (let ((t0 (posn-timestamp (event-start initial)))
+ 		 (t1 (posn-timestamp (event-end final))))
+ 	     (and (integerp t0) (integerp t1)
+ 		  (if (> mouse-1-click-follows-link 0)
+ 		      (<= (- t1 t0) mouse-1-click-follows-link)
+ 		    (< (- t0 t1) mouse-1-click-follows-link)))))))

  ;;=== Paste ===============================================================

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

* Re: Mouse Sel mode and mouse-1-click-follows-link
  2005-05-08 15:09 Mouse Sel mode and mouse-1-click-follows-link Chong Yidong
@ 2005-05-08 16:55 ` Luc Teirlinck
  2005-05-10 15:43   ` Chong Yidong
  0 siblings, 1 reply; 5+ messages in thread
From: Luc Teirlinck @ 2005-05-08 16:55 UTC (permalink / raw)
  Cc: emacs-devel

Chong Yidong wrote:

   The trouble is, I can't get it to work with *Customize* buffers.  This is
   probably due to some widget magic that I'm ignorant of.  Can someone help
   me figure it out?  (How does the normal mouse.el stuff deal with
   Customize?)  The current patch is below.

That is because Custom implements the mouse-1 behavior in a different
way from mouse-1-click-follows-link.

The relevant code for mouse-1 starts at line 4175 in cus-edit-el, in
particular:

     (define-key map [mouse-1] 'Custom-move-and-invoke)

The relevant code for mouse-2 starts is in wid-edit.el in particular:

    (define-key map [down-mouse-2] 'widget-button-click)

(All assuming I understood correctly.)

I believe that the best solution might be to get rid of the mouse-1
binding and use the follow-link property to implement the mouse-1
behavior in Custom, as is done elsewhere.

Sincerely,

Luc.

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

* Re: Mouse Sel mode and mouse-1-click-follows-link
  2005-05-08 16:55 ` Luc Teirlinck
@ 2005-05-10 15:43   ` Chong Yidong
  2005-05-11 12:40     ` Kim F. Storm
  2005-05-11 16:27     ` Richard Stallman
  0 siblings, 2 replies; 5+ messages in thread
From: Chong Yidong @ 2005-05-10 15:43 UTC (permalink / raw)


>    The trouble is, I can't get it to work with *Customize* buffers.
>    This is probably due to some widget magic that I'm ignorant of.  Can
>    someone help me figure it out?
>
> That is because Custom implements the mouse-1 behavior in a different
> way from mouse-1-click-follows-link.
>
> I believe that the best solution might be to get rid of the mouse-1
> binding and use the follow-link property to implement the mouse-1
> behavior in Custom, as is done elsewhere.

I don't know enough about the widget library to have an opinion on
changing it.  Come to think of it, does mouse-1 on custom widgets work
with mouse-sel-mode in Emacs 21?  I suspect that it doesn't, but I can't
check right now.  If it's never worked, then maybe it's not so important
to fix it for the release.

The patch I posted does at least adapt mouse-sel-mode to
mouse-1-click-follows-link, so Info and Help buffers will work.  If
someone could review it and check it in, that would be great.

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

* Re: Mouse Sel mode and mouse-1-click-follows-link
  2005-05-10 15:43   ` Chong Yidong
@ 2005-05-11 12:40     ` Kim F. Storm
  2005-05-11 16:27     ` Richard Stallman
  1 sibling, 0 replies; 5+ messages in thread
From: Kim F. Storm @ 2005-05-11 12:40 UTC (permalink / raw)
  Cc: emacs-devel

"Chong Yidong" <cyd@stupidchicken.com> writes:

> The patch I posted does at least adapt mouse-sel-mode to
> mouse-1-click-follows-link, so Info and Help buffers will work.  If
> someone could review it and check it in, that would be great.

I installed your patch, thanks.

I renamed mouse-follow-link-p to mouse-sel-follow-link-p.

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

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

* Re: Mouse Sel mode and mouse-1-click-follows-link
  2005-05-10 15:43   ` Chong Yidong
  2005-05-11 12:40     ` Kim F. Storm
@ 2005-05-11 16:27     ` Richard Stallman
  1 sibling, 0 replies; 5+ messages in thread
From: Richard Stallman @ 2005-05-11 16:27 UTC (permalink / raw)
  Cc: emacs-devel

    The patch I posted does at least adapt mouse-sel-mode to
    mouse-1-click-follows-link, so Info and Help buffers will work.  If
    someone could review it and check it in, that would be great.

I agree.  Fixing Custom is a separate matter.

The code in Custom was implemented long ago.
Now that we have mouse-1-click-follows-link,
it would probably be a simplification to make Custom
work with that.  It could just define Mouse-2
and allow mouse-1-click-follows-link to handle Mouse-1.

So would people please look at the patch you sent,
and maybe install it?

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

end of thread, other threads:[~2005-05-11 16:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-08 15:09 Mouse Sel mode and mouse-1-click-follows-link Chong Yidong
2005-05-08 16:55 ` Luc Teirlinck
2005-05-10 15:43   ` Chong Yidong
2005-05-11 12:40     ` Kim F. Storm
2005-05-11 16:27     ` 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).