Linux command
emacsclient 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Open file
emacsclient [file.txt]
Open file
emacsclient -nw [file.txt]
Open file
emacsclient -c [file.txt]
Open file
emacsclient -n [file.txt]
Evaluate Emacs Lisp
emacsclient -e "(message \"Hello\")"
Start alternate editor
emacsclient -a "" [file.txt]
Create new frame
emacsclient -cn [file.txt]
Connect to specific socket
emacsclient -s [server_name] [file.txt]
说明
emacsclient connects to an existing Emacs server process to open files or evaluate Lisp expressions. This allows quick file editing without starting a new Emacs instance, dramatically reducing startup time. The Emacs server must be started first with M-x server-start or by adding (server-start) to the init file. emacsclient then communicates with this server to open files in existing or new frames. This workflow is common for using Emacs as an external editor for other programs (git, crontab) or as a quick command-line editor while maintaining a persistent Emacs session.
参数
- -n, --no-wait
- Return immediately, don't wait for editing.
- -c, --create-frame
- Create a new graphical frame.
- -nw, -t, --tty
- Open in terminal, not graphical frame.
- -e, --eval
- Evaluate argument as Emacs Lisp.
- -a _editor_, --alternate-editor= _editor_
- Use editor if no server (empty string starts daemon).
- -s _name_, --socket-name= _name_
- Connect to named server socket.
- -f _file_, --server-file= _file_
- Use server file for TCP connection.
- -q, --quiet
- Don't display messages.
- --version
- Display version information.
- --help
- Display help information.
FAQ
What is the emacsclient command used for?
emacsclient connects to an existing Emacs server process to open files or evaluate Lisp expressions. This allows quick file editing without starting a new Emacs instance, dramatically reducing startup time. The Emacs server must be started first with M-x server-start or by adding (server-start) to the init file. emacsclient then communicates with this server to open files in existing or new frames. This workflow is common for using Emacs as an external editor for other programs (git, crontab) or as a quick command-line editor while maintaining a persistent Emacs session.
How do I run a basic emacsclient example?
Run `emacsclient [file.txt]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -n, --no-wait do in emacsclient?
Return immediately, don't wait for editing.