[Top][All Lists]

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

Re: Output filenames and the inconsistency of the `file` variable

From: Al Haji-Ali
Subject: Re: Output filenames and the inconsistency of the `file` variable
Date: Tue, 25 Aug 2020 22:32:10 +0100
User-agent: mu4e 1.5.5; emacs 27.1

Hi Ikumi,

>> Would changing that to calling the appropriate filename function be
>> acceptable in my contribution?
> Probably yes, provided that your contribution is careful enough not to
> break compatibility with existing codes including users' customization.

To start with, I think the first change is to ensure that the variable `file` 
(or the lexically-scoped alternative) is not used as a string. Since this is an 
internal variable, I think user config is not an issue.
For the existing AUCTeX code, as far as I can see, the places where the 
dynamically-scoped `file` is used as a string are only two: tex.el:1168 and 

So thest are the only changes needed:

--- a/tex-buf.el
+++ b/tex-buf.el
@@ -531,9 +531,9 @@ remember to add /Library/TeX/texbin/ to your PATH"

     ;; Now start the process
-    (setq file (funcall file))
-    (TeX-process-set-variable file 'TeX-command-next TeX-command-Show)
-    (funcall hook name command file)))
+    (let ((filename (funcall file)))
+      (TeX-process-set-variable filename 'TeX-command-next TeX-command-Show)
+      (funcall hook name command filename))))

 (defvar TeX-command-text)               ;Dynamically scoped.
 (defvar TeX-command-pos)                ;Dynamically scoped.
diff --git a/tex.el b/tex.el
index 9a1d1b6d..9e651966 100644
--- a/tex.el
+++ b/tex.el
@@ -1165,7 +1165,7 @@ entry in `TeX-view-program-list-builtin'."
                                 (get-file-buffer (TeX-region-file t)))
-    (let ((pdf (concat file "." (TeX-output-extension))))
+    (let ((pdf (funcall file (TeX-output-extension))))
       (pop-to-buffer (or (find-buffer-visiting pdf)
                         (find-file-noselect pdf))))))

@@ -1189,7 +1189,7 @@ viewer."
   (require 'url-util)
   (let* ((uri (concat "file://" (url-encode-url
-                                 (concat file "." (TeX-output-extension))))))
+                                 (funcall file (TeX-output-extension))))))
         (owner (dbus-call-method
                 :session (format "org.%s.%s.Daemon" de app)
                 (format "/org/%s/%s/Daemon" de app)

> Recently, there were some
> discussions in this list about moving to lexical scope:
> So the situation with respect to this dynamically-scoped variables may
> be much different in future AUCTeX.
Without the changes above, the lexically-scoped variable would still have to 
serve the two functions (being a function and a string) which I think is not 

-- Al

reply via email to

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