[Top][All Lists]

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

Re: c-style-alist

From: Andrea Crotti
Subject: Re: c-style-alist
Date: Sat, 25 Sep 2010 13:54:57 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (darwin)

Andrea Crotti <> writes:

> Supposing I have a new language (actually NED), and I already have some
> syntax highlighting.
> The only thing I want to add is a smarter indentation, and for that is
> quite similar to C++.
> Looking for possible answers I found out that in
> c-style-alist there is also for example python-mode, which is not a
> c-mode derivatives.
> Is that is the general way to define the correct the policy of spacing?
> And what if I define it as a derived mode even if it's quite different
> from the original c/c++ branch?

I solved  making that mode a derived-mode from cc-mode.
Then I created another derived-mode for c++ files used by omnetpp, but
I'm struggling to make it automatically enabled.

It's very very simple
--8<---------------cut here---------------start------------->8---
(require 'derived)

(define-derived-mode cpp-omnet-mode c++-mode "C++ Omnet mode"
  "Major mode for editing c++ files used with omnet++"

(provide 'cpp-omnet-mode)
--8<---------------cut here---------------end--------------->8---

and I thought I could do simply something like
--8<---------------cut here---------------start------------->8---
  ;; Look for the file .ini or the header inclusion
  (defun is-omnet-cpp-file ()
        (or (file-exists-p "omnetpp.ini")
            (search-forward "<omnetpp.h>"))
  ;FIXME: Not working correctly yet, because it goes in infinite loop
  ;; (add-hook 'c++-mode-hook 'is-omnet-cpp-file)
--8<---------------cut here---------------end--------------->8---

But it's not fine, since it will evaluate infinitely this hook.
Another possibility would be to use "find-file-hook", but it doesn't
really make sense because the files possible are a subset of c++ files.

How can I make it non recurse keeping this?
Or some other suggestions?

reply via email to

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