From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: find-file-noselect needs save-match-data Date: Wed, 13 Jun 2007 15:55:40 -0400 Message-ID: References: <46665AD7.7040706@gmx.at> <87k5ueq23m.fsf@kfs-lx.testafd.dk> <87myz8c10t.fsf@jurta.org> <18030.3441.204697.244518@rgrjr.dyndns.org> <87zm3515r4.fsf@jurta.org> <85k5u8x2gm.fsf@lola.goethe.zz> <87r6og6czf.fsf@catnip.gol.com> <85bqfkx0i5.fsf@lola.goethe.zz> <85tztbvh4d.fsf@lola.goethe.zz> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1181764560 1318 80.91.229.12 (13 Jun 2007 19:56:00 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 13 Jun 2007 19:56:00 +0000 (UTC) Cc: rms@gnu.org, miles.bader@necel.com, schwab@suse.de, emacs-devel@gnu.org, juri@jurta.org, miles@gnu.org To: David Kastrup Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jun 13 21:55:58 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HyYwf-0004LC-LL for ged-emacs-devel@m.gmane.org; Wed, 13 Jun 2007 21:55:57 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HyYwf-00032o-7g for ged-emacs-devel@m.gmane.org; Wed, 13 Jun 2007 15:55:57 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HyYwb-00031v-FU for emacs-devel@gnu.org; Wed, 13 Jun 2007 15:55:53 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HyYwZ-00031D-SM for emacs-devel@gnu.org; Wed, 13 Jun 2007 15:55:53 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HyYwZ-000319-Ip for emacs-devel@gnu.org; Wed, 13 Jun 2007 15:55:51 -0400 Original-Received: from mercure.iro.umontreal.ca ([132.204.24.67]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HyYwW-0007Vg-Aw; Wed, 13 Jun 2007 15:55:48 -0400 Original-Received: from hidalgo.iro.umontreal.ca (hidalgo.iro.umontreal.ca [132.204.27.50]) by mercure.iro.umontreal.ca (Postfix) with ESMTP id 0C6372CF333; Wed, 13 Jun 2007 15:55:47 -0400 (EDT) Original-Received: from faina.iro.umontreal.ca (faina.iro.umontreal.ca [132.204.26.177]) by hidalgo.iro.umontreal.ca (Postfix) with ESMTP id E0D9F3FE0; Wed, 13 Jun 2007 15:55:40 -0400 (EDT) Original-Received: by faina.iro.umontreal.ca (Postfix, from userid 20848) id CE5FC6C812; Wed, 13 Jun 2007 15:55:40 -0400 (EDT) In-Reply-To: <85tztbvh4d.fsf@lola.goethe.zz> (David Kastrup's message of "Wed\, 13 Jun 2007 20\:33\:54 +0200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux) X-DIRO-MailScanner-Information: Please contact the ISP for more information X-DIRO-MailScanner: Found to be clean X-DIRO-MailScanner-SpamCheck: n'est pas un polluriel, SpamAssassin (score=-2.82, requis 5, autolearn=not spam, ALL_TRUSTED -2.82) X-DIRO-MailScanner-From: monnier@iro.umontreal.ca X-detected-kernel: Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:72806 Archived-At: > The main problem I currently see is that the current semantics and > usage would want to have save-match-data used in places where actually > nobody changes match-data. I'm not sure I understand. AFAIK save-match-data is only needed in 2 circumstances: 1 - when implementing a function that needs to leave the match-data unaffected. This is typically only the case for functions that are placed on hooks. In most cases such save-match-data are necessary because the function you define does touch the match-data (otherwise you wouldn't have used save-match-data) and the function that runs the hook will sooner or later need the match-data to stay unaffected. 2 - around code that needs to be run after string-match but before match-end and of which we do not know that it leaves the match-data unaffected. This may be unnecessary because the code may in fact preserve the match-data even though you don't know it. So although number 1 may be an unnecessary use of save-match-data, I find it's usually useful/necessary. Number 2 OTOH can often turn out to be unnecessary. Luckily number 2 is very rarely needed because in most cases it's easier to restructure your code such that save-match-data is not needed any more. So I don't see current usage as problematic w.r.t efficiency. The only real problem with it is that people tend to not know/understand it and are thus tempted to complain that most functions need to be wrapped in save-match-data, which then leads to long discussions such as this one. Maybe we should make the convention more prominent by adding it to the docstring of save-match-data? Stefan