1

What handler is called when I make triple click ? For me, it select whole line. I want this behavior to be binded to C-l, how to do it ?

EDIT:

I tried to bind this to key, but not works, how to fix it?

(defun custom/mark-whole-line  ()
   (interactive)
   (mouse-start-end 0 (buffer-size) 2))
2
  • The answer to your edit is not so simple. That's why I ran through all of the code I mentioned. The mouse.el code is a bit convoluted, in part because the Emacs mouse does a lot of different things with the same buttons. If you want a command that does only what triple-clicking mouse-1 does then you (or someone else) will need to dig into that code and compose bits of it (or similar or write code from scratch) to do the job.
    – Drew
    Commented Nov 27, 2017 at 23:36
  • In any case, to bind a mouse event to a command you typically need for the command to use "e" in the interactive spec. Check the manual.
    – Drew
    Commented Nov 27, 2017 at 23:38

1 Answer 1

2

I guess you mean the key-binding <triple-mouse-1>.

You can sort-of answer your question by using C-h k followed by triple-clicking mouse-1 (the first/left mouse button).

This is what I see when I do that in the Emacs 26 pretest:

<mouse-1> (translated from <triple-mouse-1>) at that spot runs the command mouse-set-point (found in global-map), which is an interactive compiled Lisp function in mouse.el.

It is bound to mouse-1.

(mouse-set-point EVENT &optional PROMOTE-TO-REGION)

Move point to the position clicked on with the mouse.

This should be bound to a mouse click event type.

If PROMOTE-TO-REGION is non-nil and event is a multiple-click, select the corresponding element around point, with the resulting position of point determined by mouse-select-region-move-to-beginning.

In Emacs prior to Emacs 26 you also see the doc for the button-down event, <down-mouse-1>.

To figure out what's happening you need to check the code of mouse-set-point. You'll see that when called interactively its second arg, PROMOTE-TO-REGION, is non-nil (coming from the numeric prefix arg). So it calls mouse-set-region.

Function mouse-set-region then calls mouse-start-end, passing (1- click-count), where click-count is the number of clicks. For a triple-click it thus passes 2.

Finally, given the value 2 as its MODE argument, function mouse-start-end selects the whole line. Its doc string (C-h f mouse-start-end) tells you:

mouse-start-end is a compiled Lisp function in mouse.el.

(mouse-start-end START END MODE)

Return a list of region bounds based on START and END according to MODE.

If MODE is 0 then set point to (min START END), mark to (max START END).

If MODE is 1 then set point to start of word at (min START END), mark to end of word at (max START END).

If MODE is 2 then do the same for lines.

Whew! Not so easy, but Emacs finally tells you what you wanted to know. It is (ultimately) function mouse-start-end that selects the whole line. But it does that only because of the MODE parameter passed to it from mouse-set-region. And mouse-set-region only does the right thing because of code that is in mouse-set-point.

1
  • Thank you, I have little second question (more in EDIT).
    – dev1223
    Commented Nov 27, 2017 at 23:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.