[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Tue, 28 Sep 2010 12:41:49 +0200
Mozilla/5.0 (X11; U; Linux i686; de; rv:22.214.171.124) Gecko/20100711 Thunderbird/3.0.6
Am 28.09.2010 11:00, schrieb Andrea Crotti:
PJ Weisberg<address@hidden> writes:
It looks to me like what's happening is that in the hook it switches
to cpp-omnet-mode, and since that's derived from c++-mode it results
in c++-mode-hooks getting run again, so it again switches to
cpp-omnet-mode and runs c++-mode-hooks, ad infinitum.
I'm not an expert and I'm sure there's a better way to do it, but one
way I could suggest is to set a buffer-local variable to mark that
you're switching to cpp-omnet-mode, and don't switch to cpp-omnet-mode
again if it's already set.
That's exactly what happens, and also the solutions from Andreas doesn't
work, it still loops forever.
But I don't understand why, since if the OR is short circuiting...
But probably I never really pass to cpp-omnet UNTIL all the hooks in
c++-mode have been executed.
I don't see how the variable could help me with that, maybe an example?
Using a variable is the right thing.
Even example code would work, if your mode, once set, returns it.
Begin questioning, if the variable is set:
(setq my-code-already-active-p t)
This should avoid the loop.
Another non related thing, I made a ned-file mode derivate of cc-mode,
because it comes handy for many things, but now is there a way to tell
yasnippet to expand ONLY the snippets for ned-mode?
Otherwise I also see all the snippets for C and C++ which I don't need
at all in this case..