【问题标题】:emacsclient window focusemacsclient 窗口焦点
【发布时间】:2010-09-03 14:25:06
【问题描述】:

如何在运行 emacsclient 后持续控制窗口焦点?

目前,重点取决于我是否已经运行了 emacs 服务器。当 emacsclient 调用替代编辑器时,焦点转移到新的 emacs 窗口。当 emacsclient 连接到现有的 emacs 服务器时,焦点不会转移(即它停留在我的 putty 客户端上)。

我希望始终专注于 emacs 窗口,因为我通常会在打开文件后转到 emacs。

任何帮助将不胜感激!

备注

版本信息

emacs: 21.4.1
emacsclient: 21.4
client os: Windows XP Service Pack 3
x server: Exceed 11.0.0.0

我的 .bash_profile 的相关部分

# a wrapper is needed to sandwich multiple command line arguments in bash
# 2>/dev/null hides
#   "emacsclient: can't find socket; have you started the server?"
emacs_wrapper () {
  if [ 0 -eq $# ]
  then
    emacsclient -n -a emacs ~/notes.txt 2>/dev/null &
  else
    emacsclient -n -a emacs $* &
  fi
}
alias x="emacs_wrapper"

另外,在我的 .emacs 结尾处,我有

(server-start)

我目前的解决方法是一个简单的自动热键脚本,它专注于我的第一个 Exceed 窗口

^+x::
If WinExist("ahk_class EXCEEDW:MWCLIENT0")
    WinActivate
return

作为旁注,似乎我重定向到 /dev/null 混淆了语法高亮 :(

【问题讨论】:

  • 这可能对您没有帮助,但在使用 23.2.2 和 Ubuntu 时,焦点似乎转移到了现有的 emacs 窗口。
  • 我怀疑在 Windows 上使用 X-server 会使情况变得复杂。您是否考虑过在 Windows 上使用 emacs? 23.2 可预编译:ftp.gnu.org/gnu/emacs/windows
  • 我实际上已经安装了 emacsw32。然而,通过 CIFS 共享工作的速度非常缓慢:(

标签: emacs emacsclient


【解决方案1】:

怎么样:

emacsclient -e  "(select-frame-set-input-focus (selected-frame))"

在 emacs 23.1 上为我工作

让(lower-frame) 失去焦点可能有用。

【讨论】:

  • 感谢您的建议!我尝试了这个修复,它似乎表现出正确的行为。不幸的是,我不能明确地将功劳归功于此修复,因为如果没有此修复,问题将不再存在。
【解决方案2】:

emacsclient 的“--create-frame”选项对你有用吗?以这种方式打开的每个文件都会得到一个新框架,但至少它会集中注意力(我认为)。

【讨论】:

  • 感谢您的建议!但是,问题自行解决了(请参阅我在 2010-10-12 上的回答)。附带说明一下,如果我使用这种方法,我会创建大量的帧。
【解决方案3】:

由于某种未知原因,问题自行解决了。现在打开文件会始终将焦点更改为具有相应文件的 emacs 框架。老实说,我不确定是什么改变了这种行为,但我很高兴。

感谢大家的cmets和建议!

【讨论】:

    猜你喜欢
    • 2012-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多