如何在打开org-protocol时给emacsclient窗口焦点?

3

我在.emacs中使用了(require 'org-protocol),现在在bash中执行如下命令:

emacsclient org-protocol://capture://something

我得到了我想要的,但emacs窗口没有聚焦。 为了使其聚焦,例如我可以给emacsclient命令添加一个-c标志。 有没有一种方法(也许是-e开关)在不使用-c的情况下实现这一点?

1个回答

2

我找到了以下代码来解决这个问题:

(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


这会导致我的org 7.9.2捕获出现贪婪处理程序错误。另一方面,它看起来框架已经自动提升了(emacs24,xubuntu)。 - bright-star
@abo-abo,你说你“找到了这段代码”。在哪里以及根据什么许可证?请给予应有的荣誉。 - user82216

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接