From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#36328: 26.2; Args out of range on search-and-replace of *.cc file Date: Tue, 25 Jun 2019 22:58:56 +0300 Organization: LINKOV.NET Message-ID: <87lfxpzbb3.fsf@mail.linkov.net> References: <20190622205033.GA9167@ACM> <20190623122207.GA4736@ACM> <20190623193258.GB4736@ACM> <87k1dc2e5h.fsf@mail.linkov.net> <20190624075218.GA4781@ACM> <87d0j27wiu.fsf@mail.linkov.net> <20190625094708.GB5471@ACM> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="156815"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) Cc: Jayden Navarro , 36328@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jun 25 22:12:14 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hfrna-000efI-FW for geb-bug-gnu-emacs@m.gmane.org; Tue, 25 Jun 2019 22:12:14 +0200 Original-Received: from localhost ([::1]:35034 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfrnZ-0004sK-3R for geb-bug-gnu-emacs@m.gmane.org; Tue, 25 Jun 2019 16:12:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52043) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfrnR-0004po-Nw for bug-gnu-emacs@gnu.org; Tue, 25 Jun 2019 16:12:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hfrnP-0002hq-Hc for bug-gnu-emacs@gnu.org; Tue, 25 Jun 2019 16:12:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:48282) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hfrnP-0002fw-1L for bug-gnu-emacs@gnu.org; Tue, 25 Jun 2019 16:12:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hfrnO-0001hd-Rj for bug-gnu-emacs@gnu.org; Tue, 25 Jun 2019 16:12:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 25 Jun 2019 20:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36328 X-GNU-PR-Package: emacs Original-Received: via spool by 36328-submit@debbugs.gnu.org id=B36328.15614934636436 (code B ref 36328); Tue, 25 Jun 2019 20:12:02 +0000 Original-Received: (at 36328) by debbugs.gnu.org; 25 Jun 2019 20:11:03 +0000 Original-Received: from localhost ([127.0.0.1]:33588 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hfrmQ-0001ff-HI for submit@debbugs.gnu.org; Tue, 25 Jun 2019 16:11:02 -0400 Original-Received: from brown.elm.relay.mailchannels.net ([23.83.212.23]:8976) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hfrmM-0001fE-H6 for 36328@debbugs.gnu.org; Tue, 25 Jun 2019 16:10:59 -0400 X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 6990B5E30D8; Tue, 25 Jun 2019 20:10:57 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a33.g.dreamhost.com (100-96-91-148.trex.outbound.svc.cluster.local [100.96.91.148]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id D14E75E2DE3; Tue, 25 Jun 2019 20:10:56 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from pdx1-sub0-mail-a33.g.dreamhost.com ([TEMPUNAVAIL]. [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.17.2); Tue, 25 Jun 2019 20:10:57 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Trail-Snatch: 1ec1907d747b935f_1561493457219_1327411982 X-MC-Loop-Signature: 1561493457218:3712464975 X-MC-Ingress-Time: 1561493457218 Original-Received: from pdx1-sub0-mail-a33.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a33.g.dreamhost.com (Postfix) with ESMTP id E611380AAA; Tue, 25 Jun 2019 13:10:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=linkov.net; bh=QFvYsHzA0HJ5Ik8Fnc/8JoCLzIE=; b= cQliaUPfkMUThleb/90ClBgaWpP9c9JlbdsiY2u/ulW3hh7LcZTsCLFeD8LD3+i2 yhPDdACWjhmsgzTWpqsg1VzZOC+fPb0p38jWTb2PxMEcfN+JwwuCcGGMwbHR2CmI VSU7/XPRMMYniwWg1hdWCJJKWRmdjNA/VglH9qHSKJg= Original-Received: from mail.jurta.org (m91-129-109-209.cust.tele2.ee [91.129.109.209]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by pdx1-sub0-mail-a33.g.dreamhost.com (Postfix) with ESMTPSA id 625E580A5B; Tue, 25 Jun 2019 13:10:49 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a33 In-Reply-To: <20190625094708.GB5471@ACM> (Alan Mackenzie's message of "Tue, 25 Jun 2019 09:47:08 +0000") X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: -100 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeduvddrudeggddugeeiucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgdpffftgfetoffjqffuvfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufhofhffjgfkfgggtgesmhdtreertdertdenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucfkphepledurdduvdelrddutdelrddvtdelnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehmrghilhdrjhhurhhtrgdrohhrghdpihhnvghtpeeluddruddvledruddtledrvddtledprhgvthhurhhnqdhprghthheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqedpmhgrihhlfhhrohhmpehjuhhriheslhhinhhkohhvrdhnvghtpdhnrhgtphhtthhopegrtghmsehmuhgtrdguvgenucevlhhushhtvghrufhiiigvpedu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:161418 Archived-At: --=-=-= Content-Type: text/plain Hello, Alan. > My feeling is that perform-replace (or, possibly, replace-highlight) is > the best place to put a save-match-data. Doing this in perform-replace means adding save-match-data in all places where replace-highlight is called, so maybe better to add it only once in replace-highlight like Jayden proposed initially. But then it's important to add an explanatory comment since the need of using of save-match-data is not self-evident here. Do you think this comment is clear enough? --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=replace-save-match-data.patch diff --git a/lisp/replace.el b/lisp/replace.el index 9d1b7bf747..50c74be8f6 100644 --- a/lisp/replace.el +++ b/lisp/replace.el @@ -2316,7 +2316,11 @@ replace-highlight (isearch-forward (not backward)) (isearch-other-end match-beg) (isearch-error nil)) - (isearch-lazy-highlight-new-loop range-beg range-end)))) + (save-match-data + ;; Preserve match-data for perform-replace since + ;; isearch-lazy-highlight-new-loop calls `sit-for' that + ;; does redisplay that might clobber match data (bug#36328). + (isearch-lazy-highlight-new-loop range-beg range-end))))) (defun replace-dehighlight () (when replace-overlay diff --git a/lisp/term/tty-colors.el b/lisp/term/tty-colors.el index 307586f221..5af8170203 100644 --- a/lisp/term/tty-colors.el +++ b/lisp/term/tty-colors.el @@ -820,7 +820,7 @@ tty-color-canonicalize "Return COLOR in canonical form. A canonicalized color name is all-lower case, with any blanks removed." (let ((case-fold-search nil)) - (if (string-match "[A-Z ]" color) + (if (string-match-p "[A-Z ]" color) (replace-regexp-in-string " +" "" (downcase color)) color))) --=-=-=--