How do I find documentation for this Emacs command? - emacs

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.

Related

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.

Is there command documentation and searching built into emacs?

Suppose I want to install a new package. To do this I need to remember that M-x package-install RET package-name is the sequence of keystrokes to type into emacs to do this.
If I forget this keystroke, my go to solution is to google the action I want to complete and browse through the results until I find the right command.
I suspect there is a better way to look up emacs commands and what they do though. If so, can anybody point me to it?
Thanks!
The number one goto command for this would be the apropos-command, which is invoked by using C-h a (or M-x apropos-command), and then typing a search query for the command.
If you know the name of a function, you can use C-h f which runs the describe-function command to get more details about the command.
Lastly, if you know the key sequence, and want more details regarding the command you run, you can use C-h k - describe-key to have emacs tell you what command and the documentation for that command when typing a sequence of keys.
You can get a more complete list of help commands by typing C-h ?.
The built-in manuals are the other obvious places to look, and you can search each one using its index, or isearch through the full-text of the manual.
https://stackoverflow.com/a/22380057/324105
If you use Icicles then the equivalent of apropos-command is built into every command that reads a command name, and you can change the pattern on the fly to tweak the set of matches. See apropos completion.
Whereas with apropos-command you need to provide at the outset the regexp or the complete list of keywords to match (and you need to get them right), with Icicles you can modify/correct them incrementally, and you can add more patterns progressively (progressive completion).
And when you have a set of matches for your pattern(s), you can see the complete doc for each on demand, as opposed to searching the output from apropos-command (which only shows partial doc anyway).
In addition, Icicles extends the standard apropos commands in various ways.

How to copy/select a whole file or buffer in Emacs?

Is there any command to select the whole file contents in Emacs?
For example, Control+a selects whole contents of a file in Notepad, Notepad++, etc.
I can select whole contents using the mouse, but it's inconvenient for large files. I found the basic Emacs commands here and here, but could not find what I am looking for.
C-x h will select the entire buffer.
You can search for help within Emacs using the built-in help system.
C-h f will look for help for specific functions. In this case, you could have searched for whole-buffer to find mark-whole-buffer.
Other help commands of interest would be:
C-h m to show available commands for the current modes
C-h v for help related to variables
C-h k to find which functions keys are bound to
C-h w to see which key bindings are defined for a given function
C-h ? to see which other options are available.
Note that C-x h will only highlight all the text. To actually copy the selected text, you must use C-w for cut (kill-region) or M-w for copy (kill-ring-save).
I use CUA, so I didn't like mark-whole-buffer because it doesn't use a temporary region.
After much messing about, I finally achieved this using a keyboard macro saved to a function:
Define a macro which selects the whole buffer
Run kmacro-name-last-macro to name the macro
Use insert-kbd-macro to script it out
Now you can copy it into your config & map it to a key, like C-a
Copying and selecting are related, but distinct, actions. A file and a buffer are also related, but distinct.
To copy a buffer, consider using jac.el. It handles both the "copying" and dealing with modes.

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

Emacs C-c } command and parentheses-match checking

I am working in Emacs 23, editing LaTeX via AUCTeX. I noticed in emacs that when I press C-c }, I receive the minibuffer message
Scan error: "Unbalanced parentheses", 16026, 16440
Question 1. What exactly is this command doing?
Question(s) 2. More generally, how can I determine what I a given macro is doing? Is there, for example, a universal command that request the keyboard shortcut as an input and outputs a description of the command to which that shortcut is bound? Is there a list of all active keyboard shortcuts?
Question 3. How can I find my unmatched parentheses? The post here recommends the command M-x check-parens, but it availed me nothing, not even a minibuffer message.
The answer to 1 and 2 is to do C-h k C-c } and see what the help buffer tells you. This is one of the features that allows us to call Emacs a self-documenting editor. Don't forget that you can follow the links in the help buffer to both the source code where this function is implemented and to other documentation.
You may also want to use C-h m to see all the key bindings added by the major and minor modes that are currently enabled and C-h ? to see what other interesting help functions there are.
I've never used check-parens specifically, but it does work in my current buffer, which is javascript. I see from its documentation (C-h f check-parens) that it relies on the current syntax table, so perhaps for TeX the syntax table doesn't contain enough information for check-syntax to find the error.