>>>> "Ray" == Raymond Toy
<toy.raymond(a)gmail.com> writes:
>>>> "Mats" == Mats Lidell
<matsl(a)xemacs.org> writes:
Mats> Hi,
>>>> Michael Sperber writes:
>> FWIW, my list so far has this:
>>
>> User-visible features: [...]
>> - C-Left Mouse for pasting
Mats> This is one really nice feature that I not only miss in GNU
Mats> Emacs but in other tools as well.
Ray> Can't that be done with a bit of elisp?
Ray> -- Ray
Hi,
this works for me. Hacked it together today after reading this
thread. Nifty feature. Strangely enough, I never knew about
`mouse-track-insert' when I was using XEmacs.
Hope this is useful
Toto
(defvar old-point nil)
(defvar old-mark nil)
(defvar old-buffer nil)
(defun mouse-drag-region-insert (start-event)
"This is a hack! Adapted from `mouse-drag-region' to implement
the functionality of the XEmacs function `mouse-track-insert':
\"Make a selection with the mouse and insert it at point.\"
Set the region to the text that the mouse is dragged over.
Highlight the drag area as you move the mouse. This must be
bound to a button-down mouse event. In Transient Mark mode, the
highlighting remains as long as the mark remains active.
Otherwise, it remains until the next input event.
Safes point and mark of current buffer so that they can be
restored in `mouse-set-region-insert'."
(interactive "e")
(setq old-point (point-marker))
(setq old-mark (mark-marker))
(setq old-buffer (current-buffer))
(mouse-drag-region start-event))
(defun mouse-set-region-insert (click)
"This is a hack! Adapted from `mouse-set-region' to implement
the functionality of the XEmacs function `mouse-track-insert':
\"Make a selection with the mouse and insert it at point.\"
Set the region to the text dragged over, copy to kill ring (the
`mouse-drag-copy-region' variable is lambda-bound for the
duration of this call) and yank it at point in the buffer active
before marking the region with the mouse. This should be bound
to a mouse drag event."
(interactive "e")
(let ((mouse-drag-copy-region t))
;; copied from `mouse-set-region'
(mouse-minibuffer-check click)
(select-window (posn-window (event-start click)))
(let ((beg (posn-point (event-start click)))
(end (posn-point (event-end click))))
(and mouse-drag-copy-region (integerp beg) (integerp end)
;; Don't set this-command to `kill-region', so a following
;; C-w won't double the text in the kill ring. Ignore
;; `last-command' so we don't append to a preceding kill.
(let (this-command last-command deactivate-mark)
(copy-region-as-kill beg end)))
(if (numberp beg) (goto-char beg))
;; On a text terminal, bounce the cursor.
(or transient-mark-mode
(window-system)
(sit-for 1))
(push-mark)
(set-mark (point))
(if (numberp end) (goto-char end))
(mouse-set-region-1)))
;; copied code from `mouse-set-region' ends here
;; adapted from `mouse-yank-at-click'
(let ((mouse-yank-at-point t))
;; Give temporary modes such as isearch a chance to turn off.
(run-hooks 'mouse-leave-buffer-hook)
(when select-active-regions
;; Without this, confusing things happen upon e.g. inserting into
;; the middle of an active region.
(deactivate-mark))
(set-buffer (marker-buffer old-point))
(goto-char old-point)
(push-mark old-mark t)
(setq this-command 'yank)
(yank)))
(define-key global-map [C-down-mouse-1] 'mouse-drag-region-insert)
(define-key global-map [C-drag-mouse-1] 'mouse-set-region-insert)
--
Sent from my GNU Emacs running on GNU/Linux
I abandoned XEmacs at 21:49 on the 25th of December 2008---and deemed
the event to be so noteworthy that I entered it in my diary.
_______________________________________________
XEmacs-Beta mailing list
XEmacs-Beta(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-beta