all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: 21465@debbugs.gnu.org
Subject: bug#21465: [PATCH] CC-modes hierarchy
Date: 14 Sep 2015 19:33:49 -0000	[thread overview]
Message-ID: <20150914193349.13729.qmail@mail.muc.de> (raw)
In-Reply-To: <mailman.971.1442025193.19560.bug-gnu-emacs@gnu.org>

In article <mailman.971.1442025193.19560.bug-gnu-emacs@gnu.org> you wrote:
> Package: Emacs
> Version: 25.0.50


> Any objection to the patch below?

> It does the following:
> - Move code common to all CC-mode major modes to a c-mode-common-mode function.
> - Add new c-derivative-mode as a parent of C, C++, and ObjC, for
>   settings which apply to C-derived languages but not for others.
>   This has become necessary given that CC-mode is used nowadays as an
>   engine for modes which have little to do with C.
> - Remove code that's redundant with what define-derived-mode does:
>   - set local-map
>   - set syntax-table
>   - set keymap parent
> - Remove c-make-inherited-keymap, since it's not used any more.
> - Fix c-after-font-lock-init so it only *moves* the function, and doesn't
>   accidentally add it (in case the derived mode decided to remove the function
>   from the hook, for example).

Why?  What is the point of the change?  It introduces an extra layer onto
the stack of major modes, but this extra layer seems to do no more than
execute two forms, `(c-initialize-cc-mode t)' and `(setq abbrev-mode t)'.
There is no coherence here, just two forms which happen to be in several
mode's initialisation routines and put together, even though they don't
form a coherent whole.  If this is to be done, surely a defun rather than
an extra layer of moding would be better.

c-derivative-mode would really need to be called c-c-derivative mode to
avoid confusion, since the prefix "c-" is just a name prefix.  But again,
what's this mode for?  It does nothing other than add a single binding to
a newly created key map.  I'm not convinced there's any need to be able to
treat the "C derivative" languages differently from all the others - 
anything you'd do in C++ Mode, you'd also be wanting to do in Java Mode
in the (somewhat unusual) circumstance that you're hacking both languages.
There's `c-mode-common-hook' for this.  Occasionally, people ask which
hook they should make their changes in.  The standard recommendation is
in `c-mode-common-hook' apart from (rare) things which are specific to
just one language.  If there are one or two extra levels of mode hook,
there will be extra confusion.

These new modes would add all the complexity of key maps, mode hooks, and
whatever, yet not achieve any coherent abstraction.  They would fragment
the initialisation code.  (Not that the current initialisation code is
anything to write home about, but this rearrangement wouldn't be an
improvement.)

c-after-font-lock-init surely isn't broken.  c-after-change is ALWAYS on
after-change-functions.  Without it, CC Mode simply wouldn't function.  Or
is there some way that Font Lock is called before CC Mode's
initialisation, and c-after-change is somehow sneeking onto the hook
twice?  Or something like that.

There is probably scope for getting rid of the explicit settings of the
local key map, syntax table, and so on.

> AFAIK this patch has no issues w.r.t compatibility since it relies on
> behavior of define-derived-mode which has existed since "for ever".
> But it hasn't seen much testing, admittedly (except for my own personal use).

The question is, will XEmacs's define-derived-mode work?

By the way, abbrev mode is used to expand "else" and "while" to themselves
+ re-indentation.  There are one or two other keywords handled likewise.
This isn't something either of us like, but doesn't seem urgent enough
to get round to fixing.

>         Stefan

[ patch read and snipped. ]

-- 
Alan Mackenzie (Nuremberg, Germany).






  parent reply	other threads:[~2015-09-14 19:33 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-12  2:32 bug#21465: [PATCH] CC-modes hierarchy Stefan Monnier
2015-09-12 16:51 ` Mark Oteiza
2015-09-13 13:25   ` Stefan Monnier
2015-09-13 16:06     ` Mark Oteiza
2015-09-13 20:24       ` Stefan Monnier
2015-09-13 21:18         ` Mark Oteiza
     [not found] ` <mailman.971.1442025193.19560.bug-gnu-emacs@gnu.org>
2015-09-14 19:33   ` Alan Mackenzie [this message]
2015-09-15  1:06     ` Stefan Monnier
2015-09-16 13:57       ` Alan Mackenzie
2015-09-17  1:49         ` Stefan Monnier
2015-09-17 12:30           ` Alan Mackenzie
2015-10-09 20:35             ` Stefan Monnier
2015-10-09 20:49     ` Stefan Monnier
     [not found]     ` <jwva8rrsrsu.fsf-monnier+emacsbugs@gnu.org>
2020-09-07 16:52       ` Lars Ingebrigtsen
2020-09-07 20:03         ` Alan Mackenzie
2020-09-07 20:40           ` Stefan Monnier
2020-09-08 10:11             ` Lars Ingebrigtsen
2015-09-15  8:46 ` Zhang Kai Yu
2015-09-19 18:43 ` Jostein Kjønigsen
2015-09-20 13:35   ` 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

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

  git send-email \
    --in-reply-to=20150914193349.13729.qmail@mail.muc.de \
    --to=acm@muc.de \
    --cc=21465@debbugs.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.