I have been looking for some information regarding the Emacs UI philosophy. Hopefully, someone here can point me in the right direction for further research. Many thanks in advance!
Background
I am a new (but avid) vanilla Vim user, just getting started with Guix System. My favorite feature of Vim is the overlap between the UI and vimscript. In this way, it is very much like Bash (and other classic shells). With the right approach, just using Vim will teach you the basics of scripting. Since Vim’s UI is modular, studying even very obscure features is rewarding.
Question
I am beginning to see the appeal of LISPs. I think I might be sold on Emacs if it were not for Vim’s code-as-the-interface approach. From what I can tell, Emacs is very keybind-driven. I love keybinds, but REPL-like interfaces are much better for learning. Does that make sense? Can this be had in Emacs?
Well first the Emacs UI is a shell in the sense that bash and Gnome/KDE Plasma are shells, that allow you to interact with your computer. IMHO, the biggest difference between vi/vim and Emacs.
Next it’s a lisp interpreter and most functionality is written in elisp so all keybindings call functions that you can use and even change while emacs is running.
My primary concern is that I will just start memorizing keybinds in Emacs without becoming familiar with the underlying functions. M-x feels like a standard command palette which abstracts the UI away from the underlying code. Is there a workflow which helps to expose the functions as you work?
The composability of Vim’s grammar is a real selling point. I want to learn in a hands-on way where I can incrementally add functions to my vocabulary along with new ways to compose them. I have found it worthwhile to avoid plugins, custom functions, and even remaps. Vim’s native vocabulary is extensive and concise enough to do nearly anything without unreasonably long commands. By constraining myself to these commands, I find my understanding grows much faster. This is what I am trying to recreate.
I understand that Emacs takes a different approach. Originally, I was looking for a way to efficiently control Emacs with just Elisp. This is why I am reaching out for your seasoned perspective. What is the best approach to hands-on, incremental learning in Emacs?
Why is that bad? Did you delve deeply into the Vim code to find out what happens when you press j in command mode? That said, you are welcome to do so in Emacs. Press C-h k and then the binding you are interested in, for example C-n. This will open a *Help* buffer with a description of that key. Pressing s in that buffer will take you to the source code for the function next-line (in this example).
Umm… yes? M-x allows you to run “commands”, functions marked as interactive. If you want to run any arbitrary function, you’ll need to use M-: instead. I’m not sure what you mean about “abstracting the UI from the underlying code”… These two keybindings quite literally are the way to run the underlying code. Keybindings are simply keyboard shortcuts tied directly to the underlying functions they run (like next-line from the the previous example).
I’m not sure I fully understand exactly what you mean here, but as a stab at it… at the very bottom, there is a bunch of C code which implements the Emacs Lisp language and some other utilities for optimization purposes (to possibly oversimplify it). There is a layer above that which is all Emacs Lisp which provides the functions necessary to implement Emacs itself. So, to control Emacs with just Emacs Lisp (aka Elisp), just use Emacs. Everything you do is running an Elisp function (mostly… there are some things implemented in C for efficiency, or because of needed hooks to external libraries like GTK for the graphical UI or whatever).
As for an approach to hands-on, incremental learning in Emacs, I might suggest starting with the built-in tutorial (C-h t). You might also consider reading Mastering Emacs (see https://masteringemacs.org). If you are looking to learn the Emacs Lisp language, there is also the manual (C-h i m Elisp RET) or the Emacs Lisp Intro (C-h i m Emacs Lisp Intro RET). If you are looking for examples on configuring Emacs, you are welcome to peruse the code at GitHub - SystemCrafters/crafted-emacs: A sensible base Emacs configuration.. Use the pieces and parts you think fit you the best or adapt them as necessary for your specific configuration of Emacs.
In general, just start using Emacs. As you need to do something, try doing it in Emacs - like writing code, setting up a language server and possibly an LLM for intellisense and code suggestions; try reading email in Emacs (there are several way, I personally use Gnus, others use mu4e, but there are a few other ways to go about it as well); if you need to take notes, try Org mode and possibly one of the second brain implementations like Roam or Denote. Consider following Protesilaos Stavrou on YouTube (https://www.youtube.com/@protesilaos) and possibly read through his configuration - he does a lot of customization without using external packages. And, of course, continue to ask here.
Thank you for all the direction! You helped clarify the Emacs learning paradigm. I will apply your recommendations and come back with follow-up questions.
M-x feels like a standard command palette which abstracts the UI away from the underlying code
No, it’s the opposite as it exposes the underling code, independent of the key chords it’s bound to.
The composability of Vim’s grammar is a real selling point. I
I don’t know about vim script but I think the analog in Emacs would be macros.
Let me know if I’m correct with my hunch.
want to learn in a hands-on way where I can incrementally add functions to my vocabulary along with new ways to compose them. I have found it worthwhile to avoid plugins, custom functions, and even remaps. Vim’s native vocabulary is extensive and concise enough to do nearly anything without unreasonably long commands. By constraining myself to these commands, I find my understanding grows much faster. This is what I am trying to recreate.
So learn the vanilla key chords and not use modules that aren’t included.
As @wolfjb wrote, use the build in help system and the other recommended resources.
I do understand that M-x is a palette of interactive Elisp functions. My concern is that I might only become familiar with function names. Ideally, I also want familiarity with the rest of the function signature.
You guys have given me plenty to work through for a while, so I will be back when I have implemented your recommendations. I do not want to waste your time with uninformed speculations.
Thank you!
I suppose the last thing I can ask before doing my homework is: How extensively do you leverage your understanding of Elisp for day-to-day EMacs stuff (configs not included)? Examples would be great.
Fun fact: The name “Emacs” stands for “Editor macros.”
I do understand that M-x is a palette of interactive Elisp functions. My concern is that I might only become familiar with function names. Ideally, I also want familiarity with the rest of the function signature.
I don’t get, what you mean by palette and function signature.
I do not want to waste your time with uninformed speculations.
Don’t be shy, the worst that can happen is that we will not respond.
How extensively do you leverage your understanding of Elisp for day-to-day EMacs stuff (configs not included)?
Not much, I’m currently trying to get into Guile and Guix but I use some Elisp in org-mode literal programming to manipulate tables or in source blocks.
I’m not sure I use it extensively in day-to-day operations, however, I did write a bit of Emacs Lisp to connect to the System Crafters Live IRC Channel (see here). I also wrote my own templates for a couple of files (pom.xml, an Org file for when I start new projects, etc), and if I create an appropriately named file in the correct directory, Emacs auto-insert functionality kicks in and inserts those templates. If you look at the Crafted Emacs (specifically the modules/crafted-init-config.el) you’ll find an auto-insert example.
There are packages that show what functions are behind the keybinds (e.g. keycast), but there is also the built-in M-x view-lossage (C-h l), which will show you the last ~300 keystrokes (can be set via M-x lossage-size`).