Hot answers tagged

45

Every command is a function, but not every function is also a command.1 A command includes a call to interactive; this is why commands are commonly referred to as "interactive functions". Commands can be invoked via M-x name-of-command RET, and they can also be bound to a key sequence. Regular functions do not include a call to interactive, can not be ...


34

What a great question! Here is the path I've taken: Step 0: Read the Emacs Tutorial Read the Emacs Tutorial before anything else. It sounds like you've done this. Good on ya! However, for anyone coming to this at a later time, this is the place to start your Emacs journey. There are a lot of misleading blog posts out there. They over complicate ...


16

The describe-key command (C-h k) will tell you what command is bound to a given key sequence. To go the other way and find out what keys (if any) are bound to a command, use where-is (C-h w). You can list all available key bindings using describe-bindings (C-h b). As of Emacs 25, you can also use view-lossage (C-h l) to see the recent history of every key ...


15

Evaluate the following using eval-expression (M-:) or in a scratch buffer: (describe-key (kbd "C-<whatever>"))


12

Yes. Library help-fns+.el defines command describe-command. And it redefines describe-function so that it does describe-command if you give it a prefix arg. The library binds describe-command to C-h c (describe-key-briefly is moved to C-h C-c). The same library defines other help commands, such as describe-file, describe-buffer, describe-keymap, and ...


11

In my experience, the included tutorial on Emacs Lisp was not too helpful (I tried twice over the years and failed). Instead, I finally used the included Emacs Lisp Reference. What finally did work: Realize that there are two aspects to Emacs Lisp: The basic language itself, and the interaction with Emacs. Separate these two in your mind. Focus first on ...


10

It doesn't. It uses just an E that is suggestive of a gnu's horns.


10

I recommend the "Emacs Lisp Intro". The "Emacs Lisp Intro" might be already available in info format within your Emacs. Try C-h i m Emacs Lisp Intro RET or evaluate (info "(eintr) Top") in Emacs. If this fails search the web for "Emacs Lisp Intro".


9

If you can't use a particular key combination because of your terminal, you can often fake it by manually simulating the key modifier. The following combinations work exactly as though you had used the corresponding modifier key: C-x @ a alt C-x @ m meta C-x @ c control C-x @ h hyper C-x @ s super (lowercase s) C-x @ S shift (...


9

apropos-command might be sufficiently close. It doesn’t offer describe-function’s tab completion, but it lets you search only through commands, and it takes you to their doc page.


9

Prefix keys like C-u may be described in the function body. You should therefore ignore such prefix keys when using C-h k to describe a function.


9

M-x finder-commentary RET <library-name> RET extracts that section and presents it in a separate buffer for reading. There is also M-x finder-by-keyword for discovering libraries this way.


9

Apropos help in Emacs is by no means limited to function apropos. M-x apropos documentation. It lets you match keywords or a regexp against doc strings. Very helpful when you don't know how the function might be named but you might be able to guess some words used in its doc. For example, M-x apropos-documentation RET shift bit RET shows you the names and ...


9

Included with emacs is a basic tool called picture-mode: To edit a picture made out of text characters (for example, a picture of the division of a register into fields, as a comment in a program), use the command ‘M-x picture-mode’ to enter Picture mode. In Picture mode, editing is based on the “quarter-plane” model of text, according to which ...


8

You've seen the basics, really. Your main problem was that this documentation was wrong, not that you weren't looking in the right place. The slightly more direct way to read that documentation for a mode is by calling describe-function: C-hf outline-minor-mode And the bit you missed is that, should the mode in question be indexed in the manual, you can ...


8

Customize the variable help-window-select: "Non-nil means select help window for viewing. Choices are: never (nil) Select help window only if there is no other window on its frame. other Select help window unless the selected window is the only other window on the help window's frame. always (t) Always select the help ...


8

if you have smex installed, just call smex. Start to type, when the right one comes up, press C-h f.


8

From gnu.org: If you type C-h f <RET>, it describes the function called by the innermost Lisp expression in the buffer around point, provided that function name is a valid, defined Lisp function. (That name appears as the default while you enter the argument.


8

You can use both make-button or make-text-button. For example (defun button-pressed (button) (message (format "Button pressed!"))) (define-button-type 'custom-button 'action 'button-pressed 'follow-link t 'help-echo "Click Button" 'help-args "test") (make-button 1 10 :type 'custom-button) This will create a button at char 1 to 10 in the current ...


7

Eliza stems from 1960s research in AI. It goes beyond the fun as far as AI research is concerned; it's wildly out of date, but still a common, reasonably fun programming exercise. As far as psychotherapy is concerned, it is about fun. It can alleviate frustration, but it isn't supposed to bring serious psychological help. doctor.el is in the lisp/play/ ...


7

I can't find this built-in. It is fairly easy to make a wrapper around describe-function that only completes command names when called interactively. In the implementation below, I duplicated the interactive form from describe-function and changed the fboundp test to commandp. As an added bonus, this function offers all function names when called with a ...


7

Yes. There is a function key-description that takes a list or vector of keys and returns a string that describes them. This is used by the built-in help facilities such as describe-key and describe-function to display information about key bindings. It calls single-key-description on each element of the input list. Both of these are written in C rather than ...


7

You can use rename-uniquely. Go to the help buffer, call rename-uniquely. It renames the buffer to something like *Help*<2>. Now If you open another help buffer, it doesn't affect *Help*<2>. (rename-uniquely) Rename current buffer to a similar name not already taken.


7

Start with the Emacs Wiki page Learn Emacs Lisp. Not that that page itself will teach you Emacs Lisp. It will instead point to learning resources -- exactly what you're looking for here, with your question. Many users have contributed to it and edited it over a period of years. That presents advantages as well as disadvantages wrt one user's blog. The ...


7

To quote the Emacs Lisp Manual, t is the preferred way to represent the truth value true. When you need to choose a value that represents true, and there is no other basis for choosing, use t. The symbol t always has the value t. t stands for "True". This is important because it is used for decision making. It is used in decisions such as "If ...


6

Use with-help-window: (with-help-window "*My Help Buffer*" ; Whatever buffer name you like. ;; Use `princ`, `prin1`, `terpri`, etc. to put text in the displayed buffer ) Key q will automatically be bound to do what you want. C-h f with-help-window says: with-help-window is a Lisp macro in help.el. (with-help-window BUFFER-OR-NAME &rest BODY)...


5

Menu bar items are represented as keybindings internally. So, this means that on the one hand keybinding-related actions will involve menu bar items and on the other one that clicking the "Search" item in the menu bar would yield a list where isearch-forward would be a valid action. FWIW, the docs tell me something slightly different: It is bound to C-s, &...


5

If you are using helm and helm-M-x, you can press C-j on the commands to pop up their documentation.


5

As far as I know, there is no such tool in Emacs or a 3rd-party library. But perhaps someone else will come up with one. You have correctly pointed to the two main sources of info I would have mentioned: (1) pop-up info in tooltips and (2) studying mode-line-format and its doc (doc string and Elisp manual, node Mode Line Top). A third source of info that ...


5

You can use post-command-hook. (defun my-echo-command-name-hook () (unless (or (eq this-command 'self-insert-command) (eq this-command 'next-line)) (message "%s" this-command))) (add-hook 'post-command-hook 'my-echo-command-name-hook)


Only top voted, non community-wiki answers of a minimum length are eligible