Hi Ikumi, Thank you for taking the time to review my patch.
On 23/02/2021, Ikumi Keita wrote: > 1. When a subfile is located in subdirectory, region typeset causes > error, even when TeX-output-dir is nil. > Indeed, this is a bug that I can probably fix but see below. > 2. Suppose that TeX-output-dir is non-nil in the subfile while it is > nil in the main file. This inconsistency can lead to endless loop in > Agreed. The value of TeX-output-dir in master should be the correct one (the value in the subfile should be ignored). The infinite loop was unexpected but should be easy to fix. > I don't think it's a good idea to modify `TeX-master-file' and > `TeX-region-file'. Their usage and implementation in AUCTeX have a lot > of subtleness, so modifying them is fragile in general. I can't > guarantee that shortcomings other than the above two don't come out > later. > > > Hence I'd recommend to make the basic design more similar to Mosè's > approach: > (1) Keep `TeX-master-file' and `TeX-region-file' as-is. > (2) Make a function dedicated to build a path (including the file name) > for generated files such as .pdf, .dvi, .aux etc. > (3) Use that dedicated function for "%o" and alikes in > `TeX-expand-list(-builtin)' and everywhere AUCTeX calls > `TeX-check-path'. > (4) Adjust `TeX-clean' and `TeX-view' to accomodate those changes. There are two things my patch is trying to do: - Implement `--output-directory` options in tex tools. This requires a minimal change to TeX-master-file which is ostensibly an automatic version of what you suggested above. If 'extension' is an output extension like "pdf", "dvi" or etc and TeX-output-dir is not nil then the function TeX-output-master-file is called which constructs the paths as you suggest. This should mean that the return value of TeX-master-file is different only for those extensions and only when `TeX-output-dir` is non-nil. This was a decision that I made early on since the full implementation that you suggested will require replacing (manually) any calls to TeX-master-file with calls to TeX-output-master-file based on the extension. - Allow `TeX-region` to have a sub-directory. I thought this was an easy fix to TeX-region-file but it turned out to cause many headaches (including the first bug above and some of the previous bugs related to preview-latex). While the precise implementation is being discussed here, I will remove the changes related to allowing TeX-region to be a sub-directory to increase reliability and fix the infinite loop bug above. > > I suppose that (1)-(4) would be almost inevitable to implement reliably > the output-diretory feature. In addtion, they would gain another > advantage of being free of complication discussed below. > Hmm.. I don't think the complications I talked about in TeX-command and TeX-save-document are a result of the patch implementation but rather are a result of these functions accepting file and file-function arguments instead of calling the relevant functions (like TeX-active-master) but not passing the file-function down to other functions. Even a full implementation would have to change the interface of these commands to allow passing of two functions and/or file paths (one for the normal path and one for the output one). Best regards, Al