[英]Programmatically Setting Emacs Window as Input Focus
How do I programmaticaly force my Emacs X Window to get current user input focus? 如何以编程方式强制我的Emacs X Window获得当前用户输入焦点?
I want to use this in the following Bash script 我想在以下Bash脚本中使用它
# Debug in Emacs using GDB
function emacs-gdb()
{
if [ -z $1 ]; then
echo -e "Usage: $FUNCNAME EXE EXE_ARGS...";
else
if (($# >= 2)); then
local ARGS="--args ${@:1:100}";
else
local ARGS="$1";
fi
emacsclient --eval "(gdb \"gdb -i=mi $ARGS\")"
fi
}
to make the Emacs window automatically get window focus. 使Emacs窗口自动获得窗口焦点。
You can do this by adding the call to raise-frame
in your eval code. 您可以通过在评估代码中添加对
raise-frame
的调用来实现。
For example: 例如:
emacsclient --eval "(progn (raise-frame) (gdb \"gdb -i=mi $ARGS\"))"
I've had this copied from somewhere related to org-protocol
. 我已经从与
org-protocol
相关的地方复制了此文件。 It should help you as well: 它也应该对您有帮助:
(defadvice raise-frame (after make-it-work (&optional frame) activate)
"Work around some bug? in raise-frame/Emacs/GTK/Metacity/something.
Katsumi Yamaoka posted this in
http://article.gmane.org/gmane.emacs.devel:39702"
(call-process
"wmctrl" nil nil nil "-s" "1")
(call-process
"wmctrl" nil nil nil "-i" "-R"
(frame-parameter (or frame (selected-frame)) 'outer-window-id)))
This is in addition to @tungd's advice of calling raise-frame
of course. 当然,这是@tungd关于调用
raise-frame
的建议的补充。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.