3

Emacs buttonizes specific expression in the buffers. For example, email ids, urls attachments in gnus buffer, and [back], [forward] in help buffers and so on. When we click on those with mouse, they act appropriately.

How to know which function is called when clicking (with mouse) on such a buttons?

C-h k isn't of much help here.

Edit: this question is already answered. The reason I wanted to know is to bind keys like firefox to go back and forth in the history of help buffer.

Now I have the following in my .emacs

(define-key help-mode-map (kbd "M-<left>") 'help-go-back)
(define-key help-mode-map (kbd "M-<right>") 'help-go-forward)
  • “C-h k isn't of much help here.” It works for me in the help buffer links. What version of emacs are you using? – Malabarba Oct 23 '14 at 12:11
  • 1
    emacs trunk, C-h k just tells me that it is bound to mouse-drag-region which is not much revealing about the final function which acted on with the mouse click – kindahero Oct 23 '14 at 12:45
  • 1
    C-h k should tell you both that down-mouse-1 is bound to mouse-drag-region and that mouse-1 is bound to mouse-set-point. A mouse click involves both a down event and an up event. The "final function which acted on with the mouse click" is the function bound to the up event. – Drew Oct 23 '14 at 16:13
  • @Drew I wonder how to trace double click. Which seems to be different function as single one, am I right? – Dima Fomin Dec 6 '17 at 14:04
  • @DimaFomin: See mouse.el - look for event-click-count. – Drew Dec 6 '17 at 16:05
7

You can view a considerable amount of information about buttons (and other text properties and overlays) by placing point on them and using what-cursor-position with a prefix arg, that is, C-u C-x =. The help page this brings up has links describing the button information.

As an example, take the [back] buttons in *Help*. C-u C-x = with point on that button brings up an help page listing various text properties: click on the link next to category and you should see something like this:

Category help-back-button:

  action               help-button-action
  evaporate            t
  face                 button
  follow-link          t
  help-echo            [Show]
  help-function        help-xref-go-back
  keymap               [Show]
  mouse-face           highlight
  rear-nonsticky       t
  supertype            help-xref
  type                 help-back

[back]

You can see that the action function is help-button-action (which as it happens will look at some of the other properties here to decide what to do).

(Note that this all has more to do with buttons than the mouse itself. Using the keyboard will fire the same function.)

| improve this answer | |
  • Thanks, I expected it to be something to do with overlay. had no clue how to look into overlays. – kindahero Oct 23 '14 at 13:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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