From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: joaotavora@gmail.com (=?utf-8?B?Sm/Do28gVMOhdm9yYQ==?=) Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] master bb591f139f: Enhance CC Mode's fontification, etc., of unterminated strings. Date: Tue, 22 May 2018 20:21:25 +0100 Message-ID: <877envijii.fsf@gmail.com> References: <20180522174054.GA4504@ACM> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1527016872 18100 195.159.176.226 (22 May 2018 19:21:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 22 May 2018 19:21:12 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: Emacs developers , Tino Calancha To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue May 22 21:21:08 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fLCqJ-0004Zp-Pg for ged-emacs-devel@m.gmane.org; Tue, 22 May 2018 21:21:08 +0200 Original-Received: from localhost ([::1]:57504 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fLCsQ-0003Ai-RJ for ged-emacs-devel@m.gmane.org; Tue, 22 May 2018 15:23:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58827) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fLCqk-0002Dd-1g for emacs-devel@gnu.org; Tue, 22 May 2018 15:21:35 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fLCqg-0003zG-NY for emacs-devel@gnu.org; Tue, 22 May 2018 15:21:34 -0400 Original-Received: from mail-wr0-x22a.google.com ([2a00:1450:400c:c0c::22a]:35334) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fLCqg-0003yw-Ga for emacs-devel@gnu.org; Tue, 22 May 2018 15:21:30 -0400 Original-Received: by mail-wr0-x22a.google.com with SMTP id i14-v6so22164094wre.2 for ; Tue, 22 May 2018 12:21:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=BDHHihYPFf0zbsub53jLGEIIlUy9x1VaHjRyaunxUJk=; b=l2xKMOQDojMqMt3igDKnpfBCLIrPGVMq0dzLsrKipTslkbztGQz3e3zp8K+Wi0tvYP MDaWqIfFebAjPARak1S0jac5nVMS06BYZikCIZySiq6Y4xTJ0CkFgXANdBiziBHBOA6e sFHKo9Cg3XRGXbqovy7i1aoRjSONlRk8uD4wQvIoDimHF/gGYC3KU4NkzqZaUEkQsyI/ Xz8EI/FeBwAyJta+yQ0dhDq2cGs7JtGtXQOKcIffKilEohhv8vxnNxkS55d698YtCMfW l7jhE/XvOI3V43bjoETi6OM8mN0duV93Y+uO6r4o9YqujUjfW/Nm7IqON9ChReinMEaN hGxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=BDHHihYPFf0zbsub53jLGEIIlUy9x1VaHjRyaunxUJk=; b=h6O6WYOOcXRfIO8jlr7T6PTNTDxX0M0YCdWv1Zc1QgrivlDlc365B2hLb+VZnCL4un ybbOrS2oLn2RmKtyJTI3V5T53zHBwBzU5+azog3NtgaEibpOcDDsBiJoHM6kirqWjcNN tiYe0nHND1wbs8QxVFoNTFDq2CeZL8W/0L+rLffXPEQHdy+j8EG4MRfyZJ+pq+BAW2KN niGqDWZXqezxmfAGMaiHRa0GdheeQ2BAJiXABjbFTfpIrhL9Z/1pFdbVbYxGgJpP4tOP leDRMGg1o+5/pdTe4hNKX05TMNl8tPpQUDmaH2PgiPbyKVMSg0tfy4e4FhDi2KEoTjaz UKjQ== X-Gm-Message-State: ALKqPweQ27vJ5MUmb7l+uql4KguSOpFWzoh5BwHtN1V4qe4DCeMWcPzS X+nU3+I1fkgpr5pJRmHwFuQn+TKN X-Google-Smtp-Source: AB8JxZo2TOsbSbrgciR5hWd09QRNYTvu04kFsTYJAAUZYfuBrussCXdmdJTNvoR0GLl75+t+5VFk1A== X-Received: by 2002:adf:c98c:: with SMTP id f12-v6mr14783490wrh.272.1527016888758; Tue, 22 May 2018 12:21:28 -0700 (PDT) Original-Received: from lolita.yourcompany.com (188.139.62.94.rev.vodafone.pt. [94.62.139.188]) by smtp.gmail.com with ESMTPSA id u35-v6sm24553014wrc.29.2018.05.22.12.21.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 22 May 2018 12:21:27 -0700 (PDT) In-Reply-To: <20180522174054.GA4504@ACM> (Alan Mackenzie's message of "Tue, 22 May 2018 17:40:54 +0000") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22a X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:225573 Archived-At: Hi Alan, Alan Mackenzie 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, , that file needs macros because it defines almost 500 tests with very subtle variations between them. You tripped one of them, and I think we're both glad you did (regardless of who is at fault: test or c++-mode) > 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-strin= gs 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-string= s RET 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, Jo=C3=A3o 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'. =20=20=20=20=20 With |"foo"|, try input " at point 2. Should become |""foo""| and point= at 3 =20=20=20=20=20 [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. 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?