>From 45953f2a7d31f6635dc92f67f81c3407e3ff6153 Mon Sep 17 00:00:00 2001 From: Hong Xu Date: Wed, 9 Aug 2017 17:10:58 +0800 Subject: [PATCH] when using SyncTeX with Evince, add an option to not switch focus after syncing. The current behavior switches focus to Evince, which is inconvenient for editing when Evince and Emacs are side-by-side. This change adds a new option `TeX-view-evince-keep-focus' to pulls the focus back to Emacs after syncing. This change also make the behavior of syncing using Evince consistent with syncing using Zathura. --- tex.el | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tex.el b/tex.el index 972110b3b54b..e0552534aba7 100644 --- a/tex.el +++ b/tex.el @@ -1151,6 +1151,15 @@ all the regular expressions must match for the element to apply." (choice regexp (repeat :tag "List" regexp)) (string :tag "Command")))) +(defcustom TeX-view-evince-keep-focus nil + "Whether Emacs retains the focus when viewing PDF files with Evince. + +When calling `TeX-evince-sync-view', Evince normally captures the +focus. If this option is set to non-nil, Emacs will retain the +focus." + :group 'TeX-view + :type 'boolean) + ;;; Viewing (new implementation) (defvar TeX-view-predicate-list-builtin @@ -1340,7 +1349,9 @@ viewer." ;; line. What is the right number to specify here? ;; number of letters? bytes in UTF8? or other? :int32 (1+ (current-column))) - :uint32 0)) + :uint32 0) + (when TeX-view-evince-keep-focus + (select-frame-set-input-focus (selected-frame)))) (error "Couldn't find the %s instance for %s" (capitalize app) uri)))) (defun TeX-atril-sync-view () -- 2.11.0