From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: haj@posteo.de (Harald =?UTF-8?Q?J=C3=B6rg?=) Newsgroups: gmane.emacs.bugs Subject: bug#37127: [PATCH] cperl-mode: Suppress a misleading message Date: Thu, 29 Oct 2020 22:11:58 +0100 Message-ID: <87eelg3ffl.fsf@hajtower> References: <87ftlu67cy.fsf@vinc17.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17764"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) To: 37127@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 29 22:14:16 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kYFFP-0004Vz-R2 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 29 Oct 2020 22:14:15 +0100 Original-Received: from localhost ([::1]:55620 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYFFO-0006lG-Tn for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 29 Oct 2020 17:14:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33468) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYFEE-000602-7K for bug-gnu-emacs@gnu.org; Thu, 29 Oct 2020 17:13:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43558) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kYFED-0008R0-UE for bug-gnu-emacs@gnu.org; Thu, 29 Oct 2020 17:13:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kYFED-0001Wx-Ph for bug-gnu-emacs@gnu.org; Thu, 29 Oct 2020 17:13:01 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <87ftlu67cy.fsf@vinc17.net> Resent-From: haj@posteo.de (Harald =?UTF-8?Q?J=C3=B6rg?=) Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 29 Oct 2020 21:13:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37127 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 37127-submit@debbugs.gnu.org id=B37127.16040059285817 (code B ref 37127); Thu, 29 Oct 2020 21:13:01 +0000 Original-Received: (at 37127) by debbugs.gnu.org; 29 Oct 2020 21:12:08 +0000 Original-Received: from localhost ([127.0.0.1]:55104 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kYFDM-0001Vk-CS for submit@debbugs.gnu.org; Thu, 29 Oct 2020 17:12:08 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:46301) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kYFDJ-0001VG-QJ for 37127@debbugs.gnu.org; Thu, 29 Oct 2020 17:12:06 -0400 Original-Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id ECC202400FD for <37127@debbugs.gnu.org>; Thu, 29 Oct 2020 22:11:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1604005920; bh=3cLnFd5hVbXDc9zewVLLUbrnN4mzfCArSR+yhtF64Lc=; h=From:To:Subject:Date:From; b=TuMhbHrzLgMOHEwaEUil8Fx+S5JPadh/tEXDnyNWbiDGZcK61Cfm+VaSfdHE8fAxg vpgJm80khU7i1t0+Uat5Drg0hzl1RFGFOqGfN30MJX4wADTV2txlNqCcv+cIxYXtPR L2CQLikW/RiDVd8/IQrdb1nwWY7hovcPm7O9/dwi5VDtC1EzYCBzl/nA1BLP3S3coi 2NpTQJGEuzxqPo7fP7Fn+C/RXQ3bBTVURtfo7/qdzvDVr8eSxS0ECsvlrkFWcTyRn1 aiI1VQCHnixtymbpMdlTRIHtdEDMO/vcd0lpaDEV6KqSY7JFVy1dxzkx05gJlSFgGA JyXuiepwv/Vgg== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4CMdRg2nBZz9rxS for <37127@debbugs.gnu.org>; Thu, 29 Oct 2020 22:11:59 +0100 (CET) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:192000 Archived-At: --=-=-= Content-Type: text/plain The unjustified message about a missing end of a RE is rather harmless, it goes away after the next keystroke. Nevertheless, this can be fixed. It also happens in several related situations. The message has its cause in the apparently totally unrelated function 'blink-matching-open'. Whenever a closing paren is inserted, this function highlights the corresponding opening paren for a short time. As part of its processing, it narrows the buffer so that it ends with the closing paren - thereby excluding the end of the regular expression. In this state, it calls 'syntax-propertize', which in turn runs through the cperl-mode functions for syntaxification, ending up eventually in 'cperl-forward-re' - which fails to find the end of the regular expression in the narrowed buffer. The patch suppresses the message if the following conditions are met: 1) The buffer is currently narrowed 2) We are at the end of the (narrowed) buffer 3) The error in question is of type 'scan-error The patch also contains a test to verify that the message isn't written in the situation given in the bug report, and also that the message is written if we do indeed have an unterminated regular expression. -- Cheers, haj --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Suppress-a-misleading-message-when-closing-a-paren-i.patch Content-Description: Suppress a misleading message >From 85b8ccab3d5e43a4a3d4e622529248973b606a04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harald=20J=C3=B6rg?= Date: Thu, 29 Oct 2020 21:03:12 +0100 Subject: [PATCH] ; Suppress a misleading message when closing a paren in a regex * lisp/progmodes/cperl-mode.el (cperl-forward-re): Suppress an error message about "End of string/RE not found" when we are at the end of a narrowed buffer where the end of a RE is temporarily unavailable (Bug#37127). * test/lisp/progmodes/cperl-mode-tests.el (cperl-bug37127): Add a test to verify that the message is suppressed when inappropriate, but appears when the RE *is* incomplete. --- lisp/progmodes/cperl-mode.el | 7 ++++++ test/lisp/progmodes/cperl-mode-tests.el | 29 +++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el index ebbea6bed9..94f42cb2bc 100644 --- a/lisp/progmodes/cperl-mode.el +++ b/lisp/progmodes/cperl-mode.el @@ -3225,6 +3225,13 @@ cperl-forward-re (and cperl-brace-recursing (or (eq ostart ?\{) (eq starter ?\{))) + ;; If we are at the end of a narrowed buffer, then a + ;; scan error should not be reported to the user. + ;; This situation actually happens when a closing + ;; paren is entered in a regular expression. + ;; Reported in Bug#37127. + (and (eobp) (buffer-narrowed-p) + (equal (car bb) 'scan-error)) (message "End of `%s%s%c ... %c' string/RE not found: %s" argument diff --git a/test/lisp/progmodes/cperl-mode-tests.el b/test/lisp/progmodes/cperl-mode-tests.el index e67678cf6b..4b949bc9a7 100644 --- a/test/lisp/progmodes/cperl-mode-tests.el +++ b/test/lisp/progmodes/cperl-mode-tests.el @@ -218,4 +218,33 @@ cperl-mode-fontify-punct-vars (should (equal (nth 3 (syntax-ppss)) nil)) (should (equal (nth 4 (syntax-ppss)) t)))))) +(ert-deftest cperl-bug37127 () + "Verify that closing a paren in a regex goes without a message. +Also check that the message is issued if the regex terminator is +missing." + (let (collected-messages) + ;; Part one: Regex is ok, no messages + (ert-with-message-capture collected-messages + (with-temp-buffer + (insert "$_ =~ /(./;") + (cperl-mode) + (goto-char (point-min)) + (search-forward ".") + (let ((last-command-event ?\))) + (cperl-electric-rparen 1) + (cperl-find-pods-heres (point-min) (point-max) t))) + (should (string-equal collected-messages ""))) + ;; part two: Regex terminator missing -> message + (ert-with-message-capture collected-messages + (with-temp-buffer + (insert "$_ =~ /(..;") + (goto-char (point-min)) + (cperl-mode) + (search-forward ".") + (let ((last-command-event ?\))) + (cperl-electric-rparen 1) + (cperl-find-pods-heres (point-min) (point-max) t))) + (should (string-match "^End of .* string/RE" + collected-messages))))) + ;;; cperl-mode-tests.el ends here -- 2.20.1 --=-=-=--