emacs-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] Flymake support for C/C++


From: João Távora
Subject: Re: [PATCH] Flymake support for C/C++
Date: Thu, 12 Oct 2017 22:24:59 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux)

Hello again, Alan.

Alan Mackenzie <address@hidden> writes:

> Yes.  It tightly couples Flymake Mode with CC Mode.  It would render CC
> Mode non-functional in the absence of Flymake Mode.

If this your criteria for "tightly coupled", then it does not apply
here. c--setup-flymake simply adds to a(n abnormal) hook, using
add-hook, which is designed to be used even if the hook variable isn't
defined yet.

(There is actually a bit of unglyness in the current patch, in which
c--setup-flymake also `defvar's and `setq-local's another obsolete
variable. I could remove that bit and come up with a pure add-hook
solution.)

> thus adding to a CC Mode hook.  Major mode hooks are usually not used by
> Emacs itself, but I'm not aware of any convention which prohibits it.

Perhaps the example that I gave you is one of the reaons.

> OK, so f-d-functions could be set in c-mode-common-hook then, couldn't
> it?

No, for the reasons that I restate below.

> I don't understand that last bit.  What's the difference between
> activation and setup?

Activation is enabling the minor mode via the flymake-mode
function. Setup is ensuring that that activation is met with suitable
circunstances for the correct operation of the minor mode, in this case
that cc-specific "backends" are set.

> It would seem then, the activation has nothing to
> do with the major mode, or else it could be done in a major mode hook.
> What am I missing here?

You are not mistaken that activation has nothing to do with the major
mode, but you are missing that there are two steps, activation and
setup, that the differ in the ways I hope to have clarified above.

> "Those two" being activation and setup?

No sorry, those two being the two hooks that you suggested.

> What do they need which is in CC Mode?

They need to hook on to the major mode's function.

> And how would a new CC Mode hook
> help?

That would appease your wish for very loose coupling in that no mention
of the word "flymake" needed to appear in cc-mode.el

> Would you be wanting it to be run before CC Mode is fully initialised?

Doesn't matter really, before the user's c-mode-common-hook is fine.

> "Do one thing and do it well".  Let's not get into the "do it well"
> bit here, but the "do one thing" is "edit C/C++/... buffers".  Flymake
> would appear to be distinct from that one thing.

Ah, I so do agree with you Alan... and let's get not into the million
ways Emacs is already the kitchen sink. Flymake can be as useful to a
pretty broad definition of "editing" as font-locking, or imenu, or
outline.el, or supporting add-log-current-defun-function. All those
things that really aren't "editing", but help you edit.

> What does Flymake do, anyway?

It highlights the bits where you make mistakes as you type, or are about
to.

> There's nothing in the Emacs manual
> about it, and it's doc string consists purely of boilerplate, at least
> in Emacs 25.3.

That is true, but the situation changes considerably, if not immensely,
in emacs 26 :-). I rewrote Flymake and wrote a fair amount of
documention. You can read the documentaion in Texinfo format in the
"Flymake" node (which is separate from the Emacs user manual, for now)
or just C-h f flymake-mode RET in a recent emacs-26 or master build.

> But it should be loosely coupled with major modes, not tightly coupled,
> surely?

For sure, we agree. If you analyse the situation I think you'll come to
the conclusion that it is.

João




reply via email to

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