unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Jostein Kjønigsen" <jostein@secure.kjonigsen.net>
To: Alan Mackenzie <acm@muc.de>, jostein@kjonigsen.net
Cc: emacs-devel@gnu.org
Subject: Re: cc-mode: Make all parameters introduced in Emacs 26 optional
Date: Mon, 12 Mar 2018 21:16:38 +0100	[thread overview]
Message-ID: <1520885798.1440538.1300560400.68951242@webmail.messagingengine.com> (raw)
In-Reply-To: <20180122203254.GA4888@ACM>

[-- Attachment #1: Type: text/plain, Size: 3698 bytes --]

Hey Alan.

Thanks for your answer!

> There's a convention in CC Mode that functions, macros, and variables> with a doc string are regarded as part of an "API" to derived
> modes, but> objects with merely a "doc comment" are regarded as internal to
> CC Mode,> and __much__ less secure against random changes.

I was unaware of such a convention, but that's  definitely useful to
know for the future.
> c-font-lock-declarators is one of these functions intended to be
> "internal".  If a derived mode like csharp-mode is using it directly,> one of the following is true:
> (i) There's a need for functionality which is currently lacking in CC> Mode.
> (ii) The maintainer of the derived mode is unaware of existing CC Mode> functionality which would satisfy his need.
> (iii) ???

That sounds like a valid assessment.

> Why is csharp-mode using c-font-lock-declarators at all?  Could it be> you're wanting to do something which currently can't be done with the> "API" functions/macros/variables?  If so, it might well be better to
> amend CC Mode to provide this functionality.

I'd hate to pass ball on this one, but I didn't write this
original code.
It's fairly messy and dirty I picked up from the internet and decided to
patch up when it started breaking with Emacs 24. Since then I've done my
best to keep it working, but I've never had time to clean it properly up
and I'm definitely not 100% in control w.r.t. what all parts of the code
actually does.
Why this particular function was chosen is something I cannot directly
answer for. This particular section of code has been unchanged since the
first commit in any version-controlled version of this code I can find,
by Dino Chiesa. As such, it's lacking a change/context which can further
explain the choice of function.
Definitely not an optimal situation.

> Well, to work properly, the caller of c-font-lock-declarators
> will need> to determine the `not-top' argument rather than just relying on a
> randomish default.  The meaning of the function has changed.
> `not-top'> doesn't seem suitable for being &optional.

That's a reasonable position indeed. I guess that puts me in the
position where I need to better figure out how this particular part of
the code actually works. I'm sure I'll appreciate that on some level
further down the road.
When/if I can get that done, that leaves me in a position where I'll
have to make a choice:
1. try to replace this broken section of code with something different
   (with a understanding of what it needs to do)2. keep using c-font-lock-declarators, in case I don't have time for
   a rewrite.
In the latter case, I will face a compatibility-issue between
Emacs versions.
Is there any way for package to know how many mandatory arguments a
function has, to be able to branch out for compatibility reasons? My
research so far haven't given me any obvious answer.
> Again, why is csharp-mode using this function?  Are there any other
> "internal" functions/macros/variables it is using?

That's indeed a good question. Seeing the kind of problems such usage
lands me in, I'd definitely want to reduce the scope of that.
A quick skim of the source-code uncovers at least the following
"internal" members used:
 * c-safe
 * c-put-character-property
 * c-put-font-lock-face
 * c-fontify-types-and-refs
 * c-forward-keyword-clause
 * c-font-lock-declarators
 * Not to mention it does monkey-patch/advice c-inside-bracelist-p and
   c-forward-objc-directive.
Like I said. This is dirty code, and I'm definitely not happy about the
state of affairs. As such, any advice appreciated.
--
Regards
Jostein Kjønigsen





[-- Attachment #2: Type: text/html, Size: 5221 bytes --]

  parent reply	other threads:[~2018-03-12 20:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-22  8:09 cc-mode: Make all parameters introduced in Emacs 26 optional Jostein Kjønigsen
2018-01-22 20:32 ` Alan Mackenzie
2018-02-03  5:59   ` Matthew Carter
2018-02-03  6:13     ` Matthew Carter
2018-02-03 11:44       ` Alan Mackenzie
2019-03-30 13:51         ` Alan Mackenzie
2019-03-30 16:39           ` Stefan Monnier
2019-03-30 19:42             ` Alan Mackenzie
2019-03-30 20:17               ` Stefan Monnier
2019-03-30 21:53                 ` Ergus
2018-03-12 20:16   ` Jostein Kjønigsen [this message]
2018-03-12 22:40     ` Stefan Monnier
2018-03-12 23:29       ` Clément Pit-Claudel
2018-03-13  1:00         ` Stefan Monnier
2018-03-13 20:08       ` Jostein Kjønigsen

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=1520885798.1440538.1300560400.68951242@webmail.messagingengine.com \
    --to=jostein@secure.kjonigsen.net \
    --cc=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    --cc=jostein@kjonigsen.net \
    /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).