あなたはそれを行うことができます-a ''
が、私や多くの人が行っていることは、基本的に複数のステップでemacsclient
行うことを行うある種のスクリプトを用意することです.emacsclient ''
私のバージョンは、この BASH スクリプトのようなものです。関心のある部分はensure-server-is-running
関数です。これはスクリプトの「主な機能」です。次に続くのはensure-server-is-running
機能であり、残りは好奇心のためにその後にありますが、質問への回答には貢献しません。
#!/bin/bash
# ec.sh
#
# [function definitions]
#
ensure-server-is-running
ensure-frame-exists
focus-current-frame
サーバーが稼働していることの確認
# ec.sh function definition
# From https://emacs.stackexchange.com/a/12896/19972
function server-is-running() {
emacsclient -e '(+ 1 0)' > /dev/null 2>&1
}
function ensure-server-is-running(){
if ! server-is-running ; then
echo "Need to start daemon, press enter to continue, C-c to abort"
read
emacs --daemon
fi
}
他の 2 つの機能は次のとおりです。
# ec.sh function definition
# From https://superuser.com/a/862809
function frame-exists() {
emacsclient -n -e "(if (> (length (frame-list)) 1) 't)" 2>/dev/null | grep -v nil >/dev/null 2>&1
}
function ensure-frame-exists() {
if ! frame-exists ; then
emacsclient -c --no-wait
fi
}
# From https://emacs.stackexchange.com/a/54139/19972
function focus-current-frame() {
# Doesn't work a frame exists and is in a terminal
emacsclient --eval "(progn (select-frame-set-input-focus (selected-frame)))"
}
focus-current-frame
OSがあなたを現在のEmacsフレームに入れるものです。これが最も重要な機能です。私にとっては、これを適応させたバージョンを MacOS Automator アプリに挿入します。emacs GUI フレームがある場合、Spotlight Search "EmacsC" を実行すると (通常は "e" と入力するだけで十分です)、emacs ウィンドウが表示されます。これは、emacs ウィンドウに切り替える超高速の方法です。