I hope to add additional paths to ffap-c-path
in c-mode/c++-mode, and I prefer the lazy load mechanism. There are two choices for me:
- use
add-hook
forc-mode-hook
/c++-mode-hook
eval-after-load
But as @sanityinc said in this page, it seems here the latter is better. So I add the code like below:
(eval-after-load 'cc-mode
'(progn
(require 'ffap)
(setq fap-c-path (append ffap-c-path '("/usr/lib/llvm-3.1/include")))
)
)
However when I later opened a c source file and find that fap-c-path
still the old value. According to the docs, I can use eval-after-load 'cc-mode
or eval-after-load "cc-mode"
if cc-mode
is a library/feature; but neither works here. I take a look at the source code where cc-mode is defined, and find that it uses a cc-provide
instead, is it the root cause?
BTW: I also tried the add-hook
approach; the new path DOES append, but every time I open another c/c++ file, the code is executed once and finally ffap-c-path
contains many duplicated paths.