From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Philipp Stephani Newsgroups: gmane.emacs.bugs Subject: bug#34214: 25.3; minibuffer function help in lisp modes changes match-data Date: Sun, 27 Jan 2019 14:58:31 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="218530"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 34214@debbugs.gnu.org To: "Miguel V. S. Frasson" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jan 27 14:59:11 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.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gnkxq-000ujY-P4 for geb-bug-gnu-emacs@m.gmane.org; Sun, 27 Jan 2019 14:59:10 +0100 Original-Received: from localhost ([127.0.0.1]:46107 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gnkxp-000294-QJ for geb-bug-gnu-emacs@m.gmane.org; Sun, 27 Jan 2019 08:59:09 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:44041) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gnkxj-00027z-MG for bug-gnu-emacs@gnu.org; Sun, 27 Jan 2019 08:59:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gnkxi-0003SO-JE for bug-gnu-emacs@gnu.org; Sun, 27 Jan 2019 08:59:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47822) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gnkxi-0003SJ-Ah for bug-gnu-emacs@gnu.org; Sun, 27 Jan 2019 08:59:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gnkxi-0005Jo-8v for bug-gnu-emacs@gnu.org; Sun, 27 Jan 2019 08:59:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Philipp Stephani Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 27 Jan 2019 13:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34214 X-GNU-PR-Package: emacs Original-Received: via spool by 34214-submit@debbugs.gnu.org id=B34214.154859753020427 (code B ref 34214); Sun, 27 Jan 2019 13:59:02 +0000 Original-Received: (at 34214) by debbugs.gnu.org; 27 Jan 2019 13:58:50 +0000 Original-Received: from localhost ([127.0.0.1]:47103 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gnkxW-0005JM-0a for submit@debbugs.gnu.org; Sun, 27 Jan 2019 08:58:50 -0500 Original-Received: from mail-ot1-f48.google.com ([209.85.210.48]:39464) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gnkxU-0005J9-8u for 34214@debbugs.gnu.org; Sun, 27 Jan 2019 08:58:48 -0500 Original-Received: by mail-ot1-f48.google.com with SMTP id n8so12532800otl.6 for <34214@debbugs.gnu.org>; Sun, 27 Jan 2019 05:58:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5l1GRPsN/LfUOL1Hin9TCYAjLZK0xvN6fm/vTxkIoAI=; b=AkhsJQl03XVn7pkxXAouvaZeNBHE0VbELphmJL1tT0D2wIIwcKLlnh71ozDT9g5zAM qZyzEYy0iYP9aXcsD+ppf/wMm+li2g3DIfIPkbV51kfVbab4wA8LD/maDPnAcshYPUhN /8bw4wLIug7lPub6qQBtx2RSJtmKC4T7g7jfNjJpf0aG5keptiNC+PpO2ZI+Rk8ev7Q2 SLDGSFHhz/RuKnPleP2Z9K8yctpL9GF+7KA3OYgn9rQNK7tSmdeP44rYTgLTkkUNiWzb VLgEgSDqfF+i6XtkOKw1Lj7bSg92x0LA9dA+h7nzXRdl4XiHKya7Y5Cw7i/eAr2Gv6+7 Zy9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5l1GRPsN/LfUOL1Hin9TCYAjLZK0xvN6fm/vTxkIoAI=; b=QN95ww3CBMit9JYUvc410dm8TWBMUX+jGCHt5BjzkEFRJJj7GWSh9F7x++rk1Yh6N9 3F0trRsCfR+2y+EV+OALwXmbPlh4Z8gf69h/iuSbmE5WaFEbvj6CF3Qj9n9Ilcisiy3Z Rt6azRA0Lv0e5pn3Bcnfo0kvES04T0xGKwQgFKN4IK9ZvrFxwaR1nHtMi3ZPFCS6rFZh vyS+/1PxCeOLhTkE60NEADw0zMNnU80PWnDsvVh4utMgcbglbmqtw8peXIPPfQAICufi /KUa+3RL5hZfa+bGKnnd5pUYXQARpbe1NyoMkHFgfxG0Kwbi8BCq+BULqyTgkXO0n57n 7+Qg== X-Gm-Message-State: AJcUukf46Fd13eUdw/7cpUjpnlJjtFNxdR2sKRcDCVJILbpZ/T67PeHa 9AvutLVxyKEE1IA4tX6/KPb8xsN/iu3GKHFYmf0= X-Google-Smtp-Source: ALg8bN7tsBTMfNfZI7H6eGcN8yVQqZzsrQHVcMyAKTxoZtTyXL5bNsPOpxhpoTDtHSzN2htsER9SgHiZ/ALMKlsuKjU= X-Received: by 2002:a9d:4687:: with SMTP id z7mr14310883ote.350.1548597522061; Sun, 27 Jan 2019 05:58:42 -0800 (PST) In-Reply-To: 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:154810 Archived-At: Am So., 27. Jan. 2019 um 00:44 Uhr schrieb Miguel V. S. Frasson : > > Programming an Emacs lisp program that uses match-data, debugging pieces > by hand, I realized that managing matchs was a nightmare. At first I > thought that navigation commands like C-a or C-M-f were messing > match-data (as one could think they use searching). It could be. But > for sure, that very handy help line that shows function arguments are > messing match data, making difficult to program Emacs lisp. > > How to reproduce: > > 1) emacs -Q > > 2) type or paste the following code on *scratch* buffer > (must be a lisp programming mode): > > (string-match "f" "foo") > (match-string 0 "foo") > > Normal behavior > > 3) Go to end of string-match line, evaluate with C-x C-e > C-n (or down) so that point goes to end of 2nd line > *Very quickly* (do not let help for match-string appear), type > C-b C-f (or left right) > and evaluate: C-x C-e > I get correct result "f" > > Now the bug > > 4) Go to end of string-match line, evaluate with C-x C-e > C-n (getting to end of 2nd line) > C-b (or left) > ...wait minibuffer function help for match-string show... > C-f (or right) > C-x C-e > I get ERROR 'args-out-of-range "foo" 15 21' > > What I observed: > > Steps 3) and 4) are (almost) identical except for time spent between C-b > and C-f commands. Error is probably due to a match-data change, probably > caused by minibuffer function help mechanism. > > What I expect: > > No unnecessary side-effects like change match-data should happen while > simply navigating through code. Lisp modes should protect searches on > background with save-match-data, because it makes a nightmare to > evaluate code by hand. > Any function is allowed to change the match data, see https://www.gnu.org/software/emacs/manual/html_node/elisp/Match-Data.html: "Notice that all functions are allowed to overwrite the match data unless they're explicitly documented not to do so.". In general you almost always want to immediately bind the match results to variables, like so: (when (string-match "f" "foo") (let ((match (match-string 0 "foo"))) ... match)) Evaluating the entire 'when' form will then work as intended.