我想在守护进程模式下运行我的Emacs,然后emacsclient
用来实际显示东西.但是,如果我跑emacsclient filename
,它会出现在终端,这不是我想要的; 我不得不把它传给它-c
.
但是,该选项总是创建一个新帧,这不是我想要的 - 我宁愿只有一个帧,并且如果它已经存在,则在同一帧中的新缓冲区中打开东西; 否则,它应该让我成为一个新的框架.但是,我不知道该怎么做.
另外,我希望最大化一个帧,我通常用-mm
选项实现我的起始Emacs ; 我如何确保emacsclient
最大化的框架?
以下脚本执行以下操作:
#!/bin/bash
# Selected options for "emacsclient"
#
# -c Create a new frame instead of trying to use the current
# Emacs frame.
#
# -e Evaluate the FILE arguments as ELisp expressions.
#
# -n Don't wait for the server to return.
#
# -t Open a new Emacs frame on the current terminal.
#
# Note that the "-t" and "-n" options are contradictory: "-t" says to
# take control of the current text terminal to create a new client frame,
# while "-n" says not to take control of the text terminal. If you
# supply both options, Emacs visits the specified files(s) in an existing
# frame rather than a new client frame, negating the effect of "-t".
# check whether an Emacs server is already running
pgrep -l "^emacs$" > /dev/null
# otherwise, start Emacs server daemon
if [ $? -ne 0 ]; then
emacs --daemon
fi
# return a list of all frames on $DISPLAY
emacsclient -e "(frames-on-display-list \"$DISPLAY\")" &>/dev/null
# open frames detected, so open files in current frame
if [ $? -eq 0 ]; then
emacsclient -n -t "$@"
# no open frames detected, so open new frame
else
emacsclient -n -c "$@"
fi
Run Code Online (Sandbox Code Playgroud)
编辑:固定扩展位置参数(2017-12-31).
为了使每个新框架最大化,您可以将其添加到您的 .emacs 中:
(modify-all-frames-parameters '((fullscreen . maximized))))
Run Code Online (Sandbox Code Playgroud)