unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* mouse.el patch for region tracking
@ 2005-12-31  7:00 JD Smith
  2005-12-31 15:13 ` Chong Yidong
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: JD Smith @ 2005-12-31  7:00 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1599 bytes --]


Recently I found that Emacs 22 breaks a simple usage of mouse-drag- 
region for defining regions by mouse drag.  When transient-mark-mode  
is set, mouse-drag-region under Emacs 21 would let you define a  
region by dragging, and when the drag is released, it completes (at  
which point you can operate on the region).  This is somewhat similar  
to the XEmacs function 'mouse-track'.

With Emacs 22, several changes were introduced to mouse-drag-region  
(unrelated improvements) which broke this apparently unsupported  
usage.  This breaks a very useful drag-to-inspect functionality in my  
IDLWAVE programming mode.  The call to mouse-drag-region would not  
complete without an additional event after the drag completes.

Since I want all the rich behavior of mouse-drag-region (double- and  
triple-click select by word and line, etc.), a very simple fix is to  
re-christen 'mouse-drag-region-1' as 'mouse-drag-track', and provide  
it an optional argument to enable calling the final event handling  
code which was tripping me up.  Then I can use this functio

I have to admit having understood little of the code I've wrapped in  
'handle-terminating-event', only that it indirectly calls read-event  
via 'mouse-show-mark' and thus blocks the return of the function,  
thus breaking of my old use of mouse-drag-region.  I would appreciate  
it if you could look this over and see if it's doing what I want it  
to (inasmuch as I've communicated that).  In particular the doc  
string is a bit weak if this function were to be advertised for more  
general usage by programmers.

JD

  

[-- Attachment #2: mouse_patch_jds.diff --]
[-- Type: application/octet-stream, Size: 2708 bytes --]

*** mouse.el	27 Dec 2005 20:19:29 -0700	1.290
--- mouse.el	30 Dec 2005 21:20:28 -0700	
***************
*** 758,764 ****
  	  (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)
--- 758,764 ----
  	  (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)
***************
*** 858,864 ****
    (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))
--- 858,865 ----
    (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."
    (mouse-minibuffer-check start-event)
    (setq mouse-selection-click-count-buffer (current-buffer))
    (let* ((original-window (selected-window))
***************
*** 942,948 ****
  		 (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)
--- 943,949 ----
  		 (integer-or-marker-p end-point))
          (mouse-move-drag-overlay mouse-drag-overlay start-point end-point click-count))
  
!       (if (and (consp event) handle-terminating-event)
  	  (let* ((fun (key-binding (vector (car event))))
  		 (do-multi-click   (and (> (event-click-count event) 0)
  					(functionp fun)
***************
*** 1030,1036 ****
  
          ;; Case where the end-event is not a cons cell (it's just a boring
          ;; char-key-press).
! 	(delete-overlay mouse-drag-overlay)))))
  \f
  ;; Commands to handle xterm-style multiple clicks.
  (defun mouse-skip-word (dir)
--- 1031,1039 ----
  
          ;; Case where the end-event is not a cons cell (it's just a boring
          ;; char-key-press).
! 	(unless (and transient-mark-mode 
! 		     (consp event))
! 	  (delete-overlay mouse-drag-overlay))))))
  \f
  ;; Commands to handle xterm-style multiple clicks.
  (defun mouse-skip-word (dir)

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

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

end of thread, other threads:[~2006-01-03 17:25 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-31  7:00 mouse.el patch for region tracking JD Smith
2005-12-31 15:13 ` Chong Yidong
2005-12-31 19:19   ` JD Smith
2005-12-31 15:45 ` Andreas Schwab
2005-12-31 16:38   ` Stefan Monnier
2006-01-01 22:48     ` Kim F. Storm
2006-01-01 23:09       ` Stefan Monnier
2006-01-02  9:38         ` Kim F. Storm
2006-01-02 21:20           ` JD Smith
2006-01-03  1:45             ` Stefan Monnier
2006-01-03  4:40               ` JD Smith
2006-01-03 15:37                 ` Stefan Monnier
2006-01-03 17:25                   ` JD Smith
2006-01-01  2:15 ` Richard M. 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).