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: Emacs developers <emacs-devel@gnu.org>,
	Tino Calancha <tino.calancha@gmail.com>
Subject: Re: [Emacs-diffs] master bb591f139f: Enhance CC Mode's fontification, etc., of unterminated strings.
Date: Wed, 23 May 2018 20:46:19 +0000	[thread overview]
Message-ID: <20180523204619.GB4191@ACM> (raw)
In-Reply-To: <877envijii.fsf@gmail.com>

Hello, João.

On Tue, May 22, 2018 at 20:21:25 +0100, João Távora wrote:
> Hi Alan,

> Alan Mackenzie <acm@muc.de> writes:

> > electric-tests.el is anything but straightforward to read.

> lol, sorry I couldn't quite make the 20000+LOC standards of cc-mode.el
> :p.

:-)

> No really, kidding, <wipes tears>, that file needs macros because it
> defines almost 500 tests with very subtle variations between them.

Yes, I understand this.

> You tripped one of them, and I think we're both glad you did
> (regardless of who is at fault: test or c++-mode)

Well, I'm glad about it, so thanks for this test file!.  The bug is most
definitely in CC Mode - I'd neglected to handle properly an open string
lacking an EOL to "terminate" it.  This will be easy to fix.

> > The test referred to above is generated by a nest of two or three
> > macros, somehow, and it is not obvious what buffer operations were
> > generated by these macros, and how they triggered a newly introduced bug
> > in C++ Mode.  The comments in the file are too sparse to help.

> Here's how it works: There's only one macro for electric-pair tests,
> aptly named define-electric-pair-test.

> In that file, find the `define-electric-pair-test' that most closely
> matches the test failure, in this case its:

>    (define-electric-pair-test autowrapping-5
>      "foo" "\"" :expected-string "\"foo\"" :expected-point 2
>      :fixture-fn #'(lambda ()
>                      (electric-pair-mode 1)
>                      (mark-sexp 1)))

> now go to the end of the expression and type M-x
> pp-macroexpand-last-sexp. It should be easy to find your failing test,
> defined in terms of `ert-deftest', in a list of 6 tests. Here it is:

>   (ert-deftest electric-pair-autowrapping-5-at-point-2-in-c++-mode-in-strings nil
>   "With |\"foo\"|, try input \" at point 2. Should become |\"\"foo\"\"| and point at 3"
>                (electric-pair-test-for "\"foo\"" 2 34 "\"\"foo\"\"" 3 'c++-mode nil
>                                        #'(lambda nil
>                                            (electric-pair-mode 1)
>                                            (mark-sexp 1))))

> Now M-x edebug-defun this form straight in the *Pp Macroexpand Output*
> buffer, and M-x edebug-defun the `electric-pair-test-for' defun,
> too. Now run the test:

>   M-x ert RET electric-pair-autowrapping-5-at-point-2-in-c++-mode-in-strings RET

Thanks for this recipe.  It wasn't self evident.

> As you step through the code, you'll eventually land on that lambda
> which calls mark-sexp and hints, along with the name, that this is a
> region-autowrapping test. This is why it expects, for a single character
> of input, that two quotes are inserted in the buffer instead of
> one. The test passes in my 26.1 as you probably already knew.

> Good luck hunting the bug and let me know if you have more problems.

Thanks for the help.

> Thanks,
> João

> PS: you could also have used:

>    M-x ert-describe-test RET electric-pair-autowrapping-5-at-point-2-in-c++-mode-in-strings

> Which would have rendered a nice docstring

>     electric-pair-autowrapping-5-at-point-2-in-c++-mode-in-strings is a
>     test defined in `electric-tests.elc'.
     
>     With |"foo"|, try input " at point 2. Should become |""foo""| and point at 3
     
>     [back]

> Though, admittedly, this is misleading for the "autowrapping" tests,
> since it doesn't tell you about the "mark-sexp" region-making
> command. Also not immediatly clear perhaps it that the | are buffer
> boundaries.

Just to be pedantic, it also doesn't say where " number 4 is inserted
(whether at EOL, or before " number 2), but that can be resolved by the
application of intelligence.  :-)

> Ideally, it should read read

>   With |"foo"|, at point 2, (mark-sexp 1) and try input ".
>   Should become |""foo""| and point at 3

> I will try to fix this in master.

> Also M-x ert-find-test-other-window could have helped you, but it
> doesn't (brings me to the beginning of the file, which isn't helpful). I
> don't know why, does anyone?

-- 
Alan Mackenzie (Nuremberg, Germany).



  parent reply	other threads:[~2018-05-23 20:46 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 [this message]
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
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=20180523204619.GB4191@ACM \
    --to=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    --cc=joaotavora@gmail.com \
    --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).