From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: JD Smith Newsgroups: gmane.emacs.devel Subject: Re: mouse.el patch for region tracking Date: Mon, 02 Jan 2006 14:20:58 -0700 Message-ID: <1136236858.14167.86.camel@turtle.as.arizona.edu> References: <87psndut5y.fsf-monnier+emacs@gnu.org> <874q4nwns3.fsf-monnier+emacs@gnu.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-IYr2YMSCgchcoDXVAtD+" X-Trace: sea.gmane.org 1136236951 7073 80.91.229.2 (2 Jan 2006 21:22:31 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 2 Jan 2006 21:22:31 +0000 (UTC) Cc: Andreas Schwab , Stefan Monnier , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jan 02 22:22:25 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EtX8K-0003Q3-QG for ged-emacs-devel@m.gmane.org; Mon, 02 Jan 2006 22:22:25 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EtX9v-0002ih-0U for ged-emacs-devel@m.gmane.org; Mon, 02 Jan 2006 16:24:03 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EtX9k-0002ia-JN for emacs-devel@gnu.org; Mon, 02 Jan 2006 16:23:52 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EtX9j-0002iO-Sg for emacs-devel@gnu.org; Mon, 02 Jan 2006 16:23:52 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EtX9j-0002iL-Pa for emacs-devel@gnu.org; Mon, 02 Jan 2006 16:23:51 -0500 Original-Received: from [128.196.210.37] (helo=nsa5.srv.as.arizona.edu) by monty-python.gnu.org with esmtp (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.34) id 1EtXAq-0005xy-AS for emacs-devel@gnu.org; Mon, 02 Jan 2006 16:25:00 -0500 Original-Received: from biff.as.arizona.edu (biff.as.arizona.edu [128.196.211.142]) by nsa5.srv.as.arizona.edu (8.12.10/8.12.10) with ESMTP id k02LL0km013770 for ; Mon, 2 Jan 2006 14:21:00 -0700 Original-Received: from turtle.as.arizona.edu (IDENT:U2FsdGVkX1+H0w/aLjiWIl+IXsiytjWOHjkwDk8+Puw@turtle.as.arizona.edu [128.196.208.207]) by biff.as.arizona.edu (8.12.8/8.12.8) with ESMTP id k02LKxYG015599; Mon, 2 Jan 2006 14:20:59 -0700 Original-To: "Kim F. Storm" In-Reply-To: X-Mailer: Evolution 2.0.4 (2.0.4-6) X-Scanned-By: MIMEDefang 2.42 X-so-MailScanner-Information: Please contact the ISP for more information X-so-MailScanner: Found to be clean X-so-MailScanner-SpamCheck: so5: not spam, SpamAssassin (score=-0.707, required 8, autolearn=disabled, AWL -0.71) X-so-MailScanner-From: jdsmith@as.arizona.edu 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:48632 Archived-At: --=-IYr2YMSCgchcoDXVAtD+ Content-Type: text/plain Content-Transfer-Encoding: 7bit On Mon, 2006-01-02 at 10:38 +0100, Kim F. Storm wrote: > Stefan Monnier writes: > > > There is another reason to wait for the next event: the selected region is > > highlighted until the next event. Now this is not necessary if > > transient-mark-mode is activated, so your suggestion is that code that wants > > to do something like XEmacs's mouse-track should do > > In any case, JD's patch is good, but there should be some more > commentary to explain the meaning of the HANDLE-TERMINATING-EVENT arg > to mouse-drag-track. Also, we may want to announce this function > somewhere. I've reworked the patch a bit, because I found that the mark was not being set in my previous version. Now I skip only the copy-region and mouse-show-mark stuff, unless the optional argument is passed. This leaves the mark set (which of course is preferred for operating on the region). I also expanded the documentation to mouse-drag-track. The one question remaining is whether it is appropriate to delete the overlay (as I currently do) when transient-mark-mode is nil, and terminating events aren't being processed. This means the highlighted region vanishes just after the drag completes. I checked XEmacs mouse-track, and it works differently: with zmacs- regions on, the overlay disappears only when a new region is started, just like transient-mark-mode. However, with it nil, the overlay still remains until some other event (any event) arrives, yet somehow it's able to allow the drag to complete anyway. I.e., it doesn't block operation on the region, as mouse-drag-region does. I'm not sure how this is achieved, but I think it's the best behavior (most consistent with regular mouse selection). Unfortunately, the way "regular mouse selection" seems to work in Emacs is by using that blocking call to 'mouse-show-mark' to delete the overlay when the next event arrives, which is the behavior this patch is attempting to address. Unless someone can think of a clever way to implement this, I think I can live with the overlay disappearing (or can just (let ((transient- mark-mode t)) and delete it myself as appropriate). Let me know if this looks acceptable and I'll check it in. JD --=-IYr2YMSCgchcoDXVAtD+ Content-Disposition: attachment; filename=mouse_patch_jds2.diff Content-Type: text/x-patch; name=mouse_patch_jds2.diff; charset=iso-8859-1 Content-Transfer-Encoding: 7bit Index: mouse.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/mouse.el,v retrieving revision 1.292 diff -b -c -c -r1.292 mouse.el *** mouse.el 1 Jan 2006 07:55:12 -0000 1.292 --- mouse.el 2 Jan 2006 21:06:17 -0000 *************** *** 765,771 **** (display-buffer (current-buffer))) ;; Give temporary modes such as isearch a chance to turn off. (run-hooks 'mouse-leave-buffer-hook) ! (mouse-drag-region-1 start-event)))) (defun mouse-on-link-p (pos) --- 765,771 ---- (display-buffer (current-buffer))) ;; Give temporary modes such as isearch a chance to turn off. (run-hooks 'mouse-leave-buffer-hook) ! (mouse-drag-track start-event t)))) (defun mouse-on-link-p (pos) *************** *** 865,871 **** (let ((range (mouse-start-end start end mode))) (move-overlay ol (car range) (nth 1 range)))) ! (defun mouse-drag-region-1 (start-event) (mouse-minibuffer-check start-event) (setq mouse-selection-click-count-buffer (current-buffer)) (let* ((original-window (selected-window)) --- 865,879 ---- (let ((range (mouse-start-end start end mode))) (move-overlay ol (car range) (nth 1 range)))) ! (defun mouse-drag-track (start-event &optional handle-terminating-event) ! "Track mouse drags by highlighting area between point and cursor. ! The region will be defined with mark and point. If ! HANDLE-TERMINATING-EVENT is set, after the drag completes, wait ! for and handle an additional terminating event (keypress, etc.), ! delete or copy the selected region to the kill buffer, follow ! links, etc. When HANDLE-TERMINATING-EVENT is nil, returns ! immediately after the drag completes, removing the ! overlay (unless transient mark mode is active)." (mouse-minibuffer-check start-event) (setq mouse-selection-click-count-buffer (current-buffer)) (let* ((original-window (selected-window)) *************** *** 949,959 **** (integer-or-marker-p end-point)) (mouse-move-drag-overlay mouse-drag-overlay start-point end-point click-count)) (if (consp event) (let* ((fun (key-binding (vector (car event)))) (do-multi-click (and (> (event-click-count event) 0) (functionp fun) ! (not (memq fun '(mouse-set-point mouse-set-region)))))) ;; Run the binding of the terminating up-event, if possible. (if (and (not (= (overlay-start mouse-drag-overlay) (overlay-end mouse-drag-overlay))) --- 957,970 ---- (integer-or-marker-p end-point)) (mouse-move-drag-overlay mouse-drag-overlay start-point end-point click-count)) + ;; Handle the terminating event (if (consp event) (let* ((fun (key-binding (vector (car event)))) (do-multi-click (and (> (event-click-count event) 0) (functionp fun) ! (not (memq fun ! '(mouse-set-point ! mouse-set-region)))))) ;; Run the binding of the terminating up-event, if possible. (if (and (not (= (overlay-start mouse-drag-overlay) (overlay-end mouse-drag-overlay))) *************** *** 977,982 **** --- 988,997 ---- last-command this-command) (push-mark region-commencement t t) (goto-char region-termination) + (if (not handle-terminating-event) + ;; Skip all post-event handling, return immediately. + (unless transient-mark-mode + (delete-overlay mouse-drag-overlay)) ;; Don't let copy-region-as-kill set deactivate-mark. (when mouse-drag-copy-region (let (deactivate-mark) *************** *** 989,995 **** ;; avoid trying to use the region. (and (mark t) mark-active (eq buffer (current-buffer)) ! (mouse-set-region-1)))) ;; Run the binding of the terminating up-event. ;; If a multiple click is not bound to mouse-set-point, ;; cancel the effects of mouse-move-drag-overlay to --- 1004,1010 ---- ;; avoid trying to use the region. (and (mark t) mark-active (eq buffer (current-buffer)) ! (mouse-set-region-1))))) ;; Run the binding of the terminating up-event. ;; If a multiple click is not bound to mouse-set-point, ;; cancel the effects of mouse-move-drag-overlay to --=-IYr2YMSCgchcoDXVAtD+ Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --=-IYr2YMSCgchcoDXVAtD+--