以编程方式将Emacs窗口设置为输入焦点

时间:2014-04-05 16:38:18

标签: emacs window focus elisp gud

我如何以编程方式强制我的Emacs X Window获取当前用户输入焦点?

我想在以下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
}

使Emacs窗口自动获得窗口焦点。

2 个答案:

答案 0 :(得分:1)

您可以在评估代码中添加对raise-frame的调用。

例如:

emacsclient --eval "(progn (raise-frame) (gdb \"gdb -i=mi $ARGS\"))"

答案 1 :(得分:1)

我从与org-protocol相关的地方复制了这些内容。 它也应该对你有所帮助:

(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)))

这是@ tungd当然要求raise-frame的建议的补充。

相关问题