From: Andrea Crotti <andrea.crotti.0@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: c-style-alist
Date: Sat, 25 Sep 2010 13:54:57 +0200 [thread overview]
Message-ID: <m11v8iyr5a.fsf@gmail.com> (raw)
In-Reply-To: m1wrqliwcg.fsf@95-015.eduroam.rwth-aachen.de
Andrea Crotti <andrea.crotti.0@gmail.com> 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 ()
(if
(or (file-exists-p "omnetpp.ini")
(search-forward "<omnetpp.h>"))
(cpp-omnet-mode)))
;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?
next prev parent reply other threads:[~2010-09-25 11:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-16 14:42 c-style-alist Andrea Crotti
2010-09-25 11:54 ` Andrea Crotti [this message]
2010-09-25 14:02 ` c-style-alist Andreas Röhler
2010-09-25 22:07 ` c-style-alist PJ Weisberg
2010-09-28 9:00 ` c-style-alist Andrea Crotti
2010-09-28 10:41 ` c-style-alist Andreas Röhler
[not found] ` <AANLkTinKPzz3aNY0e-7uOvK=3nN7Gs+dgf_3xv4+pLva@mail.gmail.com>
[not found] ` <B10177A4-D04A-417D-944C-F21564A9C4A9@gmail.com>
2010-09-29 22:02 ` c-style-alist PJ Weisberg
2010-10-06 14:13 ` c-style-alist Andrea Crotti
2010-10-06 21:40 ` c-style-alist PJ Weisberg
2010-10-07 16:30 ` c-style-alist Andrea Crotti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m11v8iyr5a.fsf@gmail.com \
--to=andrea.crotti.0@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.