我在.emacs中使用了(require 'org-protocol)
,现在在bash中执行如下命令:
emacsclient org-protocol://capture://something
我得到了我想要的,但emacs窗口没有聚焦。
为了使其聚焦,例如我可以给emacsclient
命令添加一个-c
标志。
有没有一种方法(也许是-e
开关)在不使用-c
的情况下实现这一点?
我找到了以下代码来解决这个问题:
(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)))
(add-hook 'server-switch-hook 'raise-frame)
显然,raise-frame
仍然有缺陷,因此改用wmctrl
。