Re:Using Emacs as $Editor
by uxp8u61q on Monday October 02, 2023 @08:02AM
(#37737055)
That's definitely the way. When I used to use Emacs, it was always running, and my $EDITOR was set to emacsclient. I had two monitors, one fully dedicated to Emacs, the other to the rest.
[ Parent
| on HN ]
Yep, likewise. I'm using emacsclient as $EDITOR too and it works well.
I find it helpful also not just because of the startup speed, but because I usually have one or more org buffers open taking notes on what I'm doing.
> I find it helpful also not just because of the startup speed, but because I usually have one or more org buffers open taking notes on what I'm doing.
As someone who lives in org, this is the way. I'm still shell bound for a lot of things, but M-x shell is far superior, there's just no contest. Only thing that is annoying is stupid things like git diff that think they know better than you and want to do their own paging resulting in "WARNING: terminal is not fully functional". Thankfully I use EGG, but when I forget (and other things do it too), it's annoying.
Re:Using Emacs as $Editor
by ataylor284_ on Monday October 02, 2023 @12:10PM
(#37740101)
Yeah, it's a seamless experience to run a program in shell-mode that invokes $EDITOR and it just pops into a new buffer. Edit, hit C-x #, and you're back at the shell.
Re:Using Emacs as $Editor
by earthscienceman on Monday October 02, 2023 @01:14PM
(#37741272)
Wait, I'm confused, because you might have found a solution to something that's bothered me for a long time. I use emacsclient -t as $EDITOR and editor is invoked at a normal emulator, it opens a new buffer in the terminal. Great. But if I'm using vterm inside emacs anything that invokes editor then tries to open a buffer inside vterm and I'm now in a weird recursive state that locks up. Having some lisp that checks if I'm in vterm when editor is invoked and instead opens it in my current client session would be great. I searched for this at some point but gave up.
Have you considered overriding the Emacs process EDITOR variable via setenv? i.e.:
(setenv "EDITOR" "/usr/bin/emacsclient -c")
If you do that, it should cause any child processes (e.g.: vterm) to inherit the replaced EDITOR variable and properly open new editor frames instead of trying to do a terminal takeover.
Re:Using Emacs as $Editor
by earthscienceman on Monday October 02, 2023 @02:28PM
(#37742391)
Well,this is extremely clever and simple. I tried that out from vterm in 29.1 and it crashed emacs...
Personally, I got tired of weird quirks like this with vterm and now bind this command to the key I used to have vterm on to spawn my actual terminal (st) in my current directory. It's probably not what most people want from vterm, but I prefer it.
(defun open-term-here ()
"open st in `default-directory`"
(interactive)
(call-process-shell-command
(concat "st bash -c \"cd "
default-directory
" && exec zsh\"")
nil 0))I also do this, C-x t to open a tmux tab to whatever directory the current buffer is:
(defun tmux-here ()
(interactive)
(if (not (eq (getenv "TMUX") ""))
(shell-command (format "tmux new-window -c %s" default-directory))
(error "Not inside a tmux session.")))
I know, I know, tmux is slow and should never be used. I like it, OK.