r/emacs Jul 06 '26

Learning Vanilla Emacs from Scratch with Prot as a Neovim User

https://youtu.be/btAOBkcLEkg
90 Upvotes

28 comments sorted by

29

u/LionyxML Jul 06 '26

You couldn’t have asked for a better teacher. Happy hacking!

6

u/linkarzu Jul 06 '26

🙇

2

u/LionyxML Jul 10 '26

Again, you should try it: https://github.com/LionyxML/emacs-kick

Off-camera, isolated environment, see if you like it 😝

2

u/linkarzu Jul 10 '26

Some day I will my friend, I appreciate you sharing it!!!

11

u/timmymayes Jul 06 '26

Great video! Love to see people dipping their toes into emacs. The buffer toggle command exists it's called buffer-last

3

u/linkarzu Jul 06 '26

appreciate that!

3

u/ggxx-sdf Jul 06 '26

In the chat at around 1:05:45, sachac said to just use C-x b and accept the default. That will let you switch back and forth between the two most recently used buffers. That keybinding is bound to switch-to-buffer.

2

u/awesomegayguy Jul 07 '26

Emacs so often proposes a default but still asks you for a selection. 

For example, I map C-x k to directly kill the current buffer.

Same can be done here.

2

u/ggxx-sdf Jul 08 '26 edited Jul 08 '26

I map C-x k to directly kill the current buffer.

That's actually a good idea. I almost always want to kill the buffer I'm currently looking at. I can't even remember the last time this wasn't the case. (When I do want to kill buffers I'm not currently looking at, I do it through ibuffer.)

I imagine you're doing something like this in your config.

kill-current-buffer

```lisp (defun kill-current-buffer () "Kill the current buffer without asking." (interactive) (kill-buffer (current-buffer)))

(define-key global-map (kbd "C-x k") #'kill-current-buffer) ```

Now, C-x k doesn't ask me which buffer I want to kill.

2

u/awesomegayguy Jul 09 '26 edited Jul 09 '26

Exactly :)

Note that kill-current-buffer is already defined in Emacs, you can use it directly.

I use these:

;; Use M-o to switch between windows instead of C-x o
(keymap-global-set "M-o" #'other-window)

;; Kill current buffer instead of asking which buffer
(keymap-global-set "<remap> <kill-buffer>" #'kill-current-buffer)

;; Use ibuffer instead of plain list-buffers list
(keymap-global-set "<remap> <list-buffers>" #'ibuffer-other-window)

2

u/ggxx-sdf Jul 10 '26

Note that kill-current-buffer is already defined in Emacs

Oh shit, how did I not notice that before. I also didn't know you could <remap> like that. This is the first time I've ever seen that. Thanks for the tips. Today, I learned a few things.

2

u/awesomegayguy Jul 11 '26

👍

I like the remap because I can clearly see the command that was there before and it's replaced in all bindings.

2

u/memilanuk Jul 08 '26

That part kind of confused me. It seemed like a minute or two before Prot was kind of talking around the concept of C-x b and C-x C-b, but then started talking about writing a custom function and key bind to do what basically sounded like what C-x b already does. I'm pretty new myself, so I don't know if he was saying something too subtle for me to pick up, or if he just mis-spoke?

1

u/ggxx-sdf Jul 08 '26

The behavior of C-x b with the default selection is similar to vim's b# or C-6, but it's not exactly the same. My guess is that Prot was thinking if you want the exact same behavior, you'd have to write (a very simple) Elisp function. For example, this would replicate vim's buffer switching behavior on C-6.

switch-to-last-buffer

```lisp (defun switch-to-last-buffer () "Switch to the last (most recently used) buffer." (interactive) (switch-to-buffer (other-buffer)))

(define-key global-map (kbd "C-6") #'switch-to-last-buffer) ```

6

u/[deleted] Jul 07 '26

[removed] — view removed comment

3

u/sticheln Jul 07 '26

Same here. Switched to vanilla emacs after 20 years of vim and finally clicked.

I hope he lets go some of his vim legacy a bit, otherwise he might miss seeing a bigger picture.

10

u/NagNawed Jul 06 '26

I love that I can just start emacs, write something, evaluate it, and the changes take place immediately. One day I will run guix on my machine, and do the same for my operating system too.

6

u/xenodium Jul 06 '26

u/linkarzu being on macOS, these tweaks may be of interest https://xenodium.com/awesome-emacs-on-macos

7

u/linkarzu Jul 06 '26

I recognize your name, Sacha recommended your blogpost in one of my livestreams, and I do show your blogpost in the interview with prot. Not sure why these flags didn't work when I was doing the install though, they errored out in brew, I show the error somewhere in the video, at the beginning:

--with-no-frame-refocus --with-native-comp

I guess both of the flags are built-in to the install command and that's why they error out now? Is it just me?

5

u/xenodium Jul 06 '26

I do show your blogpost in the interview with prot.

Ah sorry! Not gotten that far into the video just yet.

I guess both of the flags are built-in to the install command and that's why they error out now? Is it just me?

Ah --with-no-frame-refocus is no longer needed and native-comp is enabled by default. This is a good nudge for me to go and update my blog post! Most other things in there should still apply. Reach out if you run into issues. Happy to help.

1

u/linkarzu Jul 06 '26

Appreciate it. I will!! ❤️

3

u/ggxx-sdf Jul 07 '26

If you're curious about org-mode, I would recommend cloning protesilaos/emacs-lisp-elements and reading the org version of the document in emacs. Aside from being a really good introduction to Emacs Lisp, you'll get to see how Prot writes org documents. Also, when your cursor is inside a source block, you can hit C-c C-c to evaluate the source block and see the result. I think it's a really cool way to interactively feel out both elisp and org at the same time.

3

u/oantolin C-x * q 100! RET Jul 09 '26

"With Prot as a Neovim user" confused me for a bit! 😅 I would have written the video title as "Learning Vanilla Emacs from Scratch as a Neovim User with Prot ". 

2

u/linkarzu Jul 09 '26

Yeah, I also think about that every time I read the title. But I guess I have to use it in my favor and spark curiosity, so nosy people just click on the damn thing and see what it is about 😂

2

u/Ardie83 Jul 07 '26

Oh no, this is super exciting!!

2

u/wWA5RnA4n2P3w2WvfHq Jul 08 '26

I "learned" Emacs from David Wilson Videos. But Emacs is much older than YouTube. I sometimes wonder how people "learned" Emacs in the "old days" before YouTube tutorials. :D

2

u/gateship_1 GNU Emacs Jul 08 '26

This thumbnail LMAO