unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Phil Sainty <psainty@orcon.net.nz>
Cc: 2034@debbugs.gnu.org,
	bug-gnu-emacs
	<bug-gnu-emacs-bounces+psainty=orcon.net.nz@gnu.org>
Subject: bug#2034: [PATCH] 27.0.50; Support mode line constructs for `mode-name' in c-mode
Date: Sun, 8 Jul 2018 20:08:54 +0000	[thread overview]
Message-ID: <20180708200854.GA6311@ACM> (raw)
In-Reply-To: <6151a9339904bddb78507bc20d8484d6@webmail.orcon.net.nz>

Hello, Phil.

Just as an aside, something in the email chain between you and me has
irritatingly formatted your (and my) text like this:

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXX

, with every second line containing just one (or two) words.  Would you
please consider investigating this a little.

On Thu, Jul 05, 2018 at 09:13:38 +1200, Phil Sainty wrote:
> Hi Alan,

> On 2018-07-05 08:11, Alan Mackenzie wrote:
> > But I must confess, I'm not filled with enthusiasm by this change.
> > What is the problem it is fixing?  The original problem (use of a CC
> > Mode command by a non CC Mode mode) went away when cc-subword.el
> > became just subword-mode.

> I believe the original problem was the same as the problem I'm aiming
> to fix, which is that `c-update-modeline' imposes a non-standard
> restriction upon `mode-name' that it be a simple string (as opposed to
> containing arbitrary mode line constructs, as it should be able to do).

That's unnecessarily harsh.  The problem is that the definition of
mode-name was changed incompatibly some while back.  This seems a foolish
change - the name of a mode is essentially a string, and changing this
has led to problems.  The current code in CC Mode conforms to the
original definition of mode-name.

> It seems that the original symptom of the problem in this bug report
> went away as a side-effect of the change to subword-mode, but the bug
> itself remained.

> `c-update-modeline' even contains a "FIXME" comment about it:

>          ;; FIXME: Derived modes might want to use something else
>          ;; than a string for `mode-name'.

Why should anybody want to do that?  (Not a rhetorical question).

> > This change introduces complexity, even if, perhaps, not very much.
> > Do we really need a buffer local variable for the display of these
> > flags?  (That's a real question, not a rhetorical one.)  It seems to
> > be inviting misuse, given that it prevails for ever, but is really
> > only valid for the short time between it being calculated and the
> > mode line being displayed.

> In the current version of the patch, the buffer-local variable is used
> every time the mode line is rendered, as the variable *symbol* is
> incorporated into `mode-name'.  However Stefan made the suggestion that
> the flags themselves could become a list of mode line constructs, which
> would then mean it could be a global value rather than a buffer-local
> one, as each buffer would render that single construct into the
> appropriate flags for its own buffer.


> >     +(defvar-local c-modeline-flags-major-modes-processed nil
> >     +  "Major modes for which `c-update-modeline' has processed `mode-name'.

> > .... seems confused.

> That was a mistake on my part, and I was intending to change it from a
> list to a single value record of the most recent `major-mode' to be
> processed.

> The reason for having a record in the first place is that a major mode
> which is *derived* from, say, `c-mode' can trigger `c-update-modeline'
> repeatedly with different values for `major-mode', and if we see a
> *new* `major-mode' value then `mode-name' will also have been reset (to
> a string, in the existing cases), and needs to be processed again, as
> each major mode body resets `mode-name'.

This emphasises my earlier comment about the foolishness of the change to
the definition of mode-name.

> i.e. We need to process `mode-name' exactly once for whatever the final
> major mode is.

mode-name belongs to the major mode, and shouldn't be tampered with by
other SW.  It is part of the mode, as defined on Elisp page "Major Mode
Conventions", which states that the major mode set this variable to THE
pretty name of the mode.  It doesn't state that mode-name is merely a
template for manipulation by random code.  This, I believe, is the root
cause of the bug you are wanting to fix.

[ .... ]

> > As a final point, how is the backward compatibility of this change?
> > How many former Emacsen will it work in?

> I've not checked.  I think these mode line constructs have been stable
> for a long time?  If a new third-party derived mode was written to have
> a fancy `mode-name' then obviously that would only work with an Emacs
> version which contained these changes.  I'm not sure what you're
> getting at here, though...  Are you saying that people will use newer
> cc-mode code with older emacsen?  I can do some testing if I know what
> the use-case is.

Changes like this made in Emacs without backward compatibility code
exacerbate the growing difference between the Emacs version and the
upstream version.  The incompatible change in mode-name happened in Emacs
23.1.  Upstream CC Mode is still compatible with XEmacs, and (probably)
with Emacs 22, and it is one of the project's aims to preserve this
compatibility as much as possible.  Your proposed change destroys it.

That means either (i) Half of us have to write compatibility code for
both the Emacs version of and upstream CC Mode; or (ii) The compatibility
code is confined to upstream CC Mode (which is a royal pain when merging
upstream changes into Emacs); or (iii) the new code doesn't get merged
into the upstream (likewise a pain).

> -Phil

-- 
Alan Mackenzie (Nuremberg, Germany).





  parent reply	other threads:[~2018-07-08 20:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <8cbpgkqwkt.fsf@fencepost.gnu.org>
2009-01-25  2:10 ` bug#2034: 23.0.60; c-subword-mode incompatible with xml-mode me
2009-01-25 15:44   ` Stefan Monnier
2009-01-25 18:48     ` Ross Patterson
2010-01-23 22:36   ` bug#2034: marked as done (23.0.60; c-subword-mode incompatible with xml-mode) Emacs bug Tracking System
2018-07-02 12:40   ` bug#2034: [PATCH] 27.0.50; Support mode line constructs for `mode-name' in c-mode Phil Sainty
2018-07-02 15:29     ` Eli Zaretskii
2018-07-02 22:53       ` Phil Sainty
2018-07-03 13:37         ` Phil Sainty
2018-07-04  2:41         ` Eli Zaretskii
     [not found]   ` <mailman.3006.1530625089.1292.bug-gnu-emacs@gnu.org>
2018-07-04 20:11     ` Alan Mackenzie
2018-07-04 21:13       ` Phil Sainty
2018-07-08  2:46         ` Phil Sainty
2018-07-08 20:08         ` Alan Mackenzie [this message]
2018-07-09 14:47           ` Phil Sainty

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=20180708200854.GA6311@ACM \
    --to=acm@muc.de \
    --cc=2034@debbugs.gnu.org \
    --cc=bug-gnu-emacs-bounces+psainty=orcon.net.nz@gnu.org \
    --cc=psainty@orcon.net.nz \
    /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).