2013-04-09 41 views
3

我通常會打開3或4個emacs,因爲我在3個或4個不同的工作區中工作。現在,當我嘗試使用emacsclient打開一個新文件時,我無法控制它轉到哪個emacs。通常它會轉到其他工作區中的emacs。有沒有辦法指定哪些emacs打開它?使用特定的emacs服務器

一種方法是重新啓動服務器,我希望該文件去,但它不是我正在尋找的解決方案。

回答

3

你可以給服務器套接字文件中的特定名稱,然後調用emacsclient使用該插座:

(defun get-tmpdir() 
    (or (getenv "TMPDIR") "/tmp")) 

(defun start-named-server (name) 
    (let ((server-name (format "%s/emacs-%s" (get-tmpdir) name)) 
     (server-start)) 

現在定義一個shell腳本「EC」,這將允許你指定的服務器名稱:

emacsclient -s ${TMPDIR-/tmp}/emacs-${1?"usage: ec [emacs server name] ..."} "[email protected]" 

所以現在你可以在你的emacs中運行M- :(start-named-server「1」)之後去「ec 1 myfile」,然後用2,3,4重複你所有其他的emacs' ...

5

Burton's s解決方案在正確的軌道上,但過於複雜,因爲你不需要與臨時目錄的名字爭執。你可以這樣做:

(defun start-named-server (name) 
    (let ((server-name name)) 
    (server-start))) 

然後用

emacsclient -s <name> "[email protected]"