Ikumi Keita <ik...@ikumi.que.jp> writes: >>>>>> Arash Esbati <ar...@gnu.org> writes: >> using `TeX-update-style-hook' would have been also my suggestion -- I >> think it is the straightforward approach. > > Hmm, then should we go the way of the revised patch #1? It saves the > value of `TeX-active-styles' by let-binding.
Hi Keita, I only read your patch and didn't test, but it makes sense to me. One thing occured to me: You use the following code (which was there before): (apply #'TeX-run-style-hooks (apply #'append (mapcar #'cdr LaTeX-provided-class-options))) Assuming that `LaTeX-provided-class-options' usually has only one entry (unlike `LaTeX-provided-package-options'), wouldn't be sufficient to do: (apply #'TeX-run-style-hooks (cdar LaTeX-provided-class-options)) Maybe you could also mention `:classopt' in AUCTeX manual under `TeX-add-style-hook' [1]. >>> Thus I propose another patch #2 to defer running style hooks until the >>> package options are actually given. >>> >>> How do you think about these ideas? > >> I like this one. The current implementation bugged me also as I wrote >> enumitem.el; one has to hit `C-c C-n' after doing `C-c C-m usepackage >> RET name RET' in order to get things right. And I'm not sure if your >> patch break other things. So +1 from me :) > > Thanks. I found that the previous patch is not sufficient in some cases > because there are style files which requires running style hooks to > obtain proper package options. For example, empheq.el has the following > code: > (TeX-add-style-hook > "empheq" > ... > ;; Load amsmath.el and mathtools.el > (TeX-run-style-hooks "amsmath" "mathtools") > > ;; Add elements from `LaTeX-mathtools-package-options' only once > ;; and not every time the style hook runs > (dolist (elt LaTeX-mathtools-package-options) > (add-to-list 'LaTeX-empheq-package-options elt)) > ... I did't like this implementation as I wrote it. I took it mainly since `mathtools' does the same thing -- and that is the only style doing this AFAIR (off the top of my head, though). I think it is cleaner to set this variable outside the style hook and write something like this: (defvar LaTeX-empheq-package-options (progn (TeX-load-style "mathtools") (append LaTeX-mathtools-package-options '("overload" "overload2" "ntheorem" "newmultline" "oldmultline"))) "Package options for the empheq package.") WDYT? > Though I haven't verified yet, I suppose there are many other style > files like this. See above. > So I reconsidered the implementation to create the revised patch #2. > It runs the style hooks twice, once to collect the package options for > completion, another to reflect the options entered by the user. This > is the same as what `TeX-arg-document' does, after all. In order to > ensure the second run even with `LaTeX-arg-usepackage', I again binds > `TeX-active-styles' by `let' in > `LaTeX-arg-usepackage-read-packages-with-options'. Maybe `(let > ((TeX-active-styles TeX-active-styles))' is better than `(let > ((TeX-active-styles nil))' here. Hmm, not sure, but `(let ((TeX-active-styles TeX-active-styles))' looks more sensible to me either. Best, Arash Footnotes: [1] https://www.gnu.org/software/auctex/manual/auctex.html#index-TeX_002dadd_002dstyle_002dhook _______________________________________________ auctex mailing list auctex@gnu.org https://lists.gnu.org/mailman/listinfo/auctex