What function does evil mode run when I press :w? - emacs

I was wondering what function evil mode ran when I pressed :w. I tried using C-h k and then I pressed :w but it only registed the : I pressed and showed me information about evil-ex function instead of showing me what function is run when I save the file using :w.

It's evil-write.
As you know, : call the function evil-ex, You can try to find related evil-ex-* variable which save the association list of command bindings and functions and I found it's evil-ex-commands.

Related

Run a function after keypress in MATLAB

I want MATLAB to run a function after I press a specific key "s" from the keyboard while I am within the MATLAB application (focused in MATLAB window). Is there a way to do that without the use of any external packages or libraries?
Thank you.
You can set custom shortcuts in Matlab by selecting:
Home > Preferences > Shortcuts
The closest option to what you want is "evaluate entire file" which runs the current script / function file open in the editor. I don't know of any ability to run a specific function using this, but you can assign the shortcut "S" as shown below.

What is the keybind in help-mode to go into link?

There are always links in help-mode which suppose to be entered by the <return> button. Since I remapped the <return> button to indent-and-new-line, I can no longer enter the link. I would like to find the correct key map for the enter button.
Help mode defined in `help-mode.el' (`help-mode'):
Major mode for viewing help text and navigating references in it.
Entry to this mode runs the normal hook `help-mode-hook'.
Commands:
key binding
--- -------
C-c Prefix Command
TAB forward-button
(that binding is currently shadowed by another mode)
RET help-follow
(that binding is currently shadowed by another mode)
ESC Prefix Command
SPC scroll-up-command
I get this help from the describe mode. I tried the help-follow but it does not work. What should be the correct key bind?
By default RET runs push-button when on a link in help-mode. You should also be able to click on links with your primary mouse button if you like using the rodent. This function is not bound to any other keys out of the box.
I'm not sure how you're rebinding RET, but it probably makes sense to do it a bit more selectively. indent-and-new-line might make sense in most modes, but as you have discovered there are situations where you may want the default behaviour.
Perhaps you could do this via prog-mode-hook, so it only affects programming modes?
Alternatively you could bind some other key to push-button in help-mode.
By the way, here is a useful technique that would have let you discover this keybinding yourself:
Run Emacs with the -Q flag to suppress loading of your init file and the system init file.
Activate a buffer that uses help-mode, e.g. by using C-h f message RET to see the documentation for the message function and then C-x o to switch to the help window.
Press C-h k RET to see what function is bound to RET.

How can I get the emacs command for a given keyboard shortcut?

Is there a general way to do this? I'm looking for a function that accepts an arbitrary keyboard shortcut, and returns the corresponding function name.
C-h k runs the command describe-key
Display documentation of the function invoked by KEY. KEY can be any
kind of a key sequence; it can include keyboard events, mouse events,
and/or menu events.
When calling from a program, pass KEY as a string or a vector.
BTW, if you really want a "function" rather than a "command" (i.e. something to call from Elisp rather than to use interactively), then `key-binding' is probably the closest.
help for a command:
F1 + your command
doc for a command:
F1 + d + your command

How do I find documentation for this Emacs command?

This question shows how to change a particular Emacs setting with set-face-attribute.
Where can I find documentation on set-face-attribute?
Normally I find documentation by C-h a, followed by a command or fragment of a command. But doing this for set-face-attribute turns up nothing.
Standard way to get description of function is C-h f - press it and type function name (you can use TAB to complete function name).
If you'll press C-h ? - you'll get list of all help functions. Another useful keybinding is C-h v - to get description of variable.

Emacs shift selection hook?

I've set up activate-mark-hook and deactivate-mark-hook, but they work only when selecting text by dragging mouse, not by using shift-selection. How do I hook into shift selection?
I'm using Aquamacs 24 on Mac OS X 10.6.6.
Just peeked into the Emacs source to see what happens, this is what I found:
For every command that has been shift-translated, the function "handle-shift-selection" is called. This function will activate or deactivate the selection by using the "transient-mark-mode" variable, and by calling "push-mark" and "deactivate-mark", respectively. If I do the math correctly, this means that your deactivate hook will be called, but not you activation hook.
One way to solve this is to add your own code to "push-mark" using "defadvice".