logoalt Hacker News

pkulakyesterday at 1:43 AM5 repliesview on HN

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?


Replies

rich_sashayesterday at 11:30 AM

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.

brucehoultyesterday at 3:11 AM

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)
ksherlockyesterday at 2:47 AM

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

yablakyesterday at 6:26 AM

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.

ksherlockyesterday at 4:06 PM

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