1

I use use-package and pulled in the treemacs package with the default settings. Then I byte-compiled my .emacsfile. But I still get a warning saying:

the following functions might not be defined at runtime: treemacs--find-python3, treemacs-follow-mode, treemacs-filewatch-mode, treemacs-fringe-indicator-mode, treemacs-git-mode

I also tried to add these modes in the :defines parameter in use-package, but has no effect.

How to get rid of these warnings properly?

David S.
  • 395
  • 2
  • 13
  • Use `require` instead of `use-package`, just ignore the warnings, or don’t bother byte-compiling your `.emacs`. – nega Jul 29 '19 at 10:23

3 Answers3

2

use-package includes keywords to deal with this. The documentation https://github.com/jwiegley/use-package tells you what to do in this case under the heading Byte-compiling your .emacs

Another feature of use-package is that it always loads every file that it can when .emacs is being byte-compiled. This helps to silence spurious warnings about unknown variables and functions.

However, there are times when this is just not enough. For those times, use the :defines and :functions keywords to introduce dummy variable and function declarations solely for the sake of the byte-compiler:

(use-package texinfo
  :defines texinfo-section-list
  :commands texinfo-mode
  :init
  (add-to-list 'auto-mode-alist '("\\.texi$" . texinfo-mode)))

If you need to silence a missing function warning, you can use :functions:

(use-package ruby-mode
  :mode "\\.rb\\'"
  :interpreter "ruby"
  :functions inf-ruby-keys
 :config
  (defun my-ruby-mode-hook ()
    (require 'inf-ruby)
    (inf-ruby-keys))

(add-hook 'ruby-mode-hook 'my-ruby-mode-hook))
mmmmmm
  • 491
  • 1
  • 4
  • 19
1

I assume you're referring to those functions in your init file?

You can add the following to suppress the individual warnings:

(declare-function treemacs--find-python3 "treemacs")
(declare-function treemacs-filewatch-mode "treemacs")
(declare-function treemacs-follow-mode "treemacs")
(declare-function treemacs-fringe-indicator-mode "treemacs")
(declare-function treemacs-git-mode "treemacs")
phils
  • 48,657
  • 3
  • 76
  • 115
0

After much research, since I am using use-package, I think the easiest and safe way to get rid of the warnings is just to suppress them, like mentioned here

Simply add this to the bottom of your .emacs file.

;; Local Variables:
;; byte-compile-warnings: (not free-vars noruntime)
;; End:
David S.
  • 395
  • 2
  • 13