【发布时间】:2011-06-24 00:40:33
【问题描述】:
当我运行 emacsclient 时,它不会响应鼠标点击。我的主要 Emacs 进程在终端中运行并正确响应鼠标点击,因为我的 Emacs 配置文件中有以下代码:
(xterm-mouse-mode 1)
为什么 emacsclient 不响应鼠标点击?有没有办法让它这样做?
【问题讨论】:
标签: emacs mouseevent gnu-screen xterm emacsclient
当我运行 emacsclient 时,它不会响应鼠标点击。我的主要 Emacs 进程在终端中运行并正确响应鼠标点击,因为我的 Emacs 配置文件中有以下代码:
(xterm-mouse-mode 1)
为什么 emacsclient 不响应鼠标点击?有没有办法让它这样做?
【问题讨论】:
标签: emacs mouseevent gnu-screen xterm emacsclient
这可能是因为 Emacs 中的某些设置特定于 终端,并且在您的 init 文件中操作此类设置只会影响在评估 init 文件时处于活动状态的终端。
下面的 Q+A 处理了大致相同的问题,并详细说明:
Run command on new frame with daemon/client in Emacs
对于您的问题,我认为这应该可以解决问题:
(defun my-terminal-config (&optional frame)
"Establish settings for the current terminal."
(if (not frame) ;; The initial call.
(xterm-mouse-mode 1)
;; Otherwise called via after-make-frame-functions.
(if xterm-mouse-mode
;; Re-initialise the mode in case of a new terminal.
(xterm-mouse-mode 1))))
;; Evaluate both now (for non-daemon emacs) and upon frame creation
;; (for new terminals via emacsclient).
(my-terminal-config)
(add-hook 'after-make-frame-functions 'my-terminal-config)
【讨论】:
xterm-mouse-mode 是一种全局次要模式,我的代码存在缺陷,如果您故意禁用该模式,然后创建一个新框架,它将再次打开。我已经相应地编辑了代码。我认为该模式足够智能,不需要我最初包含的window-system 检查(无论如何这不足以识别 xterm)。
xterm-mouse-mode?在after-make-frame-functions 中使用它?还有什么?
after-make-frame-functions 中的调用运行良好。 (my-terminal-config) 调用可能会触发该错误。将其注释掉即可解决。另请注意,这只是 emacsclient -nw 错误。