Hi all,

If a document is divided into multiple files, in a subfile not placed in
`TeX-master-directory', AUCTeX suggests wrong default command for
actions on the region such as C-c C-r and C-c C-b.
By the same reason, C-u C-c C-a also fails.
I think the attached fix is necessary.

[How to confirm]
1. Extract the attached files under /tmp .
2. Open /tmp/childdir/child.tex and put the region on arbitrary text.
3. Type C-c C-r.  AUCTeX suggests "LaTeX" as default command.  This is
   OK.
4. Type RET to accept the default.  The file is typeset normally.  Then
   type C-c C-r again.  AUCTeX suggests "LaTeX" as default again.  This
   is not what should be.  Since the sample files are so simple, the
   right default here is "View".
5. Type RET to accept the default.  Of course the file is typeset
   without problem.  Type C-c C-r again.  AUCTeX suggests "LaTeX" as
   default again.  Even if you repeat typing C-c C-r RET, AUCTeX always
   suggests "LaTeX" as default, never "View".
6. If you type C-u C-c C-a instead of C-c C-r, the sequence repeats
   "LaTeX" commands and stops with the message `Stopping after running
   "LaTeX" 4 times in a row.'

As always, comments and suggestions are welcome.

Regards,
Ikumi Keita

Attachment: fortest.tar.gz
Description: test files

diff -r a68aa20babe3 tex-buf.el
--- a/tex-buf.el	Wed May 31 00:07:27 2017 +0900
+++ b/tex-buf.el	Thu Jun 01 23:48:34 2017 +0900
@@ -177,11 +177,15 @@
 text before `TeX-header-end'.
 
 If the master file for the document has a trailer, it is written to
-the temporary file before the region itself.  The document's trailer is
+the temporary file after the region itself.  The document's trailer is
 all text after `TeX-trailer-start'."
   (interactive "P")
   (TeX-region-update)
-  (TeX-command (TeX-command-query (TeX-region-file nil t)) 'TeX-region-file
+  ;; In the next line, `TeX-region-file' should be called with nil
+  ;; `nondirectory' argument, otherwise `TeX-comand-default' called
+  ;; within `TeX-command-query' won't work in included files not
+  ;; placed in `TeX-master-directory'.
+  (TeX-command (TeX-command-query (TeX-region-file)) 'TeX-region-file
 	       override-confirm))
 
 (defun TeX-command-buffer (&optional override-confirm)
@@ -777,7 +781,7 @@
     (cond (;; name might be absolute or relative, so expand it for
 	   ;; comparison.
 	   (if (string-equal (expand-file-name name)
-			     (expand-file-name TeX-region))
+			     (expand-file-name (TeX-region-file)))
 	       (TeX-check-files (concat name "." (TeX-output-extension))
 				;; Each original will be checked for all dirs
 				;; in `TeX-check-path' so this needs to be just
_______________________________________________
auctex-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/auctex-devel

Reply via email to