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: replace-regexp-in-string, using the dyn scoped variable STR Date: Thu, 12 Nov 2009 10:26:35 -0500 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 1258040621 29599 80.91.229.12 (12 Nov 2009 15:43:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 12 Nov 2009 15:43:41 +0000 (UTC) Cc: Lennart Borgman , Emacs-Devel devel To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Nov 12 16:43:35 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 1N8bpe-0003tW-AK for ged-emacs-devel@m.gmane.org; Thu, 12 Nov 2009 16:43:34 +0100 Original-Received: from localhost ([127.0.0.1]:57341 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N8bpd-0003Os-SJ for ged-emacs-devel@m.gmane.org; Thu, 12 Nov 2009 10:43:33 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N8bZK-0005Nr-3s for emacs-devel@gnu.org; Thu, 12 Nov 2009 10:26:42 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N8bZF-0005H0-B6 for emacs-devel@gnu.org; Thu, 12 Nov 2009 10:26:41 -0500 Original-Received: from [199.232.76.173] (port=41374 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N8bZE-0005GR-MB for emacs-devel@gnu.org; Thu, 12 Nov 2009 10:26:36 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.183]:54306 helo=ironport2-out.pppoe.ca) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N8bZE-0003xP-Ba for emacs-devel@gnu.org; Thu, 12 Nov 2009 10:26:36 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvIEABK4+0pMCpsp/2dsb2JhbACBTttuhDwEiSg X-IronPort-AV: E=Sophos;i="4.44,728,1249272000"; d="scan'208";a="49221489" Original-Received: from 76-10-155-41.dsl.teksavvy.com (HELO ceviche.home) ([76.10.155.41]) by ironport2-out.pppoe.ca with ESMTP; 12 Nov 2009 10:26:35 -0500 Original-Received: by ceviche.home (Postfix, from userid 20848) id A779370072; Thu, 12 Nov 2009 10:26:35 -0500 (EST) In-Reply-To: <877htwmirx.fsf@mail.jurta.org> (Juri Linkov's message of "Thu, 12 Nov 2009 11:59:06 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) 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:116890 Archived-At: >> (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 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, which basically requires either doing another string-match or using ad-hoc methods (e.g. (substring m 3 -1))). Stefan