From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Chong Yidong" Newsgroups: gmane.emacs.devel Subject: Mouse Sel mode and mouse-1-click-follows-link Date: Sun, 8 May 2005 11:09:53 -0400 (EDT) Message-ID: <1446.220.255.40.146.1115564993.squirrel@220.255.40.146> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1115565010 499 80.91.229.2 (8 May 2005 15:10:10 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 8 May 2005 15:10:10 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun May 08 17:10:07 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DUnPj-0002rC-2V for ged-emacs-devel@m.gmane.org; Sun, 08 May 2005 17:09:51 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DUnXr-0000hL-Rh for ged-emacs-devel@m.gmane.org; Sun, 08 May 2005 11:18:15 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DUnV0-00088y-JF for emacs-devel@gnu.org; Sun, 08 May 2005 11:15:19 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DUnUq-000847-Ql for emacs-devel@gnu.org; Sun, 08 May 2005 11:15:09 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DUnUn-0007wZ-Ny for emacs-devel@gnu.org; Sun, 08 May 2005 11:15:05 -0400 Original-Received: from [64.21.80.18] (helo=shark.dnsvelocity.com) by monty-python.gnu.org with esmtp (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.34) id 1DUnVs-00076q-PA for emacs-devel@gnu.org; Sun, 08 May 2005 11:16:14 -0400 Original-Received: from stupidch by shark.dnsvelocity.com with local (Exim 4.50) id 1DUnPl-00081o-Uk for emacs-devel@gnu.org; Sun, 08 May 2005 11:09:54 -0400 Original-Received: from 220.255.40.146 ([220.255.40.146]) (SquirrelMail authenticated user cyd@stupidchicken.com); by www.stupidchicken.com with HTTP; Sun, 8 May 2005 11:09:53 -0400 (EDT) Original-To: emacs-devel@gnu.org User-Agent: SquirrelMail/1.4.3a X-Mailer: SquirrelMail/1.4.3a X-Priority: 3 (Normal) Importance: Normal X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - shark.dnsvelocity.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [32675 33085] / [47 12] X-AntiAbuse: Sender Address Domain - stupidchicken.com X-Source: /usr/local/cpanel/3rdparty/bin/php X-Source-Args: /usr/local/cpanel/3rdparty/bin/php /usr/local/cpanel/base/3rdparty/squirrelmail/src/compose.php X-Source-Dir: :/base/3rdparty/squirrelmail/src X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:36860 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:36860 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 ===============================================================