Comment by pkulak

Comment by pkulak 2 days ago

10 replies

My hang up is that I live in the terminal. What eMacs folks seem to do is use the terminal in eMacs, kinda in place of tmux? Is that right? And what terminal is the best? Is it really as nice as something like Foot? What happens if you open a text file in an eMacs terminal?

skydhash 9 hours ago

In lieu of the terminal, I use shell-mode for CLI tools. For the rare TUIs i need there’s always ansi-term. And there’s shell-command and async-shell-command for one-off things and `compile` for anything that present a report about files (build, lint, and test).

binary132 2 days ago

I usually just use emacs in one terminal tab and tmux / bash in another. The more you get familiar with emacs though, the more you tend to get things done in emacs without using a terminal at all. Magit and the file interface are both generally a lot better than terminal living. You _can_ drop into a shell window, but in my experience it’s usually easier just to keep a terminal around if you need it.

rich_sasha 2 days ago

I use Emacs exclusively in the terminal, with standard platform terminals (iterm on Mac, windows terminal on windows). Works great.

  • pkulak 2 days ago

    You mean, you use eMacs in terminal mode? I thought that was frowned upon? Isn’t a lot of the benefit is eMacs that you can get a true GUI, with no keybinding limitations, varying font sizes, etc?

    • rich_sasha a day ago

      I wasn't aware of any frowniness! Sure, there are some features you can only access via gui, but I'd say they are extremely minimal in my workflow:

      - real buttons in GUI

      - rendering inline images/LaTeX

      - varies fonts (eg font sizes)

      There may be others but I can't think of them. Neither of the above is things I do more often than a handful of times a year.

      Meanwhile, terminal Emacs plays well with tmux and SSH which I do a lot of. For example, a workflow I have is to SSH to a Linux box, start a tmux session and have Emacs/ipython/jupyter with port forwarding open on the remote box. I can steal this tmux session from any new connection. It also survives if the machine I'm sshing from dies or reboots. I can't think of a way to make it work with GUI emacs.

    • brucehoult 2 days ago

      I guess some people can frown on anything.

      I 99% of the time use emacs in a terminal. 90% of the time over ssh or in a non-GUI VM/docker etc.

      I usually install emacs-nox to speed up the install.

      Vanilla emacs is fine. Maximum I scp my .emacs file from another machine, but there's actually very little in it. Mostly it's disabling the menu bar, tool bar, and scroll bars.

      Usually all I'll do is adjust things such as indenting and other code formatting things to match the codebase I'm working on -- which varies from project to project anyway, and you need to do with any editor to avoid making a mess.

      I do have one little elisp function that tries to find and open the header file for the C file I'm currently in, or the c, cc, cpp, c++ file for the header file I'm in.

      I'll reproduce that below, if anyone cares. Please don't laugh too much at my elisp -- I probably wrote that in the 90s.

          ;;;;;;;;;;;; Automatic switching between source and header files ;;;;;;;;;;;;;;;;
          
          (defvar c++-source-extension-list '("c" "cc" "C" "cpp" "c++" "pcc" "pc"))
          (defvar c++-header-extension-list '("h" "hh" "H" "hpp"))
          (defvar c++-header-ext-regexp "\\.\\(hpp\\|h\\|\hh\\|H\\)$")
          (defvar c++-source-ext-regexp "\\.\\(cpp\\|c\\|\cc\\|C\\|pcc\\|pc\\)$")
          
          (defun toggle-source-header()
            "Switches to the source buffer if currently in the header buffer and vice versa."
            (interactive)
            (let* ((buf (current-buffer))
                   (name (file-name-nondirectory (buffer-file-name)))
                   (check (lambda (regexp extns)
                            (let ((offs (string-match regexp name)))
                              (if offs
                                  (let ((file (substring name 0 offs)))
                                    (loop for ext in extns
                                          for test-file = (concat file "." ext)
                                          do (if (file-exists-p test-file)
                                                 (return (find-file test-file))))))))))
          
              (or (funcall check c++-header-ext-regexp c++-source-extension-list)
                  (funcall check c++-source-ext-regexp c++-header-extension-list))))
          
          (global-set-key [?\C-c ?`] 'toggle-source-header)
    • ksherlock 2 days ago

      The emacs GUI is basically a dog-shit terminal emulator that only runs emacs. Just run emacs in the terminal.

    • yablak 2 days ago

      You can set up the terminal+tmux to forward all the important keys to console emacs. I like iterm2 for its extreme configurability. Others say kitty terminal with the kitty term emacs library is great. I never got that working with tmux.

    • ksherlock a day ago

      By the way, Richard Stallman uses emacs from a text console. A text console! Not an xterm, not a terminal emulator, the text console.

Scarblac 2 days ago

If you want to quickly edit a file, you can also open emacs in the terminal with "emacs -nw".