Malabarba / latex-extra

A series of usability improvements for Emacs latex-mode.
GNU General Public License v3.0
69 stars 14 forks source link

Reference to free variable ‘latex-extra-mode’ #23

Closed budsbenzer closed 7 years ago

budsbenzer commented 7 years ago

Since I upgraded to Emacs 25.1, I get the error message Warning (bytecomp): reference to free variable ‘latex-extra-mode’ on startup. I include latex-extra in my init.el by

(use-package latex-extra
  :ensure t
  :config
  (add-hook 'LaTeX-mode-hook #'latex-extra-mode))

My Emacs version is GNU Emacs 25.1.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.20.9) of 2016-09-18, while (lm-version) evals to "1.13".

By the way, the call to (lm-version "latex-extra") in function latex-bug-report results in the error message lm-version: Opening input file: No such file or directory, /home/XXX/.emacs.d/elpa/latex-extra-20160328.1721/latex-extra.

Malabarba commented 7 years ago

That's strange, I don't get that message when byte-compiling. Have you tried replacing that snippet in your init file with (add-hook 'LaTeX-mode-hook #'latex-extra-mode)? Do you still get the same errror?

budsbenzer commented 7 years ago

Strange indeed. 😄 When I remove the package's .elc and recompile, there are no warnings. However, the warning appears again when I restart Emacs.

I replaced the (use-package ...) by

(require 'latex-extra)
(add-hook 'LaTeX-mode-hook #'latex-extra-mode)

but the warning persists. When I remove the above from init.el and eval it in the scratch buffer instead, there are no warnings.

budsbenzer commented 7 years ago

It may be a hack, but I managed to suppress the warning with

(let ((byte-compile-warnings '(not free-vars)))
  (use-package latex-extra
  :ensure t
  :config
  (add-hook 'LaTeX-mode-hook #'latex-extra-mode)))

Since I'm okay with that as a solution, I'll close the issue.

Malabarba commented 7 years ago

Alight. It might just be some compatibilty thing with a very specific version of auctex.

HuStmpHrrr commented 6 years ago

does this indicate an error, or is it free to ignore? i believe it might be some byte code compatibility issue. is there a better way than suppressing the message?

norbusan commented 6 years ago

I confirm that this is still a problem, and indeed the (add-hook 'LaTeX-mode-hook #'latex-extra-mode) does not work. I need to activate the extra mode manually.

guilherme-salome commented 5 years ago

I am using:

(use-package latex-extra
  :ensure t
  :init (add-hook 'LaTeX-mode-hook #'latex-extra-mode))

I get the same warning, and the hook does work. I suspect there is a problem with use-package itself. I have tried the following before:

(use-package latex-extra
  :ensure t
  :hook (LaTeX-mode-hook . latex-extra-mode))

which should work according to their docs, but actually doesn't. And the solution with init does work.

Nevertheless, the bytecomp warning still shows up. I am not sure if it is related, but I cannot compile beamer files with C-c C-a, but can articles.

guilherme-salome commented 5 years ago

I figured out a solution that does not require the hack, and why the :hook specification above does not work.

First, the :hook specification above does not work because it takes the 1st symbol inside ( ) and then appends -hook to it. In this case, the first symbol is LaTeX-mode-hook, and it will try to add latex-extra-mode to the LaTeX-mode-hook-hook hook. So the correct way to call it is:

(use-package latex-extra
  :ensure t
  :hook (LaTeX-mode . latex-extra-mode))

Second, this also solves the problem with the bytecomp error! I do not understand why exactly, but it seems that it defers adding the hook until the variable latex-extra-mode is actually declared, and so we do not get a free variable error.

technician77 commented 4 years ago

No matter what I do I get the error below everytime I start emacs. Tried reinstalling the package, no difference. Current config is below. For years I used the (let ((byte-compile-warnings '(not **free-vars)))** wrapping but now it makes no difference it's there or not.

GNU Emacs 27.0.60 (build 1, x86_64-w64-mingw32) of 2019-12-28

~/.emacs.d/elpa/latex-extra-20170817.147/latex-extra.elc:Warning: reference to
    free variable ‘latex-extra-mode’
  (use-package latex-extra
    :mode ("\\.tex\\'" . TeX-latex-mode)
    :hook
    (LaTeX-mode . latex-extra-mode))