emacsclient窗口焦点

vle*_*lee 12 emacs emacsclient

运行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
Run Code Online (Sandbox Code Playgroud)

我的.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"
Run Code Online (Sandbox Code Playgroud)

另外,在我的.emacs结束时,我有

(server-start)
Run Code Online (Sandbox Code Playgroud)

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

^+x::
If WinExist("ahk_class EXCEEDW:MWCLIENT0")
    WinActivate
return
Run Code Online (Sandbox Code Playgroud)

作为旁注,似乎我的重定向到/ dev/null混淆了语法 - 荧光笔:(

Vit*_*hKa 8

怎么样:

emacsclient -e  "(select-frame-set-input-focus (selected-frame))"
Run Code Online (Sandbox Code Playgroud)

在emacs 23.1上为我工作

不重点(lower-frame)可能有用.


vle*_*lee -3

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

感谢大家的意见和建议!