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)。我将使用其中一个或两者进行测试,看看稍后会发生什么。

相关内容