Hi Mosè, Mosè Giordano <m...@gnu.org> writes:
> 2017-02-15 9:19 GMT+01:00 Arash Esbati <ar...@gnu.org>: >> what do you think about this small patch against subfiles.el: > > Actually in subfiles.el it should be sufficient to replace > `file-name-base' with `file-name-sans-extension', but I didn't have > the time to understand why `TeX-load-style' doesn't load it. I think the issue is in `TeX-load-style': --8<---------------cut here---------------start------------->8--- (defun TeX-load-style (style) "Search for and load each definition for STYLE in `TeX-style-path'." (cond ((assoc style TeX-style-hook-list)) ; We already found it ((string-match "\\`\\(.+[/\\]\\)\\([^/\\]*\\)\\'" style) ;Complex path (let* ((dir (substring style (match-beginning 1) (match-end 1))) (style (substring style (match-beginning 2) (match-end 2))) (master-dir (if (stringp TeX-master) (file-name-directory (file-relative-name TeX-master)) "./")) (TeX-style-path (append (list (expand-file-name TeX-auto-local dir) (expand-file-name TeX-auto-local master-dir) (expand-file-name TeX-style-local dir) (expand-file-name TeX-style-local master-dir)) TeX-style-path))) (TeX-load-style style))) (t ;Relative path ;; Insert empty list to mark the fact that we have searched. (setq TeX-style-hook-list (cons (list style) TeX-style-hook-list)) ;; Now check each element of the path (dolist (name TeX-style-path) (TeX-load-style-file (expand-file-name style name)))))) --8<---------------cut here---------------end--------------->8--- When invoked as (TeX-load-style "../../main-file.tex") from `TeX-run-style-hooks' (with `file-name-sans-extension' as you suggested, of course), `TeX-load-style' sees a complex path and starts the second condition. But then, it makes a recursive call to (TeX-load-style style) which is (TeX-load-style "main-file"). Now the t condition is called and (TeX-load-style-file ...) does not find any auto generated file it standard style path since the additions of the first run are lost. I think this can be fixed by adding (dolist (name TeX-style-path) (TeX-load-style-file (expand-file-name style name))) to second condition as well. @Uwe: Can you try copy/paste this into you one of your sub files and eval them? --8<---------------cut here---------------start------------->8--- \begin{verbatim} (defun TeX-load-style (style) "Search for and load each definition for STYLE in `TeX-style-path'." (cond ((assoc style TeX-style-hook-list)) ; We already found it ((string-match "\\`\\(.+[/\\]\\)\\([^/\\]*\\)\\'" style) ;Complex path (let* ((dir (substring style (match-beginning 1) (match-end 1))) (style (substring style (match-beginning 2) (match-end 2))) (master-dir (if (stringp TeX-master) (file-name-directory (file-relative-name TeX-master)) "./")) (TeX-style-path (append (list (expand-file-name TeX-auto-local dir) (expand-file-name TeX-auto-local master-dir) (expand-file-name TeX-style-local dir) (expand-file-name TeX-style-local master-dir)) TeX-style-path))) ;; (TeX-load-style style) ;; start possible fix (dolist (name TeX-style-path) (TeX-load-style-file (expand-file-name style name))) ;; end possible fix )) (t ;Relative path ;; Insert empty list to mark the fact that we have searched. (setq TeX-style-hook-list (cons (list style) TeX-style-hook-list)) ;; Now check each element of the path (dolist (name TeX-style-path) (TeX-load-style-file (expand-file-name style name)))))) (TeX-run-style-hooks (file-name-sans-extension (cadr (assoc "subfiles" LaTeX-provided-class-options)))) \end{verbatim} --8<---------------cut here---------------end--------------->8--- Best, Arash _______________________________________________ auctex-devel mailing list auctex-devel@gnu.org https://lists.gnu.org/mailman/listinfo/auctex-devel