答案1
添加以下代码,取自https://lists.gnu.org/archive/html/bug-auctex/2013-04/msg00004.html,到你的.emacs
(defun raise-client-frame ()
(let ((wmctrl (executable-find "wmctrl")))
(if wmctrl
(start-process "wmctrl" nil wmctrl "-R" (frame-parameter nil 'name)))))
;; This raises the frame when using Evince.
(add-hook 'TeX-source-correlate-mode-hook
(lambda ()
(when (TeX-evince-dbus-p)
(dbus-register-signal
:session nil "/org/gnome/evince/Window/0"
"org.gnome.evince.Window" "SyncSource"
(lambda (file linecol &rest ignored)
(TeX-source-correlate-sync-source file linecol ignored)
(raise-client-frame))))))
;; This raises the frame when using all other viewers.
(add-hook 'server-switch-hook 'raise-client-frame)
AUCTeX 的当前版本支持使用 Evince 进行正向/反向搜索,不再需要使用旧的黑客技术。
答案2
(defadvice raise-frame (after make-it-work (&optional frame) activate)
"Work around some bug? in raise-frame/Emacs/GTK/Metacity/something.
Katsumi Yamaoka <[hidden email]> posted this in
http://article.gmane.org/gmane.emacs.devel:39702"
(call-process
"wmctrl" nil nil nil "-i" "-R"
(frame-parameter (or frame (selected-frame)) 'outer-window-id)))
假设您已经wmctrl
在系统上安装,请将上述代码放入您的初始化文件中。