Skip to main content
added 3182 characters in body
Source Link
db48x
  • 20k
  • 1
  • 25
  • 30

I had forgotten that all buttons created by the widget library execute a single command named widget-button-click. This command then looks up the correct command to run and then runs it. It’s necessary but a annoying when you are introspecting things.

When you find yourself in that situation, put the point on the button and use C-u C-x = to run what-cursor-position. This opens a buffer containing everything Emacs knows about the character at point. It includes various data from the unicode database about the character, and it also includes any text properties at that point. You want to look for either the button or action property. Either one can describe what to do when the thing is clicked on.

The button property often holds something that looks like an object:

(push-button :tag " Revert... " :help-echo "Show a menu with reset operations." :mouse-down-action ignore :action custom-reset :button-overlay #<overlay from 165 to 176 in *Customize Group: Emacs*> :from #<marker (moves after insertion) at 165 in *Customize Group: Emacs*> :to #<marker at 176 in *Customize Group: Emacs*>) 

This particular one came from the first button I spotted in a Customize buffer, rather than from notmuch-hello. Its a property list (aka plist). The :action property is custom-reset, which is the function that this button calls when clicked. The other properties of the button aren’t so relevant to your situation, but you can probably guess what they’re for.

Some other things that you can click on have an action property instead. This can name a function, or it sometimes contains the function body itself. If the value is just the function itself, then they’re pretty hard to read:

#[128 " r\306\307!q\210p\310 \210\311\211\312\211\312\313 \210\314\315!+\210\211\316\300\242!\317!)\210\207" [("(push-button :tag \" Revert... \" :help-echo \"Show a menu with reset operations.\" :mouse-down-action ignore :action custom-reset :button-overlay #<overlay from 165 to 176 in *Customize Group: Emacs*> :from #<marker\n (moves after insertion)\n at 165 in *Customize Group: Emacs*> :to #<marker at 176 in *Customize Group: Emacs*>)") default-directory buffer-read-only buffer-file-name buffer-undo-list inhibit-modification-hooks get-buffer-create "*Pp Eval Output*" kill-all-local-variables nil t erase-buffer run-hooks temp-buffer-setup-hook princ internal-temp-output-buffer-show inhibit-read-only standard-output] 7 "\n\n(fn &rest IGNORE)"] 

That particular button opens the window that shows the value of the button property I already mentioned in a new window. The really odd–looking stuff at the beginning is the compiled bytecode that will be executed when this function is called. Not super helpful.

Still other clickable buttons instead have a category property that leads you to more information. The category generally has an activate property that again contains either a function or the name of one.

And of course, once you have a function name you can use C-h f to look up what the function does and where it is defined.

I had forgotten that all buttons created by the widget library execute a single command named widget-button-click. This command then looks up the correct command to run and then runs it. It’s necessary but a annoying when you are introspecting things.

When you find yourself in that situation, put the point on the button and use C-u C-x = to run what-cursor-position. This opens a buffer containing everything Emacs knows about the character at point. It includes various data from the unicode database about the character, and it also includes any text properties at that point. You want to look for either the button or action property. Either one can describe what to do when the thing is clicked on.

The button property often holds something that looks like an object:

(push-button :tag " Revert... " :help-echo "Show a menu with reset operations." :mouse-down-action ignore :action custom-reset :button-overlay #<overlay from 165 to 176 in *Customize Group: Emacs*> :from #<marker (moves after insertion) at 165 in *Customize Group: Emacs*> :to #<marker at 176 in *Customize Group: Emacs*>) 

This particular one came from the first button I spotted in a Customize buffer, rather than from notmuch-hello. Its a property list (aka plist). The :action property is custom-reset, which is the function that this button calls when clicked. The other properties of the button aren’t so relevant to your situation, but you can probably guess what they’re for.

Some other things that you can click on have an action property instead. This can name a function, or it sometimes contains the function body itself. If the value is just the function itself, then they’re pretty hard to read:

#[128 " r\306\307!q\210p\310 \210\311\211\312\211\312\313 \210\314\315!+\210\211\316\300\242!\317!)\210\207" [("(push-button :tag \" Revert... \" :help-echo \"Show a menu with reset operations.\" :mouse-down-action ignore :action custom-reset :button-overlay #<overlay from 165 to 176 in *Customize Group: Emacs*> :from #<marker\n (moves after insertion)\n at 165 in *Customize Group: Emacs*> :to #<marker at 176 in *Customize Group: Emacs*>)") default-directory buffer-read-only buffer-file-name buffer-undo-list inhibit-modification-hooks get-buffer-create "*Pp Eval Output*" kill-all-local-variables nil t erase-buffer run-hooks temp-buffer-setup-hook princ internal-temp-output-buffer-show inhibit-read-only standard-output] 7 "\n\n(fn &rest IGNORE)"] 

That particular button opens the window that shows the value of the button property I already mentioned in a new window. The really odd–looking stuff at the beginning is the compiled bytecode that will be executed when this function is called. Not super helpful.

Still other clickable buttons instead have a category property that leads you to more information. The category generally has an activate property that again contains either a function or the name of one.

And of course, once you have a function name you can use C-h f to look up what the function does and where it is defined.

Source Link
db48x
  • 20k
  • 1
  • 25
  • 30

Use C-h k, but click on the the thing you are interested in.