Emacs:使用 emacsclient

Emacs:使用 emacsclient

我總是將 emacs 設定為在伺服器模式下運行,每次更新 Ubuntu 時,執行此操作的過程都會發生變化。

即使我的/.bash_aliases和中具有所有相同的設置/.emacs,它也不起作用。

我有 emacs 24.3.x(無論最新版本是什麼),我有 AUCTeX cvs 和 TeX Live 2013 安裝。

在我的./bash_aliases,我有

emacs = 'emacsclient -t --alternate-editor='

我的相關資訊/.emacs

;; Start server and set directory                                               
(setq server-socket-dir (format "/tmp/emacs%d" (user-uid)))
(server-start)

(custom-set-variables
 '(TeX-PDF-mode t)
 '(TeX-show-compilation t)
 '(TeX-newline-function (quote newline-and-indent))
 '(TeX-source-correlate-method (quote synctex))
 '(TeX-source-correlate-mode t)
 '(TeX-source-correlate-start-server t))

僅在開啟 LaTeX 檔案時才會出現問題。有時它說另一台伺服器正在運行,有時它說:

dustin@dustin:~/Documents/NUPOC/NUPOCSoln$ emacs SolnNUPOC.tex 
emacsclient.emacs24: can't find socket; have you started the server?
To start the server in Emacs, type "M-x server-start".
Warning: due to a long standing Gtk+ bug
http://bugzilla.gnome.org/show_bug.cgi?id=85715
Emacs might crash when run in daemon mode and the X11 connection is unexpectedly lost.
Using an Emacs configured with --with-x-toolkit=lucid does not have this problem.
("emacs")
Loading 00debian-vars...
Loading 00debian-vars...done
Loading /etc/emacs/site-start.d/50autoconf.el (source)...
Loading /etc/emacs/site-start.d/50autoconf.el (source)...done
Loading /etc/emacs/site-start.d/50cmake-data.el (source)...
Loading /etc/emacs/site-start.d/50cmake-data.el (source)...done
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...
Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...
Error while loading 50dictionaries-common: Symbol's value as variable is void: debian-aspell-only-dictionary-alist
Loading paren...
Loading paren...done
Warning: no abbrev-file found, customize `abbrev-file-name' in order to make mode-specific abbrevs work. 
Starting Emacs daemon.
Restarting server

我讀到手動的註腳:


有些程式使用不同的環境變數;例如,要使 TeX 使用“emacsclient”,請將 TEXEDIT 環境變數設定為“emacsclient +%d %s”。


沒有提及(我可以找到)在哪裡以及如何設定 TEXEDIT 環境。

  1. 如何設定 TEXEDIT 環境?或者
  2. 如何設定 emacsclient 工作?

在必須重新安裝所有內容之前,此設定就有效了。

答案1

我能夠讓伺服器啟動並工作synctex。它仍然會發出此訊息:

emacsclient: can't find socket; have you started the server?
To start the server in Emacs, type "M-x server-start".

Warning: due to a long standing Gtk+ bug
http://bugzilla.gnome.org/show_bug.cgi?id=85715
Emacs might crash when run in daemon mode and the X11 connection is unexpectedly lost.
Using an Emacs configured with --with-x-toolkit=lucid does not have this problem.
Loading paren...
Loading paren...done
Loading server...
Loading server...done
Warning: no abbrev-file found, customize `abbrev-file-name' in order to make mode-specific abbrevs work. 
Starting Emacs daemon.
Restarting server
Emacs daemon should have started, trying to connect again

我改變的是我的/.bash_aliases/.emacs

如果您先開啟 emacs 而不指定文件,然後再開啟文件,您將不會收到上述警告。我不知道為什麼它按照這個順序完美地工作,而不是直接進入文件。

對於我的別名,我現在有:

# emacs aliases for server mode
alias emacs='emacsclient -t -s server --alternate-editor='

是;-s的縮寫--socket-name=。因此,-s server--socket-name=server

M-x describe-variable那時我發現了這個server-socket-name,名稱應該會為你輸出。另外,我們可以用相同的方式找到目錄M-x,然後server-socket-dir

在我的中~/.emacs,我改變了:

;; Start server and set directory                
(setq server-socket-dir (format "/tmp/emacs1000" (user-uid)))
;(server-start)  has been commented out

在自訂設定變數中,我新增了:'(server-mode t)

我不知道(server-start)和自訂變數之間是否有區別'(server-mode t)。我將使用其中之一或兩者進行測試,看看稍後會發生什麼。

相關內容