unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: "João Távora" <joaotavora@gmail.com>
Cc: Glenn Morris <rgm@gnu.org>,
	Emacs developers <emacs-devel@gnu.org>,
	Tino Calancha <tino.calancha@gmail.com>
Subject: Re: CC Mode and electric-pair "problem".
Date: Mon, 18 Jun 2018 10:36:54 +0000	[thread overview]
Message-ID: <20180618103654.GA9771@ACM> (raw)
In-Reply-To: <CALDnm50u+cWsTG27z_qprXH_HWBf2_CERiEuPHHO6b5_UT5u8Q@mail.gmail.com>

Hello, João.

On Sun, Jun 17, 2018 at 22:27:20 +0100, João Távora wrote:
> On Sun, Jun 17, 2018 at 9:13 PM, Alan Mackenzie <acm@muc.de> wrote:

> > Hello, Glenn.

> > On Sun, Jun 17, 2018 at 12:58:53 -0400, Glenn Morris wrote:
> > > Alan Mackenzie wrote:

> > > > However, the test suite (make check) threw up another discrepancy, in a
> > > > test called
> > > > electric-pair-whitespace-chomping-2-at-point-4-in-c++-mode-in-strings.

> > > Hello, is this still being worked on?
> > > The test continues to fail on RHEL 7 and hydra.nixos.org.

> > From my point of view, the bug is not being worked on this very day, but
> > has by no means been forgotten.  It has needed a period of mulling over.
> > I think João sees it the same way.


> Yes, while mulling over things is generally good, I believe the problem
> from Glenn's perspective is the nuisance of checking whether every
> test failure is something to worry about or just the thing being
> mulled over.

Yes.  But it is the master branch, where not everything can be expected
to work all the time.  I think the main thing is, we're _going_ to fix
this bug.

> So I suggest taking a quick temporary action to make the test pass
> and then think about how to do it properly.  This action could be
> disabling the test temporarily but IME that invariably buries the
> issue ad eternum. So it's better to do it in cc-mode.

Hmm.  To modify CC Mode temporarily to make 'chomp in electric-pair-mode
work would be an order of magnitude more work than "simply" to fix the
bug.  That's without disabling the handling of " in CC Mode entirely.

> Although it won't be difficult to fix, this bug is an awkward thing, and
> > will need decisions (smallish ones) to be taken.

> > My favoured method would be to alter electric-pair--skip-whitespace such
> > that a NL terminating a string (as contrasted with a NL terminating a
> > comment) would be allowed to be scanned over.


> I'm OK with adding an customization point to
> electric-pair--skip-whitespace that c-mode can customize.  But I also
> wonder whether the benefit to end-users of handling NL-terminated
> strings are worth it.  Perhaps there are indeed benefits, it's just that
> I haven't seen them argued.

OK, here goes.  Why should major modes tie themselves in knots, just so
that electric-pair-mode can work?  What CC Mode is doing is natural, and
matches the reality.  A C(++) compiler regards an unterminated string as
ending at the (first unescaped) linefeed.  It will then regard the next
line as code (not string).  If there is a subsequent ", the compiler
won't see that as a terminator for the unbalanced opening ".  CC Mode now
matches this reality, which is a Good Thing.

electric-pair-mode's chomp facility could be more rigorously coded -
sometimes it is dealing with visible whitespace, sometimes it is dealing
with syntactic properties.  Surely it should be working with visible
whitespace all the time?

I've attempted a bit of debugging.  In addition to
electric-pair--skip-whitespace, I encountered a scan-sexps in subfunction
ended-prematurely-fn of function electric-pair--balance-info, which
snagged on the end of string at EOL.

> But more importantly perhaps there are ways to reap these benefits in a
> way that doesn't require changes to e-p-m, or even better, in a way
> that benefits all of Emacs, not just c-mode.

We are talking about a corner case in e-p-m, namely where e-p-m attempts
to chomp space between parens inside an invalid string.  This surely
won't come up in practice very much.  Is it worth fixing?  (I would say
yes.)

> So, in practice, is the advantage here that the user is visually
> warned of an invalid NL-terminated string?

The user is visually informed of the reality: that one or more strings
are unterminated, and where the "breakage" is (where the
font-lock-string-face stops).  This is an improvement over the previous
handling, where the opening invalid " merely got warning-face, but the
following unterminated string flowed on indefinitely.

The disadvantage is that e-p-m is constraining major modes in how they
can use syntax-table text properties.  I think this is a problem in
electric-pair-mode, not in CC Mode.

> João

-- 
Alan Mackenzie (Nuremberg, Germany).



  reply	other threads:[~2018-06-18 10:36 UTC|newest]

Thread overview: 93+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-22  7:42 [Emacs-diffs] master bb591f139f: Enhance CC Mode's fontification, etc., of unterminated strings Tino Calancha
2018-05-22 17:40 ` Alan Mackenzie
2018-05-22 19:21   ` João Távora
2018-05-22 19:34     ` Eli Zaretskii
2018-05-22 20:25       ` João Távora
2018-05-22 22:17         ` João Távora
2018-05-23 14:52           ` Eli Zaretskii
2018-05-23 20:46     ` Alan Mackenzie
2018-05-23 21:12       ` João Távora
2018-05-23 23:21     ` Michael Welsh Duggan
2018-05-31 12:37 ` CC Mode and electric-pair "problem". (Was: ... master bb591f139f: Enhance CC Mode's fontification, etc., of unterminated strings.) Alan Mackenzie
2018-05-31 16:07   ` CC Mode and electric-pair "problem" João Távora
2018-05-31 17:28     ` Alan Mackenzie
2018-05-31 18:37       ` João Távora
2018-06-02 13:02         ` Alan Mackenzie
2018-06-03  3:00           ` João Távora
2018-06-17 16:58   ` Glenn Morris
2018-06-17 20:13     ` Alan Mackenzie
2018-06-17 21:07       ` Stefan Monnier
2018-06-17 21:27       ` João Távora
2018-06-18 10:36         ` Alan Mackenzie [this message]
2018-06-18 13:24           ` João Távora
2018-06-18 15:18             ` Eli Zaretskii
2018-06-18 15:37               ` João Távora
2018-06-18 16:46                 ` Eli Zaretskii
2018-06-18 17:21                   ` Eli Zaretskii
2018-06-18 23:49                   ` João Távora
2018-06-19  2:37                     ` Eli Zaretskii
2018-06-19  8:13                       ` João Távora
2018-06-19 16:59                         ` Eli Zaretskii
2018-06-19 19:40                           ` João Távora
2018-06-18 20:24                 ` Glenn Morris
2018-06-19  2:03                   ` João Távora
2018-06-18 15:42             ` Alan Mackenzie
2018-06-18 17:01               ` João Távora
2018-06-18 18:07                 ` Yuri Khan
2018-06-18 22:52                   ` João Távora
2018-06-18 18:08                 ` Alan Mackenzie
2018-06-18 23:43                   ` João Távora
2018-06-19  1:35                     ` João Távora
2018-06-19  1:48                   ` Stefan Monnier
2018-06-19  3:52                     ` Clément Pit-Claudel
2018-06-19  6:38                       ` Stefan Monnier
2018-06-20 13:48                         ` Clément Pit-Claudel
2018-06-26 16:08                     ` Fontifying unterminated strings [was: CC Mode and electric-pair "problem".] Alan Mackenzie
2018-06-26 20:02                       ` João Távora
2018-06-28 23:56                       ` Stefan Monnier
2018-06-29  0:43                         ` Stefan Monnier
2018-06-18 22:41                 ` CC Mode and electric-pair "problem" Stephen Leake
2018-06-19  0:02                   ` João Távora
2018-06-19  3:15                   ` Clément Pit-Claudel
2018-06-19  8:16                     ` João Távora
2018-06-19  5:02                 ` Alan Mackenzie
2018-06-20 14:16                   ` Stefan Monnier
2018-06-26 18:23                     ` Alan Mackenzie
2018-06-27 13:37                       ` João Távora
2018-06-29  3:42                       ` Stefan Monnier
2018-06-30 18:09                         ` Alan Mackenzie
2018-07-01  3:37                           ` Stefan Monnier
2018-07-01 15:24                             ` Eli Zaretskii
2018-07-06 21:58                             ` Stephen Leake
2018-07-01 15:57                           ` Paul Eggert
2018-06-27 18:27                     ` Alan Mackenzie
2018-06-29  4:11                       ` Stefan Monnier
2018-06-30 19:03                         ` Alan Mackenzie
2018-06-30 19:29                           ` Eli Zaretskii
2018-06-30 20:14                             ` Alan Mackenzie
2018-07-01  3:50                               ` Stefan Monnier
2018-07-01  9:58                                 ` Alan Mackenzie
2018-07-01 11:22                               ` João Távora
2018-07-01 15:25                                 ` Eli Zaretskii
2018-07-01 15:22                               ` Eli Zaretskii
2018-07-01 16:38                                 ` scratch/fontify-open-string. [Was: CC Mode and electric-pair "problem".] Alan Mackenzie
2018-07-08  8:29                                   ` Stephen Leake
2018-07-15  9:00                                     ` Stephen Leake
2018-07-15 15:13                                       ` Eli Zaretskii
2018-07-15 18:45                                         ` Alan Mackenzie
2018-07-16  2:23                                           ` Indentation of ?: in C-mode (was: scratch/fontify-open-string. [Was: CC Mode and electric-pair "problem".]) Stefan Monnier
2018-07-16 14:18                                             ` Eli Zaretskii
2018-07-16 15:54                                               ` Indentation of ?: in C-mode Stefan Monnier
2018-07-15 16:56                                       ` scratch/fontify-open-string. [Was: CC Mode and electric-pair "problem".] Alan Mackenzie
2018-07-17  3:41                                         ` Stephen Leake
2018-07-01  4:02                           ` CC Mode and electric-pair "problem" Stefan Monnier
2018-07-01 10:58                             ` Alan Mackenzie
2018-07-01 11:46                               ` João Távora
2018-07-01 16:13                               ` Stefan Monnier
2018-07-01 18:18                                 ` Alan Mackenzie
2018-07-01 23:16                                   ` Stefan Monnier
2018-07-02 19:18                                     ` Alan Mackenzie
2018-07-03  2:10                                       ` Stefan Monnier
2018-06-26 18:52                   ` Alan Mackenzie
2018-06-26 19:45                     ` João Távora
2018-06-26 20:09                       ` Alan Mackenzie

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=20180618103654.GA9771@ACM \
    --to=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    --cc=joaotavora@gmail.com \
    --cc=rgm@gnu.org \
    --cc=tino.calancha@gmail.com \
    /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).