尝试运行 emacsclient 时出现“未知终端类型”错误

uno*_*nor 6 debian emacs

(我正在使用emacs23;在 Debian 7 上;Xfce。)

我想尝试Gilles 推荐的使用 Emacs 做快速笔记的解决方案

尝试运行时emacsclient -a "" -e "(remember-other-frame)",出现以下错误:

*错误*:未知终端类型

怎么了?


(不太确定我在做什么,)我尝试从 Emacs 中启动服务器:Ctrl+x并输入server-start. 然后它说:

警告(服务器):无法启动 Emacs 服务器。
有一个现有的 Emacs 服务器,名为“服务器”。
在这个 Emacs 进程中启动服务器,停止现有的
服务器或者调用 `Mx server-force-delete' 强行断开它。

Ctrl+x并输入时server-force-delete,它说:

连接文件“/tmp/emacs1000/server”已删除

当我现在emacsclient -a "" -e "(remember-other-frame)"从不同的终端窗口emacs -nw运行时(仍然在第一个窗口中运行),我得到:

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.
("emacs")
Loading 00debian-vars...
Loading 00debian-vars...done
Loading /etc/emacs/site-start.d/50a2ps.el (source)...
Loading /etc/emacs/site-start.d/50a2ps.el (source)...done
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...
Loading debian-ispell...
Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...
Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...done
Loading debian-ispell...done
Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...
Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...done
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...done
Starting Emacs daemon.
Emacs daemon should have started, trying to connect again
*ERROR*: Unknown terminal type
Run Code Online (Sandbox Code Playgroud)

[编辑] 请求的信息

的输出echo $TERM; echo $DISPLAY

xterm
:0.0
Run Code Online (Sandbox Code Playgroud)

您是从终端模拟器运行它吗,如果是,是哪个,如果不是,在哪里?

我不确定什么是“终端模拟器”,但我使用的终端设备将自身(在“信息”菜单中)标识为:Xfce 终端模拟器(终端 0.4.8)。这是安装 Debian 7 + Xfce 时的默认设置。


你在有什么~/.emacs~/.emacs.d

  • ~/.emacs 不存在。
  • ~/.emacs.d仅包含一个子文件夹auto-save-list(其中包含名称以 开头的空文件.saves)。

Gil*_*il' 9

错误的解释

remember-other-frame调用switch-to-buffer-other-frame 它调用display-buffer与变量pop-up-frames设置为t。这导致make-frame使用参数调用pop-up-frame-alist。该函数make-frame在与当前选定的帧相同的显示设备上创建一个帧。(Emacs 所谓的框架就是 GUI 所谓的窗口,除了框架也可以在文本终端中。)此时 Emacs 仍然在守护进程模式下运行,所以没有被选中的框架。因此make-frame看不到GUI环境,认为应该创建一个终端框架,但也没有文本终端,导致出现令人困惑的错误信息“未知终端类型”。

简单但笨拙的解决方法

remember-other-frame是从现有 Emacs 窗口中调用的正确函数,但从 emacsclient 调用在技术上是错误的。在那里,我们应该使用-c选项让 Emacs 创建一个新框架,以及普通remember函数。

emacsclient -a "" -c -e "(remember)"
Run Code Online (Sandbox Code Playgroud)

然而,这不是很好,因为remember创建了一个必须用 关闭的窗口C-c C-c(这也是保存注释的东西),然后框架必须用 关闭C-x 5 0。如果您忘记了C-c C-c(这更有可能是因为要键入C-x 5 0的消息会覆盖C-c C-c在回显区域中要键入的消息),该注释甚至不会被保存。

更好的解决方法

make-frame明确指示在当前 X 显示上创建框架。

emacsclient -a "" -e "
    (let ((pop-up-frame-alist \`((window-system . x)
                                 (display . \"$DISPLAY\")
                                 ,@pop-up-frame-alist)))
      (remember-other-frame))"
Run Code Online (Sandbox Code Playgroud)

您可以将所有内容放在一行中,只需确保不要更改标点符号。

emacsclient -a "" -e "(let ((pop-up-frame-alist \`((window-system . x) (display . \"$DISPLAY\") ,@pop-up-frame-alist))) (remember-other-frame))"
Run Code Online (Sandbox Code Playgroud)