Hi Ikumi.
Thank you for your email.
Current AUCTeX source has some references to the variable
`buffer-file-name', as well as call to the function of the same name. It
seems that the variable is nil in indirect buffers. Is it safe to leave
those references unchanged?
You are correct. I can see a few cases:
./tex.el:2440: (and buffer-file-name
./tex.el:2441: (file-name-directory buffer-file-name)))))))
In the above, I think that part of the code is in fact redundant. That's because if the function's `expand-file-name' second argument is nil, then it's taken to be the default-directory. Quoting from the help page:
Second arg DEFAULT-DIRECTORY is directory to start with if NAME is relative
(does not start with slash or tilde); both the directory name and
a directory’s file name are accepted. If DEFAULT-DIRECTORY is nil or
missing, the current buffer’s value of ‘default-directory’ is used.
NAME should be a string that is a valid file name for the underlying
filesystem.
So, with the current code, the second argument will be something like /home/me/file.tex, while if nil, it is assumed to be /home/me/ which in the end has the same effect. I can't imagine a situation where that's not the case.
For all other cases:
./style/catchfilebetweentags.el:70: (buffer-file-name (current-buffer)))))
./style/pdfsync.el:40: (file-relative-name (buffer-file-name)
./tex-info.el:707: (unless (file-exists-p (buffer-file-name))
./toolbar-x.el:1465: (buffer-file-name (buffer-base-buffer))
./toolbar-x.el:1469: :visible (or buffer-file-name
./toolbar-x.el:1479: :visible (or buffer-file-name
./latex.el:2564: (let ((name (file-name-nondirectory buffer-file-name)))
./latex.el:2585: (file-name-nondirectory buffer-file-name))))
I believe we can change buffer-file-name to (TeX-buffer-file-name) where the file "tex.el" is loaded for consistency. The function with nil argument has the same effect as the variable. I'm happy to make the changes to that too if that's OK with you.
The major portion of the addition is
(cond
[...]
;; Indirect buffer
(my-buffer
(with-current-buffer my-buffer
(TeX-master-file nil nondirectory ask)))
^^^
. Why is the first argument always nil? The original function receives
the second argument as `extension'. Aren't there cases that we should
provide the same argument `extension' here?
As far as I understand the variable TeX-master always points to the name of the file *without* the extension. That's why the first argument is nil. Otherwise, if extension is say "pdf", then the TeX-master for the indirect buffer will be something like "foo.pdf". The extension part is added later in the code in the function TeX-master-file.
I don't get the error that you mentioned. Can you please send me a traceback?