I am writing on a large LaTeX Document using Emacs with AUCTeX, RefTeX and Company for autocompletion. RefTeX for citations is working fine and finds my bibliography entries really fast. However, when company searches for labels it has to scan every file used in the project, this takes several seconds and is done every time I move the point in a \ref{} command. Also while scanning for files, I cannot make additional keyboard input, making me wait until scanning is finished every time. Here is the relevant part of my Emacs configuration:
;;------------------------------------------------------------------------------
;; Company -> Autocomplete
;;------------------------------------------------------------------------------
(use-package company
:config
(setq company-idle-delay 0
company-minimum-prefix-length 4
company-selection-wrap-around t)
:bind
(("C-<tab>" . company-complete))
)
(global-company-mode t)
(use-package company-math :ensure t)
(use-package company-reftex :ensure t)
(use-package company-bibtex :ensure t)
(use-package math-symbol-lists)
(use-package company-math :ensure t)
(use-package company-reftex :ensure t)
(use-package company-bibtex :ensure t)
(add-hook 'LaTeX-mode-hook
(lambda()
(make-local-variable 'company-backends)
(setq company-backends
(append '((:separate company-reftex-citations
company-bibtex
company-reftex-labels))
company-backends))
(setq company-backends
(append '((:separate company-math-symbols-latex
company-math-symbols-unicode
company-latex-commands
company-ipa-symbols-unicode
company-dabbrev))
company-backends))))
;;------------------------------------------------------------------------------
;; LaTeX
;;------------------------------------------------------------------------------
(setq-default TeX-output-dir "build")
(setq-default TeX-master nil)
;; RefTex
(add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; Enable RefTex in AUCTex Latex mode
(add-hook 'latex-mode-hook 'turn-on-reftex) ; Enable RefTex in Emacs Latex mode
;; Enable LaTeX Preview Pane
;(add-hook 'LaTeX-mode-hook 'latex-preview-pane-mode)
;(add-hook 'latex-mode-hook 'latex-preview-pane-mode)
(setq-default reftex-plug-into-AUCTeX t)
(setq-default reftex-default-bibliography '("./bibliography/Masterthesis.bib"))
(setq-default reftex-bibliography-commands '("bibliography" "nobibliography" "addbibresource"))
(setq reftex-use-external-file-finders t)
(setq reftex-external-file-finders
'(("tex". "kpsewhich -format=.tex %f")
("bib". "kpsewhich -format=.bib %f")))
Can I speed up the company process for scanning labels? Or is this there at least a way to disable the automatic scanning?
I am new to Emacs and think my problem might result from a faulty configuration.
company-reftex.el
and recompile the file withemacs-lisp-byte-compile
you should be fine. The drawback is that you need to runreftex-parse-all
manually when needed. You could also runreftex-parse-all
once and afterwards watch the input files for changes. But that is more complicated.reftex-parse-all
into a customizable hook such that it could be optionally removed or replaced by something better.reftex-parse-all
incompany-reftex-label-candidates
optional. Could you please check whether my suggestion, removingreftex-parse-all
incompany-reftex-label-candidates
, solves your problem and report back afterwards? Thanks in advance. You could also participate there: github.com/TheBB/company-reftex/issues/11company-reftex-labels-parse-all
which can be set to nil. That change is still only in a pull request. Please test this planned changeset by temporarily replacingreftex-parse-all
withreftex-parse-one
incompany-reftex-label-candidates
. Please report the results of this test here or at github.com/TheBB/company-reftex/pull/13 Thank you in advance.