9

When a new version of Emacs is released it is usually the case that some variables/commands/functions become obsolete. They are usually marked as such in the corresponding documentation:

turn-on-eldoc-mode is an alias for eldoc-mode in eldoc.el. [...]

This function is obsolete since 24.4; use eldoc-mode instead.

I'd like to make sure I am not referencing any obsolete variables in my init-file, but I'd also like to avoid checking the whole thing manually.

So my question is: Is there a way to automatically identify all obsolete variables in my init-file (that possibly also works for third-party packages installed via the package manager)?

0

1 Answer 1

13

Byte-compile the file.

Generally, it's best to not byte-compile your init file, but here it's useful. The byte-compiler will warn you about a lot of bad practices, among them is the usage of obsolete variables or functions.

  1. Just call M-x byte-compile-file and give your init file.

  2. Afterwards, make sure you delete the generated .elc file.

6
  • 2
    Out of curiosity, what are the reasons not to byte-compile the init file?
    – Dan
    Commented Oct 25, 2014 at 14:41
  • 4
    @Dan The advantages are negligible. Meanwhile, occasionally you might forget to recompile after changing it, and be left wondering why your changes aren't having any effect.
    – Malabarba
    Commented Oct 25, 2014 at 14:43
  • 4
    @Dan: In addition to what Malabarba said, a given init file is sometimes (often) used for multiple Emacs versions, and byte-compiling it can reduce this kind of portability.
    – Drew
    Commented Oct 25, 2014 at 15:13
  • Just in case it's not obvious: you can byte-compile it (to see warnings etc.) and then delete the *.elc.
    – Drew
    Commented Oct 25, 2014 at 15:14
  • 7
    That's why you should use #' instead of ' for functions. If you compile something with (add-hook 'emacs-lisp-mode-hook #'turn-on-eldoc-mode) the compiler will warn you.
    – Malabarba
    Commented Oct 25, 2014 at 16:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.