Hi Arash and Tassilo,

>>>>> Arash Esbati <ar...@gnu.org> writes:
> I used the branch today to write a .tex file and when hitting `C-c C-v'
> to view the result, I get:

>     Debugger entered--Lisp error: (void-function nil)

[...]

> This happens when I set `TeX-view-program-selection' which looks like
> this in my init file:

>     (setq TeX-view-program-selection '((output-pdf "SumatraPDF")
>                                        (output-dvi "dviout")))

> When commented out, AUCTeX uses the the default `start' entry on Windows
> which works.  Can others reproduce this?

Confirmed. Similar error occurs when I turn off TeX-PDF-mode and try to
invoke xdvi for "View" command.

When "View" command is issued, TeX-command-expand calls
TeX-view-command-raw, which in turn calls TeX-command-expand with the
second argument being nil. This second call of TeX-command-expand
overwrites the dynamic scope variable TeX-file-fn with wrong value, so
the error occurs after emacs continues the execution of the first
TeX-command-expand.

Attached is a conceptual patch to fix the problem. I think that the
second argument of TeX-command-expand is no longer necessary, thanks to
the fine utility TeX-active-master.

Regards,
Ikumi Keita

diff --git a/tex-buf.el b/tex-buf.el
index e600e63c..dd22712f 100644
--- a/tex-buf.el
+++ b/tex-buf.el
@@ -494,8 +494,7 @@ been set."
   ;; of point in the region file so that forward search works.
   (if (string= name "View") (TeX-region-update-point))
 
-  (let ((TeX-file-fn file-fn)
-        (command (TeX-command-expand (nth 1 (assoc name TeX-command-list))
+  (let ((command (TeX-command-expand (nth 1 (assoc name TeX-command-list))
 				     file-fn))
 	(hook (nth 2 (assoc name TeX-command-list)))
 	(confirm (if override-confirm
@@ -560,9 +559,7 @@ without further expansion."
     ;; relavant file name involves some special characters such as
     ;; space and multibyte characters.  Hence embed that function in a
     ;; template prepared for that purpose.
-    (setq TeX-file-fn (apply-partially
-		       #'TeX--master-or-region-file-with-extra-quotes
-		       file))
+    (setq TeX-file-fn #'TeX--master-or-region-file-with-extra-quotes)
     (while (setq TeX-expand-pos (string-match pat TeX-expand-command TeX-expand-pos))
       (setq string (match-string 0 TeX-expand-command)
 	    entry (assoc string list)
@@ -587,7 +584,7 @@ without further expansion."
     TeX-expand-command))
 
 (defun TeX--master-or-region-file-with-extra-quotes
-    (file-fn &optional extension nondirectory ask extra)
+    (&optional extension nondirectory ask extra)
   "Return file name with quote for shell.
 Helper function of `TeX-command-expand'.
 
@@ -609,7 +606,7 @@ conditions are met:
 2. \" \\input\" is supplemented
 3. EXTRA is non-nil (default when expanding \"%T\")"
   (shell-quote-argument
-   (let* ((raw (funcall file-fn extension nondirectory ask))
+   (let* ((raw (TeX-active-master extension nondirectory ask))
 	  ;; String `TeX-command-text' means that the file name is
 	  ;; given through \input command.
 	  (quote-for-space (if (and (stringp TeX-command-text)

Reply via email to