-
Launch Emacs quicker
- How?
- Start Emacs server first (if not already running), then launch
emacsclient
- Start Emacs server first (if not already running), then launch
- How?
-
Launch different Emacs servers in different sessions
- Ex: different servers for different
tmuxsessions and GUI mode. - Why?
- We can work on one git repository in one
tmuxsession by isolating opened buffers and tags tables (visit-tags-table).
- We can work on one git repository in one
- Ex: different servers for different
Use the qe command to replace emacs -nw:
$ qe
$ qe [files-to-edit]Use the qew command to replace emacs (GUI mode):
$ qew
$ qew [files-to-edit]If you want to kill the background server process to save memory,
M-x kill-emacs to kill all the clients and the server in the current
session. But the startup latency will increase next time when you run qe/qew again.
C-h v server-name(the currrent Emacs server/socket name)
If you want to run multiple qe in tmux to look like a tab-like UI,
add this to .emacs:
(defun my-tmux-getenv (variable)
"Return VARIABLE from the environment of the selected frame's terminal."
(getenv variable (selected-frame)))
(defun inside-tmux-p ()
"Return non-nil if the selected frame is displayed inside a tmux pane."
(and (my-tmux-getenv "TMUX") (my-tmux-getenv "TMUX_PANE")))
(defun my-truncate-string (string max-length)
(if (<= (length string) max-length)
string
(concat (substring string 0 max-length) "..")))
(defun update-tmux-title (&rest _)
"Update the tmux window showing the selected frame to its buffer's name."
(when (inside-tmux-p)
(let* ((buffer (window-buffer (selected-window)))
(name (file-name-nondirectory
(or (buffer-file-name buffer) (buffer-name buffer))))
(title (concat "e:" (my-truncate-string name 15))))
(unless (equal title (frame-parameter nil 'my-tmux-title))
(set-frame-parameter nil 'my-tmux-title title)
(call-process "tmux" nil 0 nil
"-S" (car (split-string (my-tmux-getenv "TMUX") ","))
"rename-window" "-t" (my-tmux-getenv "TMUX_PANE")
title)))))
(add-hook 'window-configuration-change-hook #'update-tmux-title)
(add-hook 'window-selection-change-functions #'update-tmux-title)- Recommended to use Homebrew to install Emacs with both GUI and terminal support:
$ brew install --cask emacs- Homebrew may register Emacs server in the background with
LaunchServicesof Mac OS:
# Check
$ brew services list
# Stop it if you want
$ brew services stop emacs