help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: c-style-alist


From: Andreas Röhler
Subject: Re: c-style-alist
Date: Tue, 28 Sep 2010 12:41:49 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.1.11) 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:

(unless my-code-already-active-p
   ... ACTIVATE
  (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..
Thanks,
Andrea







reply via email to

[Prev in Thread] Current Thread [Next in Thread]