From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas Schwab Newsgroups: gmane.emacs.devel Subject: Re: replace-regexp-in-string, using the dyn scoped variable STR Date: Thu, 12 Nov 2009 16:58:11 +0100 Message-ID: References: <877htwmirx.fsf@mail.jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1258041836 1725 80.91.229.12 (12 Nov 2009 16:03:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 12 Nov 2009 16:03:56 +0000 (UTC) Cc: Juri Linkov , Lennart Borgman , Emacs-Devel devel To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Nov 12 17:03:28 2009 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 1N8c8u-0005o2-3T for ged-emacs-devel@m.gmane.org; Thu, 12 Nov 2009 17:03:28 +0100 Original-Received: from localhost ([127.0.0.1]:54369 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N8c8t-0002wC-FE for ged-emacs-devel@m.gmane.org; Thu, 12 Nov 2009 11:03:27 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N8c3y-0004db-EU for emacs-devel@gnu.org; Thu, 12 Nov 2009 10:58:22 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N8c3t-0004ZN-SG for emacs-devel@gnu.org; Thu, 12 Nov 2009 10:58:22 -0500 Original-Received: from [199.232.76.173] (port=55718 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N8c3t-0004ZG-H2 for emacs-devel@gnu.org; Thu, 12 Nov 2009 10:58:17 -0500 Original-Received: from mx1.redhat.com ([209.132.183.28]:34293) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N8c3t-0001aj-0h for emacs-devel@gnu.org; Thu, 12 Nov 2009 10:58:17 -0500 Original-Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nACFwDmc000801 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 12 Nov 2009 10:58:14 -0500 Original-Received: from hase.home (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nACFwBGC001024; Thu, 12 Nov 2009 10:58:12 -0500 X-Yow: If I had a Q-TIP, I could prevent th'collapse of NEGOTIATIONS!! In-Reply-To: (Stefan Monnier's message of "Thu, 12 Nov 2009 10:26:35 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. 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:116895 Archived-At: Stefan Monnier writes: >>> (setq org-str (replace-regexp-in-string >>> "&#x\\([a-f0-9]\\{2,4\\}\\);" >>> (lambda (m) >>> (char-to-string >>> ;; Note: str is scoped dynamically from >>> ;; `replace-regexp-in-string'. >>> (+ (string-to-number (match-string 1 str) 16) > >> `str' has the same value as `m'. > > No, it doesn't: str is "the whole string" whereas m is only the > (match-string 0) part of it Which is always a prefix of str, and only different from str if the match was empty. > (which is why it's more convenient to use (match-string 1 str) in > Lennart's example than to try and figure out where submatch 1 is in m, The submatch 1 of m is at (match-beginning 1). Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."