質問
emacsclientでロードするユーザーのemacs initファイルを指定するにはどうすればよいですか?
emacsclient は '-u user' を理解せず、'-a ALTERNATE-EDITOR' はそれを引用して '-u user' を提供することを許可しません。
たとえば、次のように実行します。
/usr/bin/emacsclient -n -a '/usr/bin/emacs -u <username>' ~<username>/notes.txt
戻り値
/usr/bin/emacsclient: error executing alternate editor "/usr/bin/emacs -u <username>"
バックグラウンド
私は emacs バージョン 23.1.1 と emacsclient バージョン 23.1 を使用しています。
emacs 自体は、'-u user' をサポートして、指定されたユーザーの init ファイルをロードします。
エイリアス ファイルで次の bash 関数を使用して、emacs を呼び出します。
# a wrapper is needed to sandwich multiple command line arguments in bash
# 2>/dev/null hides
# "emacsclient: can't find socket; have you started the server?"
emacs_wrapper () {
if [ 0 -eq $# ]
then
/usr/bin/emacsclient -n -a /usr/bin/emacs ~<username>/notes.txt 2>/dev/null &
else
/usr/bin/emacsclient -n -a /usr/bin/emacs $* 2>/dev/null &
fi
}
alias x='emacs_wrapper'
x の後にファイルのリストを入力します。
- 既存の emacs サーバーが実行されている場合はそれに接続し、そうでない場合は新しいサーバーを開始します
- バックグラウンド プロセスとして実行
- ファイルが提供されていない場合は、ファイルのリストまたはメモ ファイルを開きます
これは、自分としてログインしているときにうまく機能します。ただし、多くのプロダクション ボックスでは、プロダクション ユーザーとしてログインする必要があります。エイリアスを bash スクリプトに分割したので、実行するだけでエイリアスと bash 関数を取得できます。
. ~<username>/alias.sh
残念ながら、これでは私の .emacs ファイル (~<username>/.emacs) を使用できません:(
この問題は私を夢中にさせてきました。