1

如何以编程方式强制我的 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 窗口自动获得窗口焦点。

4

2 回答 2

1

raise-frame您可以通过在 eval 代码中添加调用来做到这一点。

例如:

emacsclient --eval "(progn (raise-frame) (gdb \"gdb -i=mi $ARGS\"))"
于 2014-04-06T02:33:15.583 回答
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

于 2014-04-06T12:21:32.583 回答