Yay Emacs 33: Sacha and Prot Talk Emacs: Built-ins
Posted: - Modified: | emacs, yay-emacs: Updated transcript
I chatted with Prot about the Emacs Carnival June 2026 topic Underappreciated Emacs Built-ins. Thanks to Ross A. Baker for hosting the carnival!
View in the Internet Archive, watch or comment on YouTube, read the transcript online, download the transcript, or e-mail me.
Related links:
- Underappreciated Emacs Built-ins
- Top (GNU Emacs Manual)
- YE24: Sacha and Prot Talk Emacs - Newbies/Starter Kits
- Emacs: decent defaults I shared with Sacha Chua | Protesilaos
- EmacsWiki: Carnival
Chapters
- 0:00 Starting up
- 2:27 Focus and distraction
- 3:54 Org Mode and other note-taking, task-management systems
- 4:58 Kill ring
- 6:50 Registers
- 9:58 Narrowing
- 12:04 org-narrow-to-subtree
- 12:13 narrow-to-defun
- 13:19 Indirect buffers
- 14:50 Undoing within a region
- 15:53 Bookmarks
- 17:41 isearch
- 18:21 Tip: Add a counter to isearch
- 19:26 C-x C-x (exchange-point-and-mark)
- 20:55 Popping to marks - going back to where you were
- 21:49 Selecting what you just pasted
- 22:33 Indenting pasted or selected text with indent-rigidly
- 23:24 Popping to mark after xref or imenu
- 24:05 Adding other packages like consult
- 24:44 Tip about indicating isearch wrapping
- 25:26 Navigating by sentence or s-expression
- 27:45 Navigating to other errors
- 28:29 Tags
- 28:47 Imenu
- 30:19 Projects
- 32:10 Putting projects in tabs or frames
- 32:35 Tabs
- 34:41 Navigating frames
- 36:07 These navigation shortcuts work for prose, too
- 37:09 follow-mode
- 37:50 Ediff
- 42:12 Calling functions by name
- 42:52 Completion
- 44:13 Manuals
- 45:57 Menus
- 47:46 Automation - abbreviations
- 49:56 Quoting the next character with C-q
- 50:31 Mapping abbreviations to code
- 51:51 Taking notes with org-capture
- 52:08 Navigating back to captures or refiles
- 53:49 dabbrev
- 54:44 Keyboard macros
- 57:52 Editable grep and occur
- 1:01:01 Emacs Carnival June 2026: Underappreciated built-ins
Transcript
Expand this to read the transcript
M-y without C-y beforehand, you get completion. So you can select something that you had in your kill-ring like a few kills ago. Clipboard navigation, which is something that you don't see right away. Sacha: If people are coming from outside Emacs and they're like, "What is this thing that you're talking about?" People are used to having a clipboard, right? As soon as you copy something, your program forgets the thing that you previously copied. On mobile phones now, if you press paste, you can see a selection of the previous things you've copied before. It's like that, but larger. Sacha: Prot points out: you can use completion with it. So M-y is yank-pop I think? What I find useful about this is sometimes I'll copy something because I want to go paste it somewhere else, and then on the way to that somewhere else, I get distracted by something, and I need to copy that, but I know that the kill-ring will have the other copies that I meant to put somewhere else. Prot: By completion here, we mean you can type and match that thing, narrow down to it. Prot: You don't have to go searching for it and, "Okay, which one exactly is it," right? Prot: You can find it more easily. jump-to-register] and then I can just easily press one more key to get to the file that I want. So registers, again, if you're not used to Emacs, this is a built-in that's got a lot of features for helping you save text to things, especially if you're going to use them in keyboard macros because you can say, okay, insert text A and then insert text C and then insert text B. But you can also use them for other things like frameset, like the way that your windows and your buffers are arranged, or files that you want to go back to. query-replace, when you do !, it means yes to all, but if you are in a narrowed region, yes to all means only within that portion of the buffer. So if you take care to narrow to where you want to be, then okay yes to all, you don't even have to check. Sacha: And I think this is underappreciated enough that, in fact, if you try to use… Is it C-x n? Prot: That's the prefix key. C-x n for narrowing. Sacha: The first time Emacs will say, are you really, really sure? It's one of those disabled commands, right? You've got to enable it for yourself. You've got to say, "Okay, I know what I'm doing. I'm not going to panic if the rest of my file disappears." I know it's there. I'm just choosing to focus on it. I think it's actually available off the menu as well, but I haven't used it off the menu bar. Prot: Yeah, I don't use the menu, so I cannot tell. But I remember that prompt, "Are you really sure?" It's disabled by default. Please make sure you know what you want. Sacha: Keyboard shortcut. That's the way to do it anyway. Prot: The thing is that I do use it extensively. org-narrow-to-subtree]. C-s, to search for the next one, or you can go to the previous one very easily. So isearch is great. C-x C-x. By default, it’s exchange-point-and-mark. Which, if your cursor is here and where you started is up there, it moves the cursor up there and now where you started is down at that point. You can expand the region both ways. You can keep switching and expanding. Sacha: I have never thought about using it for expanding the region. I usually just use it to confirm that, yes, I am actually selecting the parts that I meant to select. Because by the time, of course, I've found the thing that I wanted to end the region with, I've forgotten or I'm not entirely sure I have the right start. So I was using C-x C-x to quickly verify and have everything nicely highlighted. But expanding the region, yeah, that's a thing you can do with it. Prot: Yeah, yeah, of course. Now it's obvious, right? But it's something that you may notice by mistake, by accident. Sacha: [interrupted by life] @charliemcmackin4859 says, "I love that you can make those marking tricks part of a keyboard macro." C-u C-SPC. I think it’s pop-to-mark is the concept. Sacha: Popping to mark. We'll just go with the concept because people can search for the key binding. Which basically means for all the places where you were before you went off searching for something else or doing some other command, you can go back to those places in sequence. I think there are even some commands to let you easily navigate through all the places you've been previously. That is a thing that you can do with Emacs built-ins. It's called popping the mark. It lets you revisit places. Prot: Yeah, yeah. Another point related to this and also related to yank that we said earlier... C-x C-x. Because when you paste something or when you do I search or whatever, it has the effect of updating the mark. Then you can work with that. Sacha: Yeah, that one I use fairly often. Also, that way, you can easily see what it highlights, the part that you've just pasted, and then you can do your other replacements or uppercasing or whatever else to it. indent-rigidly, C-x C-i by default, where you can now have a region of text including an implicit region between mark and point, and you just shift it around, literally left or right. Try it. It's very nice. Sacha: C-x C-i. I think you can even use the arrow keys to move things, so you can just nudge it until it looks right, which is great because sometimes, when you paste things, the indentation isn't the same as all of the rest of your stuff. You might want to put it all the way into an Org list or whatever else, code block, whatever. Prot: Okay. Sacha: So C-x C-x, very handy even after you paste. forward-sexp, but it works in other languages which don't have this Lispy syntax. Sacha: So if you skipped over that part of the tutorial or the manual, go back and read it because it can save you some time. In a pinch, it will also help you make sure that your parentheses are matched up correctly and you go to where you expect them to go. There are other ways to make it easier to match up parentheses or braces or brackets or quotes like [ show-paren-mode ] or whatever. Sometimes I just go forward and back to see whether I end up in the right place. Prot: A small trick here, if you are writing specifically Emacs Lisp, there is a very common mistake of adding an extra parenthesis, and it says "end of file during parsing", or one less parenthesis, what you can do with a combination of keyboard macros... You go to the beginning and you do C-M-e to go to the end of the defun, and then, in a keyboard macro, you keep doing that. Next, next, next, end, end, end, right? Until it stops, and you know where your error is. Sacha: Oh, and I should tell people, if you give the execute-kbd-macro a negative argument, it'll run until error. So you just do that and it'll drop you where it ends. You don’t have to manually press e 500 times. Prot: Exactly. The "run until error" happens when you are in a narrowed region as well. Error here means end of region, end of buffer. Sacha: I should point out in the specific case where you're trying to hunt down a stray parenthesis, you should also just use check-parens, which will tell you. Prot: Of course. next-error, previous-error
to also go to just the next match or the previous match. Prot: That's very useful. next-error and previous-error which works with compile and grep and occur and a bunch of other things that have the same convention. So yes, if you use the M-x compile command to run whatever your compilation step is, it will parse the output of many compilation systems, programs, and it will let you jump to the next error. It will also even show you the errors, I think. Anyway, so you don't need flymake. Flymake just gives you the squiggly underlines. But you can use next-error right away. Prot: Yeah, yeah, yeah. Flymake is more narrow. Yeah, correct. display-buffer-alist so when I do Emacs Magit, magit-status or whatever, it goes in a new tab. Then I leave my work where it is. I do the git thing, then I quit those. I'm back to my layout. Sacha: I know you're a good advocate of checking out display-buffer-alist and all the wonderful things it can do. I should definitely look into having it set up a tab because that sounds a lot nicer than trying to remember, okay, I need to save my window configuration to register and then do this thing. I have it set up actually so that I can winner-undo in order to get back to my previous configuration. But of course, if I need to flip back and forth between two different views, like Magit and my project code, then a tab would work much better for this purpose, I think. Prot: Yes, and it scales better as well, like if you need to have three tabs or whatever. Sacha: Or a new frame. But sometimes managing frames gets a little annoying too. Prot: Of course, of course. There are pros and cons. select-frame ], I think, is the command. If you have lots of frames and you don't know where they are, you can use completion for that. If you want, you can also name frames. I believe it’s rename frame. [set-frame-name] I forget now the command. Basically, you can give it a specific name rather than it changing the name all the time. So you can say, OK, this is my super important note for our livestream, right? That's the frame for you. Now you can find it. Sacha: I should look into that. I also underutilize frames because for the most part, I have a keyboard shortcut like Super 1 which jumps back to Emacs, raises my Emacs window. But it doesn't work so well if I have multiple Emacs window, like multiple Emacs frames. If I can figure out how to get mentally through that or if I switch to EXWM as my window manager, then I'm sure that managing multiple Emacs frames will be a lot easier. But at least tabs, I can probably use within that one frame in order to manage different windows. Prot: I would say tabs is the first thing you want to check. Frames is a little bit more... You have to change your mental model a little bit. C-M-u or
backwards-up-list moves you out of a quote or a parenthesis and then you can C-M-e to go to the end of it. So even if you're writing, for example, a novel, and you're saying, okay, I want to get out of this quote and go to the next sentence, you can either isearch to the start of it, or you can go up out of the quote and then go to the end of the quote. Also very handy to learn the commands for killing an S expression [ kill-sexp ], which again also works with other stuff like quotes or parentheses, because then you can copy and paste things or you can kill it. You don't have to paste it back. It's just you delete it and then you type something else in. It's fine. Prot: Exactly, exactly. And one of those is the mark-sexp, which is very useful. follow-mode allows the same file with multiple frames like a book. So follow mode can work with two, three or more windows. You have an ultra wide, right? So like, okay, you can have several columns following the same file and you can scroll and all of them will scroll in sync. Prot: Yeah, yeah. It's quite nice. Quite nice. Sacha: I forget, does follow mode work with different files? Prot: With different files? I don't think so. Like kind of a scroll lock for all windows? Sacha: Yeah, yeah, yeah. Prot: I don't know. I don't think so. I haven't tried it. Sacha: Worth looking into. [scroll-all-mode] centered-cursor-mode [(it’s a package)], which will keep the cursor position in the middle of the frame. So I can't remember whether there's also like a scroll lock or whatever. Prot: scroll-lock-mode. Yeah, there is `scroll-lock mode. Sacha: Or there was another Emacs built-in that someone mentioned that scrolls it one line at a time, keeping it centered, I guess, which the person found very useful because their cat was sitting on their laptop. So moral lesson is: learn about the Emacs built-in because you never know when a small mammal will be obscuring half of your screen. You can still use Emacs. Which actually is an interesting segue into this thing about discoverability because Emacs is quite unlike many other editors. It is very well documented and if you can figure out how to navigate and find that documentation and even how to make this fun for you, then you can do all sorts of interesting things with it. Okay, so self-documentation. I love telling people, okay, you can just press C-h k or describe-key to describe
anything. You can C-h f any function. You can, you know, C-h v any variable. describe- whatever is great. Of course, adding C-h to the end of the keyboard shortcut that you've started but you've forgotten how to finish, especially if you've turned on which-key mode, is great for listing the actual shortcuts that start with that sequence. Prot: And even without which-key, it will put all those shortcuts in a Help buffer, and it will show the key and the name of the command. Of course, you can click on the command to read about it. Sacha: Someday I think it would be amazing if Emacs comes with a completion interface that's easy for people to understand and get started with, but in the meantime, if you don't already have completion set up, that is well worth taking the time to figure out. Prot: Yeah, yeah. The built-in one has improved tremendously. I mean minibuffer.el here has improved tremendously over the various recent versions. But you still need to be aware of all the user options to configure it. So to get, for example, a single column view instead of a grid with 100 options... That requires some effort. Out of the box, if you really want something that is built into Emacs and does completion in a way that is fairly easy to understand, it would be icomplete-vertical-mode or fido or fido-vertical-mode. M-RET or M-p to send what you already
have there instead of selecting one of the completion options. This is helpful because sometimes you'll want to name a file something that is a substring of another file and you want to be able to say, yeah, that is actually what I meant, not the completion part. Prot: Yeah, yeah. I think that's the only rough edge with most of those, yeah. Where you have to be mindful of that or, you know, I have to select the prompt or I have to type a special key for this edge case. Yeah. Sacha: Once you get that sorted out and you've drilled it into your fingers, it's very, very helpful to have completion sorted out. C-h R is how you can search for the manual of a package. Like for example, I'm interested in Org. C-h R, Org. I find Org from anywhere, right? C-h R and then I will search for something else, right? Elisp, for example, to go to the Emacs Lisp reference manual. Again, very useful. From inside the manuals, g to go to a chapter, also known as a node, i to go to a topic, an index, and m if you want, but g
and i. Just think of g and i. Very, very
useful. m is also useful to navigate the menu of the current node. Sacha: I use s also for search. Prot: And there's for research throughout, yes. Sacha: Yes. I have not been using C-h R. I have been using C-h i to look at the whole list of info manuals and then using m or isearch like a newbie. Prot: That works. The problem with that is that if you have already gone into a manual, C-h i will take you back to that manual. So you have to click it and then start again. Sacha: Okay. Alright. Well, I'm learning new things. Prot: Nice. C-h k, which is describe-key,
it will work on menu items as well. If you're finding yourself always going to the menu to do this thing, sometimes the menu items are not named the same as their commands, but you can use C-h k to find out what that function is and what keyboard shortcuts it's bound to. Then you can call it with M-x directly, or you can memorize the keyboard shortcuts. deja vu with English, and then I have the French equivalent with all the fancy accents. Stuff like that you can do, like... something you keep misspelling the whole time you actually do it, right, something that is with an annoying spelling, like annoying capitalization like LaTeX. Nobody knows how that is written. You just write it latex, all lowercase, and then expand to whatever it should expand. This sort of thing is very useful. Of course, you can just have some short text which expands into very long text. Sacha: We should also point out if you type something that is normally an abbreviation like LaTeX, but in this case you actually want to write the word latex, then how do you do the abbreviation without it being expanded into whatever that is? Prot: Of course you would rather avoid that situation with your abbreviation. It wouldn't be like that, but otherwise you will have to undo. When you do SPC and it expands, you undo. That is a little bit annoying, for sure. But I would say, just make sure to have abbreviations that are not ordinary words. They are a little bit contrived, so you don't get false positives. A good use case here, like what I have in my configuration, like you can have your abbreviations behind a character such as the semicolon. Then of course it's very unlikely that you will have semicolon later. C-q to quote the next character literally. So here for example, I have ot expand to the current time, but if I say ot C-q SPC, this
helps. And in general, this idea of C-q to quote the next character is also useful in other places where you might, for example, need to add a literal new line to a search or something like that, or a literal tab. org-capture if you’re reading the manuals from within Emacs, which you can. If you org-capture, you can even select sections of the manual and it'll automatically save that in the capture template along with a link back to where you were looking. This is great. org-capture and we talked about bookmarks earlier, when you do org-capture or org-refile, it stores
a bookmark. You can go back to the last capture, the last refile. Sacha: Yeah, yeah, which is handy. Also, you can use org-refile to navigate your Org
files. In addition to using it to jump to the last thing that you filed because you were like, "Oh, yeah, wait, I forgot. I want to add more to that note," you can also use it to jump to any of your projects, for example, or any of your notes, assuming you’ve set up your org-refile-targets appropriately. Okay, @RandCode has question. Does Emacs have a grammar checker like Harper's LSP? I know there are packages that people can use to work with Harper and other things. Do you know of any other built-in things? Prot: Built-in, it's flyspell, but that's not grammar. That's spelling. Sacha: Okay, all right. Prot: I cannot think of something. No, I don't think there is for grammar. So Harper or anything like that would plug into Flymake. Sacha: @greggr0th has a question. What are your favorite completion plugins? Prot: Yeah, I think it's really vertico. I prefer it over the built-in options, over icomplete. So it's vertico, and then with that, I would say, at minimum, orderless. So vertico and orderless, at minimum. But then, of course, if you want a little bit more, which is very useful, Marginalia, Consult, Embark, maybe I'm forgetting something, save-hist, it's built-in. But yeah, those, those for sure. M-/, and it will search the buffer for something starting with what's on the left side of your point and then expand it. I can't remember if it's dabbrev or hippie-expand, but you can also set it up so that it can try words from other buffers or other things that you've got or contacts or whatever. Anyway, so dynamic abbreviations. If you search for dabbrev and if you look also for hippie-expand, you will find lots of things that you can configure to fit your particular workflow. So you can expand abbreviations without having to define them. Prot: Yeah, yeah, yeah. Super powerful. Super useful. I use it more than tab completion, you know, like with core. I use dabbrev more. It's very nice. Yeah. C-x C-k C-e to edit your macro. It's a text buffer. You just remove what you don't want. Sacha: You can save these keyboard macros as well. You can use them in a future Emacs session or even turn them into your first Emacs Lisp function. You can give it a name and you can run it that way. C-x C-q which turns it from read-only to something you can change, then you can do your search and replace in that, and you can C-x C-q again and those changes can get put back into all those different files. Prot: It's amazing. On this note, specifically for grep, if you edit many files with the grep edit mode that is built into Emacs 31, it will not save them for you. So C-x s, instead of C-x C-s, allows you to save multiple buffers. And every time, it gives you a prompt and you can type d to see the diff. Like, okay, what exactly did I change? If you have many unsaved files, d to see what you're about to save so you never make any mistakes. Sacha: Mm-hmm. Taking advantage of these diffing tools is great also. Even if you're new to Emacs or you don't have a programming background, if you find yourself making changes to lots of files, I strongly recommend learning more about version control systems like Git and then using something like Magit or even the built-in VC. If you use VC, you can use it and you have set up something like a git repository. You can use `C-x v =` to diff to see the changes between your file and the previous thing that you had saved. Which makes sense so that you can see, okay, these are the changes. Also it means that you can experiment with different changes. You can experiment with different ways of writing a paragraph or whatever, and you know that all of your previous versions are saved and you don't have "really, really final version two." You don't clutter your directory with a lot of copies of the same file. Prot: But even if you don't have any of the version control system set up, a very simple thing is diff-buffer-with-file. So you have a file you are working on and now you make some edits. The buffer, what is in memory, is different than what is on disk. You can compare the difference between the two. Sacha: Okay, I'm going to try to wrap up here because the kid is going to run and say hi very soon. Thank you so much for joining me. Of course, there's a lot more to talk about the Emacs built-ins, but I hope we've given a quick tour of some of the things that are definitely worth learning more about and the situations for which they are absurdly useful. Thanks to everyone in chat also for coming and hanging out. I will post the show notes eventually and get the transcripts sorted out. Thanks. Prot: You're welcome. You're welcome. Take care. Of course, good luck with everything. Didn't she show up here? Sacha: If she shows up, she will. It's inevitable. Chat
- protesilaos: Looking forward to this! Talk to you soon.
- gr1maldi: Yo, and stuff.🙂
- charliemcmackin4859: I just checked, there are 11 items in my kill-ring at the moment. Some of them are several lines long
- charliemcmackin4859: narrowing to defun feels easier than trying to mark the function before search-and-replacing… I love narrowing
- charliemcmackin4859: …and I love that you can make those marking tricks part of a keyboard macro
- hmelman: both local and global marks are useful to navigate through
- pratikmishra4073: just tried indirect buffer. didn't know it existed
- hmelman: and the fact that things like xref or imenu push the last location before jumping, means popping the mark is an easy way to go back from various navigation mechanisms
- matthewjorgensen9115: thinking about isearrch wrap around search losing your place. either have scrroll to posisiotn to know the direction and how far it was away, or have mode line flash to say it moved from last to first
- hmelman: Don't need flymake for that just M-g M-n (next-error) which works with compile, grep, occur (I think).
- hmelman: One I keep forgetting about, you mentioned using sexp commands in other languages, works in prose too. C-M-u (backwards-up-list) moves you out of a "quote" or (paren) and then C-M-e to the end of it.
- matthewjorgensen9115: follow mode alllows the smae file with multiple frames, like a book. follow mode can work with 2 3 or more windows
- matthewjorgensen9115: also works with centered cursor mode which will keep the cusor possion in the middle of the frame
- RandCode: Damn I am late, hello everyone! 🙂
- matthewjorgensen9115: when highlighting parts of the manual how are you doing this? in bookmarks, bookmark region, using org-remark? other ways?
- RandCode: Does emacs have a grammar checker like harper's lsp?
- greggr0th: What are your favorite completion plugins?
- RandCode: Also, looking fresh Prot ;)
- protesilaos: Thanks!
- hmelman: dabbrev is underrated. You don't need to pre-define them, just type the start of a word/symbol and type M-/ and it will search the buffer for something starting with what's left of point and expand it
- RandCode: There is so much to learn that I feel like I have been missing out on all of emacs somehow lol
- RandCode: Since you mentioned built-in completion framewworks, how does the built-in (vertical) completions compare to corfu btw?
- charliemcmackin4859: not grammar, but if you have a dictionary server running (like dicod on linux) emacs can be made to communicate with it to give definitions at point
- RandCode: Ohh, that is a cool! ^
- matthewjorgensen9115: virtico multiform mode allows custom settings command, for example for files I use grid and alphabetical, but vertico recommendations normally. This allows more value of completion knowledge
- RandCode: Thank you so mcuh for this wonderful stream everyone!!!




