yelinaung98 · 2022-06-05 16:48
Hi, I have been using emacs for like 4 years now with my customized configs. Most of the configs are small functions, variable changes but I want to extend more. I want to start writing things like asking user input and executing scripts. One usecase will be like, if I execute command deploy and choose uat, it will ask for comment and I can add deployment comments and etc. What is the best way to learn those things? I was checking most customizating emacs docs but most only show aobut customizing variables and etc.
takeonrules · 2022-06-05 17:10
completing-read and interactive functions are your friend. Also look-up some transient examples. This may be the key tool.
I have several uses in my config that might inspire you: https://github.com/jeremyf/dotemacs/blob/main/emacs.d/configuration.org#crafting-menus-to-help-organize
00-11 · 2022-06-05 18:14
1. Read the doc about [`interactive` forms](https://www.gnu.org/software/emacs/manual/html_node/elisp/Using-Interactive.html).
2. Look at the source code for simple commands (defined in Lisp) that interest you. Look at their use of `interactive`, in particular.
3. Use `completing-read`.
E3D3redit · 2022-06-05 18:51
Two simple `completing-read` examples:
Pick a name: `(completing-read "Enter a name: " '("Tom" "Jerry" "Donald"))`
Select a 'M-x command': `(completing-read "M-x " obarray #'commandp)`
xtifr · 2022-06-05 20:59
Elisp is an extremely powerful language. This is why people do so many amazing things with it. This also means it's not exactly something you should expect to learn overnight--but it shouldn't take *too* long to get the basics.
Emacs comes with both an elisp tutorial and an extensively detailed elisp manual. (These are completely separate from the *emacs* tutorial and manual.) You can find these via Help->More Manuals->Introduction to Emacs Lisp and Help->More Manuals->Emacs Lisp Manual. (Or you can use `C-h i` to get to the index of manuals and skim for them.)
Emacs also comes with an incredible number of handy examples--the source to all the parts of emacs written in elisp. (That is to say, most of emacs.) Whenever you get help for a function (e.g. with `C-h f`), there will be a link in the help window saying something like "*foo* is an interactive function defined in foo.el", where the name of the .el file (elisp file) will be a link. Click on or press enter on that filename, and it will take you directly to the source for that function!
Another useful feature when browsing elisp source files (yours or others) is Help->More Manuals->Lookup Subject in all Manuals... (aka `M-x info-apropos`).
Emacs isn't called "the self-documenting editor" for nothing! :)
arthurno1 · 2022-06-06 01:41
> One usecase will be like, if I execute command deploy and choose uat, it will ask for comment and I can add deployment comments and etc. What is the best way to learn those things?
You can start by pressing C-h i in you Emacs and choose "An Introduction to pProgramming with Emacs Lisp" from the toc.