auctex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[AUCTeX] [PATCH] Implement TeX-view-pdf-tools-keep-focus


From: Leo Vivier
Subject: [AUCTeX] [PATCH] Implement TeX-view-pdf-tools-keep-focus
Date: Sun, 03 Feb 2019 23:38:15 +0100

Hello,

This is my first time submitting a patch via email, so please excuse me
if I've done anything wrong.  Notably, the next 4 lines seem to be parts
of an email header, and I'm not sure whether I should remove them.
Since they have my local commit number on them, I'm going to leave them
in just in case.

Thanks.

>From d33de95dcf943c4dc02531073b75db4c354924bc Mon Sep 17 00:00:00 2001
From: Leo Vivier <address@hidden>
Date: Sun, 3 Feb 2019 23:19:29 +0100
Subject: [PATCH] Implement TeX-view-pdf-tools-keep-focus

Based on `TeX-view-evince-keep-focus'.

If t, instead of focussing the PDF buffer with `pop-to-buffer',
display it with `display-buffer'.
---
 tex.el | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/tex.el b/tex.el
index 3c3f1769..df38c3fd 100644
--- a/tex.el
+++ b/tex.el
@@ -1130,6 +1130,15 @@ DE is the name of the desktop environment, APP is the 
name of viewer."
                                                 (cdr (caar (cdr elem)))))
                                             spec)))))))))
 
+(defcustom TeX-view-pdf-tools-keep-focus nil
+  "Whether AUCTeX retains the focus when viewing PDF files with pdf-tools.
+
+When calling `TeX-pdf-tools-sync-view', the pdf-tools buffer
+normally captures the focus. If this option is set to non-nil,
+the AUCTeX buffer will retain the focus."
+  :group 'TeX-view
+  :type 'boolean)
+
 (defun TeX-pdf-tools-sync-view ()
   "Focus the focused page/paragraph in `pdf-view-mode'.
 If `TeX-source-correlate-mode' is disabled, only find and pop to
@@ -1150,9 +1159,12 @@ entry in `TeX-view-program-list-builtin'."
                                 (get-file-buffer (TeX-region-file t)))
                               (current-buffer))
        (pdf-sync-forward-search))
-    (let ((pdf (concat file "." (TeX-output-extension))))
-      (pop-to-buffer (or (find-buffer-visiting pdf)
-                        (find-file-noselect pdf))))))
+    (let* ((pdf (concat file "." (TeX-output-extension)))
+           (buffer (or (find-buffer-visiting pdf)
+                      (find-file-noselect pdf))))
+      (if TeX-view-pdf-tools-keep-focus
+          (display-buffer buffer)
+        (pop-to-buffer buffer)))))
 
 (defcustom TeX-view-evince-keep-focus nil
   "Whether Emacs retains the focus when viewing PDF files with Evince.
-- 
2.20.1





reply via email to

[Prev in Thread] Current Thread [Next in Thread]