How to make flymake happy without interfering with logic?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to make flymake happy without interfering with logic?

Pankaj Jangid
Hi,

I have a file 'init-env.el' in '<user-emacs-directory>/lisp'
directory. In my 'init.el' when I do (require 'init-env), flymake says
no such file or directory.

Emacs loads the file perfectly without any error with the following code
in my init.el,

(add-to-list 'load-path (expand-file-name "lisp" user-emacs-directory))

But flymake works only when I call the above code inside
(eval-when-compile ...) form.

My question is - how to make flymake happy without interfering with
logic?

Regards,
--
Pankaj Jangid

Reply | Threaded
Open this post in threaded view
|

Re: How to make flymake happy without interfering with logic?

Stefan Monnier
> I have a file 'init-env.el' in '<user-emacs-directory>/lisp'
> directory. In my 'init.el' when I do (require 'init-env), flymake says
> no such file or directory.

flymake is designed for files which can be correctly byte-compiled from
a "vanilla" Emacs.

Wrapping your `load-path` modification inside an `eval-and-compile` is
one way to make it work.  Another way could be to do

    (if t (require 'init-env))

so the `require` is only executed when loading the file but not when
compiling it.  Another could be to use

    (require 'init-env (expand-file-name "lisp/init-env" user-emacs-directory)

Yet another might be to disable flymake in that file because the file
just doesn't lend itself to this kind of checking.


        Stefan