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: spacibba@aol.com, emacs-devel <emacs-devel@gnu.org>,
	36474@debbugs.gnu.org
Subject: bug#36474: Algorithm in electric-pair--unbalanced-strings-p unsuitable for CC Mode
Date: Tue, 2 Jul 2019 18:28:11 +0000	[thread overview]
Message-ID: <20190702182811.GC30597@ACM> (raw)
In-Reply-To: <CALDnm51cMGU4+LP7N53o9uy5SASyCyTo2_jm99gDVnNcF=HgDw@mail.gmail.com>

Hello, João.

On Tue, Jul 02, 2019 at 18:22:34 +0100, João Távora wrote:
> On Tue, Jul 2, 2019 at 5:04 PM Alan Mackenzie <acm@muc.de> wrote:

> > > [did you mean to copy bug-gnu-emacs@gnu.org, or emacs-devel@gnu.org?
> > > I'm assuming the latter and correcting]
> > No, it's a bug, therefore I submitted a bug report.

> You should use the X-Debbugs-CC feature then (and why not continue
> in the existing bug 36423?)

I didn't know about the former, and as for the bug, it is a different
bug with differenct causes from #36423.

> Anyway, I insist this matter be brought to emacs-devel because it's a
> followup to a discussion that started there but never reached a
> suitable conclusion. For that reason, and because I provide a
> workaround for the bug  at the end of  this message, I'm cross-posting
> this one mail to both the bug list and emacs-devel.

> > > The arguments _against_ NL-terminated strings is that they (1) break
> > > longstanding features such as sexp-based navigation (e.g. `up-list`
> > > and friends) for modes such say, `js-mode` and (2) break features
> > > that expect this to work, most notably electric-pair-mode.

> > This isn't true.

> What "isn't true"? Have those features broken or not?

They may well be broken.  CC Mode hasn't broken them.  They made invalid
assumptions, which turned out to be unjustified.

> They worked before the fe06f643b commit and don't work after the
> commit. It sounds quite unrefutable to me.

I don't know what you're talking about.

> > If those other feature no longer work with an up to date Emacs, they
> > should be fixed.

> I've stated this repeatedly in the life of this discussion: it's not
> just about electric-pair-mode. If you try to M-x up-list from a
> multi-line string in emacs 26.1 it works just as well in js-mode and
> c++-mode.  In emacs master it does not in c++-mode. Same with
> forward-sexp on the starting delimiter, etc.

I've just tried these in a multiline string in C++ Mode.  Both up-list
and forward-sexp work just fine.  I don't know what you're doing.

> > The fontification that CC Mode does is natural and helpful, and users
> > haven't complained about it (except when there've been bugs).

> Yes, users haven't complained except when users have complained.

> > There have certainly been no complaints about using
> > font-lock-warning-face for the invalid string delimiters, and
> > font-lock-string-face for valid ones.

> That's because providing this annotation is perfectly fine.  The problem
> is providing it _at the expense of other features_.

If other features are broken (and your list of other broken features, so
far, is empty), they should be fixed.

> And _that's_ what they've complained about: an average user has no
> obvious way of telling that the particular implementation of the red
> annotation thingy is guilty of breaking his C-M-u or his
> electric-pair-mode.

That's groundless disparagement.  C-M-u works, and electric-pair-mode is
broken because it's broken.  In one place it's using scan-sexps to move
forward over whitespace, totally oblivious to the possibility of
syntax-table text properties (which have been in use since Emacs-21).
That's broken code.

> He/she might even judge the latter more vital than said red thingy
> , an annotation which he/she will get by other means if using
> very popular packages such as flycheck, or flymake, or eglot, or
> lsp-mode, etc. These normally call the compiler directly on the
> source code and highlight those and many other errors.

Irrelevant.

> On the other hand, if what you want is the red annotation, are you
> absolutely sure there isn't a better way to get it?

No, I'm not.  That's why I invited you to come up with a better way, if
you can.

> And if you are, are you also absolutely sure you need to put it in the
> code and and not provide an easy way to turn it off?

It's a core feature of the mode, not an option.

> > For this, I think we would both rather that you amend elec-pair.el rather
> > than me.

> I'll be "mulling this over". There are potentially many other points
> of breakage

"Potentially" many?  So far, there is precisely one, in
electric-pair--unbalanced-strings-p.  I thought I was doing you a favour
by diagnosing the trouble.  If I'd known I'd get the reaction from you
I've just got, I wouldn't have bothered.

> that would need such an indirection, and doing that to serve just a
> particular cc-mode quirk doesn't sound priority to me.

No, you'd be cleaning up your code, to conform with the reality that in
2019 major modes use syntax-table text properties.  Features from CC
Mode have a habit of migrating to the Emacs core.

> In the meantime, let others chime in.

> Also, in the meantime, for a user that is bothered by this bug,
> I'd recomend to put something like this in his/her .emacs file:

>   (defun c-unescaped-nls-in-string-p (&optional quote-pos) t)

It's free software, but that's a stupid thing to do.

> I had something more elaborate in my setup but just this
> seems to fix it in my testing.

> There is a also a very promising variable, c-multiline-string-start-char,
> that I think would be a good candidate for customizing this, ....

It is not a customisation variable.  It is a language definition
variable.

> .... but I haven't messed with it enough. Just setting it from .emacs
> doesn't do the trick. Perhaps in a mode hook?

Or, alternatively, actually fix the problems which have been festering
for years or decades, and are just now revealing themselves.  Thus far,
there's exactly one such problem in electric-pair--unbalanced-strings-p.

> --
> João Távora

-- 
Alan Mackenzie (Nuremberg, Germany).





  reply	other threads:[~2019-07-02 18:28 UTC|newest]

Thread overview: 82+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190702131632.GA30597@ACM>
     [not found] ` <CALDnm51Hi10KMqYneWBamNL4sNdzHEz6_NasGk=oR_y-=1Y7nQ@mail.gmail.com>
2019-07-02 15:27   ` Fwd: Algorithm in electric-pair--unbalanced-strings-p unsuitable for CC Mode João Távora
     [not found]   ` <20190702160410.GB30597@ACM>
2019-07-02 17:22     ` João Távora
2019-07-02 18:28       ` Alan Mackenzie [this message]
2019-07-02 21:11         ` bug#36474: " Stefan Monnier
2019-07-03  9:28         ` João Távora
2019-07-03 10:58           ` Alan Mackenzie
2019-07-03 13:07             ` Dmitry Gutov
2019-07-03 13:32               ` Alan Mackenzie
2019-07-03 14:25                 ` Dmitry Gutov
2019-07-03 15:58                 ` Eli Zaretskii
2019-07-03 20:54                   ` Alan Mackenzie
2019-07-04  2:33                     ` Eli Zaretskii
2019-07-04  1:36                 ` Richard Stallman
2019-07-03 13:33               ` Eli Zaretskii
2019-07-03 13:35               ` João Távora
2019-07-03 13:31             ` João Távora
2019-07-03 18:25               ` Kévin Le Gouguec
2019-07-04  0:52                 ` João Távora
2019-07-04  6:17                   ` Kévin Le Gouguec
2019-07-04 15:05               ` Alan Mackenzie
2019-07-04 15:50                 ` João Távora
2019-07-04 16:58               ` [PATCH] " Alan Mackenzie
2019-07-04 18:45                 ` João Távora
2019-07-04 19:01                   ` Alan Mackenzie
2019-07-04 21:44                     ` João Távora
2019-07-08 10:05                       ` Alan Mackenzie
2019-07-08 12:10                         ` João Távora
2019-07-08 15:49                         ` Stefan Monnier
2019-07-08 16:33                           ` Stefan Monnier
2019-07-08 17:24                             ` Alan Mackenzie
2019-07-08 17:32                               ` Stefan Monnier
2019-07-08 16:45                           ` Alan Mackenzie
2019-07-08 17:29                             ` Stefan Monnier
2019-07-08 18:05                               ` Alan Mackenzie
2019-07-08 20:59                                 ` Stefan Monnier
2019-07-09  6:41                                   ` Clément Pit-Claudel
2019-07-09  9:06                                     ` João Távora
2019-07-09  9:23                                       ` João Távora
2019-07-09  9:52                                         ` Alan Mackenzie
2019-07-09 10:54                                           ` João Távora
2019-07-09 11:18                                             ` João Távora
2019-07-09 15:18                                             ` Dmitry Gutov
2019-07-09 15:40                                               ` contextual refontification (was: [PATCH] Re: Algorithm in electric-pair--unbalanced-strings-p unsuitable for CC Mode) Stefan Monnier
2019-07-10  9:32                                                 ` João Távora
2019-07-09 15:43                                               ` [PATCH] Re: Algorithm in electric-pair--unbalanced-strings-p unsuitable for CC Mode João Távora
2019-07-09 15:31                                             ` Alan Mackenzie
2019-07-09 16:14                                               ` João Távora
2019-07-09 12:33                                       ` Clément Pit-Claudel
2019-07-09 14:28                                         ` João Távora
2019-07-09 16:05                                           ` Clément Pit-Claudel
2019-07-09 16:32                                             ` João Távora
2019-07-09 17:09                                               ` João Távora
2019-07-09 13:45                                     ` Stefan Monnier
2019-07-09 16:00                                   ` Alan Mackenzie
2019-07-09 17:11                                     ` Stefan Monnier
2019-07-09 18:26                                       ` Alan Mackenzie
2019-07-09 18:47                                         ` Eli Zaretskii
2019-07-09 18:53                                         ` João Távora
2019-07-10 10:32                                           ` Alan Mackenzie
2019-07-10 10:40                                             ` Lars Ingebrigtsen
2019-07-10 12:24                                               ` João Távora
2019-07-10 14:14                                                 ` Clément Pit-Claudel
2019-07-10 16:07                                                   ` João Távora
2019-07-11 15:14                                                 ` Lars Ingebrigtsen
2019-07-11 15:43                                                   ` João Távora
2019-07-11 15:51                                                     ` Lars Ingebrigtsen
2019-07-11 16:13                                                       ` João Távora
2019-07-12 15:58                                                         ` Lars Ingebrigtsen
2019-07-12 18:47                                                           ` João Távora
2019-07-13  0:08                                                             ` Lars Ingebrigtsen
2019-07-10 12:10                                             ` João Távora
2019-07-10 14:03                                               ` Alan Mackenzie
2019-07-10 16:05                                                 ` João Távora
2019-07-10 17:56                                                   ` Alan Mackenzie
2019-07-11  0:11                                                     ` Richard Stallman
2019-07-03 16:56             ` Stefan Monnier
2019-07-03 16:58             ` Stefan Monnier
2019-07-04 15:24               ` Alan Mackenzie
2019-07-04 15:52                 ` Stefan Monnier
2019-07-04 16:42                   ` Alan Mackenzie
2019-07-04 20:16                     ` Stefan Monnier
2019-07-04 21:27                     ` João Távora

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=20190702182811.GC30597@ACM \
    --to=acm@muc.de \
    --cc=36474@debbugs.gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=joaotavora@gmail.com \
    --cc=spacibba@aol.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).