unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: bug-cc-mode@gnu.org, emacs-devel@gnu.org
Subject: Re: Reify the cc-mode-common into an actual parent mode
Date: Sun, 29 May 2016 10:00:20 +0000	[thread overview]
Message-ID: <20160529100020.GB3367@acm.fritz.box> (raw)
In-Reply-To: <jwvtwhink5z.fsf-monnier+emacs@gnu.org>

Hello, Stefan.

On Sat, May 28, 2016 at 02:08:47PM -0400, Stefan Monnier wrote:
> > The canonical way to create a mode derived from CC Mode is to derive
> > from, say, `c-mode', call `c-add-language', then specify the values
> > of the language variables which differ from those of `c-mode'.

> Hmm... you don't seem to preach by example here: none of CC-mode's
> predefined modes inherit from another.

Indeed not.  In this sense, they are "special" modes.

> So I'm not sure "canonical" is the appropriate word.

I think it is.  Although it is certainly open to a mode hacker to go
through cc-langs.el adding in values for every language variable for her
new mode, it is far less troublesome to use `c-add-language', which uses
an existing mode (not necessarily one of the seven "blessed" modes) as a
basis.

I'm not aware of anybody attempting to modify CC Mode itself to add an
eigth language into it.

> I also looked at some of the externally maintained major modes that rely
> on CC-mode, and they generally don't seem to derive from any of your
> predefined modes either.

By the way, thanks for listing out these modes in cc-mode.el.  I've only
looked at one or two of them.  csharp-mode.el, for example, does use
`c-add-language'.

> > There's nothing coherent about `c-mode-common'; it isn't sensible to set
> > a buffer to this mode, and it would be erroneous to attempt to derive a
> > mode (other than the seven within CC Mode) directly from it, since the
> > language variables for the new mode wouldn't get initialised.

> Currently all CC modes seem to either derive from prog-mode or from
> fundamental-mode, so they all have the same need to explicitly call
> things like (c-init-language-vars-for <mymode>).  Using c-mode-common
> doesn't make any difference in this respect.

Yes.  `c-init-language-vars-for' is a large part of what distinguishes
one CC mode from another.  This is a bit like how buffer local variables
distinguish between major modes, more or less.

> > modes that have them.  It so happens that, at the moment, those two
> > functions don't affect `c-update-modeline', so things work, but this
> > executing in the wrong order is storing up trouble for the future, should
> > some form in `c-mode''s :after-hook position need executing before
> > `c-update-modeline'.

> The fact that they don't interfere is not an accident, IMO.

Possibly not.

> [ BTW, I notice that define-derived-mode doesn't document the relative
>   order of execution of inherited :after-hooks.  It's probably better
>   that way, admittedly.  ]

A fine point, but maybe you're right.

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e


  reply	other threads:[~2016-05-29 10:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-24  0:41 Reify the cc-mode-common into an actual parent mode Stefan Monnier
2016-05-28 11:30 ` Alan Mackenzie
2016-05-28 17:51   ` Stefan Monnier
2016-05-29  9:45     ` Alan Mackenzie
2016-05-29 14:53       ` Stefan Monnier
2016-05-28 18:08   ` Stefan Monnier
2016-05-29 10:00     ` Alan Mackenzie [this message]
2016-05-30 17:37       ` Stefan Monnier

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160529100020.GB3367@acm.fritz.box \
    --to=acm@muc.de \
    --cc=bug-cc-mode@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).