On 09/11/2020 04:02, Maximilian Wuttke wrote: > Hi, > > The "C-c RET" completion for `\usepackage` caches the available packages > into a variable (I think `TeX-global-input-files`). However, this list > is not saved to the disk, and if I restart Emacs, the packages have to > be rescanned, which takes some time (ca. 10 seconds on my computer). > > It would be a nice feature to save the packages (and of course also > provide a command to update the list). But my Emacs Lisp skills are not > good enough yet to implement this feature. > > -- Maximilian > > > PS: AUCTex is great! It was one of the reasons why I switched from vim > to Emacs. :) I've already written my bachelor's thesis and a paper with > Emacs, and now I'm writing my master's thesis. >
OK, I implemented this feature for myself. It wasn't so complicated after all. > ;; Save TeX and LaTeX packages and document classes to a file > ;; Code inspired by `company-statistics.el' > > (defvar LaTeX-packages-file (concat user-emacs-directory > "latex-packages-cache.el")) > > (defun LaTeX-save-package-list () > "Save TeX and LaTeX packages and document classes to the file > `LaTeX-packages-file'" > (interactive) > (with-temp-buffer > (let (print-level print-length) > (insert > (format "%S" > `(setq LaTeX-global-class-files (quote ,LaTeX-global-class-files) > TeX-global-input-files (quote ,TeX-global-input-files)))) > (write-file LaTeX-packages-file nil)))) > > (defun LaTeX-load-package-list () > "Load TeX and LaTeX packages and document classes from the file > `LaTeX-packages-file'" > (interactive) > (load LaTeX-packages-file 'noerror nil 'nosuffix)) > > (with-eval-after-load "latex" (LaTeX-load-package-list))