/[emacs]/emacs/lisp/mouse-sel.el
ViewVC logotype

Diff of /emacs/lisp/mouse-sel.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.43 by monnier, Thu Oct 28 23:34:51 2004 UTC revision 1.44 by kfstorm, Wed May 11 12:33:44 2005 UTC
# Line 465  Clicking mouse-1 or mouse-3 kills the se Line 465  Clicking mouse-1 or mouse-3 kills the se
465    
466  This should be bound to a down-mouse event."  This should be bound to a down-mouse event."
467    (interactive "@e")    (interactive "@e")
468    (let (direction)    (let (select)
469      (unwind-protect      (unwind-protect
470          (setq direction (mouse-select-internal 'PRIMARY event))          (setq select (mouse-select-internal 'PRIMARY event))
471        (mouse-sel-primary-to-region direction))))        (if (and select (listp select))
472              (push (cons 'mouse-2 (cdr event)) unread-command-events)
473            (mouse-sel-primary-to-region select)))))
474    
475  (defun mouse-select-secondary (event)  (defun mouse-select-secondary (event)
476    "Set secondary selection using the mouse.    "Set secondary selection using the mouse.
# Line 487  This should be bound to a down-mouse eve Line 489  This should be bound to a down-mouse eve
489    (mouse-select-internal 'SECONDARY event))    (mouse-select-internal 'SECONDARY event))
490    
491  (defun mouse-select-internal (selection event)  (defun mouse-select-internal (selection event)
492    "Set SELECTION using the mouse."    "Set SELECTION using the mouse, with EVENT as the initial down-event.
493    Normally, this returns the direction in which the selection was
494    made: a value of 1 indicates that the mouse was dragged
495    left-to-right, otherwise it was dragged right-to-left.
496    
497    However, if `mouse-1-click-follows-link' is non-nil and the
498    subsequent mouse events specify following a link, this returns
499    the final mouse-event.  In that case, the selection is not set."
500    (mouse-sel-eval-at-event-end event    (mouse-sel-eval-at-event-end event
501      (let ((thing-symbol (mouse-sel-selection-thing selection))      (let ((thing-symbol (mouse-sel-selection-thing selection))
502            (overlay (mouse-sel-selection-overlay selection)))            (overlay (mouse-sel-selection-overlay selection)))
# Line 501  This should be bound to a down-mouse eve Line 510  This should be bound to a down-mouse eve
510                              (car object-bounds) (cdr object-bounds)                              (car object-bounds) (cdr object-bounds)
511                              (current-buffer)))                              (current-buffer)))
512            (move-overlay overlay (point) (point) (current-buffer)))))            (move-overlay overlay (point) (point) (current-buffer)))))
513      (mouse-extend-internal selection)))      (catch 'follow-link
514          (mouse-extend-internal selection event t))))
515    
516  ;;=== Extend ==============================================================  ;;=== Extend ==============================================================
517    
# Line 523  This should be bound to a down-mouse eve Line 533  This should be bound to a down-mouse eve
533    (save-window-excursion    (save-window-excursion
534      (mouse-extend-internal 'SECONDARY event)))      (mouse-extend-internal 'SECONDARY event)))
535    
536  (defun mouse-extend-internal (selection &optional initial-event)  (defun mouse-extend-internal (selection &optional initial-event no-process)
537    "Extend specified SELECTION using the mouse.    "Extend specified SELECTION using the mouse.
538  Track mouse-motion events, adjusting the SELECTION appropriately.  Track mouse-motion events, adjusting the SELECTION appropriately.
539  Optional argument INITIAL-EVENT specifies an initial down-mouse event to  Optional argument INITIAL-EVENT specifies an initial down-mouse event.
540  process.  Optional argument NO-PROCESS means not to process the initial
541    event.
542    
543  See documentation for mouse-select-internal for more details."  See documentation for mouse-select-internal for more details."
544    (mouse-sel-eval-at-event-end initial-event    (mouse-sel-eval-at-event-end initial-event
# Line 564  See documentation for mouse-select-inter Line 575  See documentation for mouse-select-inter
575              ;; Handle dragging              ;; Handle dragging
576              (track-mouse              (track-mouse
577    
578                (while (if initial-event  ; Use initial event                (while (if (and initial-event (not no-process))
579                             ;; Use initial event
580                           (prog1                           (prog1
581                               (setq event initial-event)                               (setq event initial-event)
582                             (setq initial-event nil))                             (setq initial-event nil))
# Line 643  See documentation for mouse-select-inter Line 655  See documentation for mouse-select-inter
655    
656                    )))                   ; end track-mouse                    )))                   ; end track-mouse
657    
658                ;; Detect follow-link events
659                (when (mouse-sel-follow-link-p initial-event event)
660                  (throw 'follow-link event))
661    
662              ;; Finish up after dragging              ;; Finish up after dragging
663              (let ((overlay-start (overlay-start overlay))              (let ((overlay-start (overlay-start overlay))
664                    (overlay-end (overlay-end overlay)))                    (overlay-end (overlay-end overlay)))
# Line 679  See documentation for mouse-select-inter Line 695  See documentation for mouse-select-inter
695    
696          ))))          ))))
697    
698    (defun mouse-sel-follow-link-p (initial final)
699      "Return t if we should follow a link, given INITIAL and FINAL mouse events.
700    See `mouse-1-click-follows-link' for details.  Currently, Mouse
701    Sel mode does not support using a `double' value to follow links
702    using double-clicks."
703      (and initial final mouse-1-click-follows-link
704           (eq (car initial) 'down-mouse-1)
705           (mouse-on-link-p (posn-point (event-start initial)))
706           (= (posn-point (event-start initial))
707              (posn-point (event-end final)))
708           (= (event-click-count initial) 1)
709           (or (not (integerp mouse-1-click-follows-link))
710               (let ((t0 (posn-timestamp (event-start initial)))
711                     (t1 (posn-timestamp (event-end final))))
712                 (and (integerp t0) (integerp t1)
713                      (if (> mouse-1-click-follows-link 0)
714                          (<= (- t1 t0) mouse-1-click-follows-link)
715                        (< (- t0 t1) mouse-1-click-follows-link)))))))
716    
717  ;;=== Paste ===============================================================  ;;=== Paste ===============================================================
718    
719  (defun mouse-insert-selection (event arg)  (defun mouse-insert-selection (event arg)

Legend:
Removed from v.1.43  
changed lines
  Added in v.1.44

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26