I have this line in my .emacs file.

(add-hook 'ibuffer-mode-hook
          #'(lambda ()
              (ibuffer-switch-to-saved-filter-groups "default")))

The settings work fine for me. But flycheck says:

the function `ibuffer-switch-to-saved-filter-groups' is not known to be defined.

I think if I declare the function ahead, the warning would go away. But ibuffer is a build-in package, and I cannot find a way to declare this function.

How to declare a built-in function?


I found the ibuffer-switch-to-saved-filter-groups is not a built-in function, but is defined in a file called ibuf-ext.el, and locate-library can find this file from my environment path. But even after I defined declare-function like below:

(declare-function ibuffer-switch-to-saved-filters "ibuf-ext.el" nil)

I still get this warning from flycheck.

  • My question was not about the ibuffer settings, it was about the flycheck warning...
    – David S.
    Commented Jun 13, 2018 at 6:31
  • That is for authors of elisp packages to check if there're errors in their package file.
    – David S.
    Commented Jun 13, 2018 at 9:23

2 Answers 2


Your declare-function doesn't silence the warning because it doesn't declare the same function (there a "-group" missing before the final "s").

The warning basically tells you that the byte-compiler can't find anything in your code which guarantees that ibuffer-switch-to-saved-filter-groups will exist when that call is reached.

The problem is fundamentally due to the byte-compiler's much too limited understanding of things like hooks: it is not able to understand that this ibuffer-mode-hook will only be run from code inside ibuffer.el (where ibuffer-loaddefs is loaded), so the functions placed on this hook will normally only be run in a context where ibuffer-switch-to-saved-filter-groups is autoloaded ondemand).

Patches welcome.


Doing a (require 'ibuf-ext) will probably pacify flycheck...

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.