From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: PJ Weisberg Newsgroups: gmane.emacs.help Subject: Re: use of "match-string" Date: Tue, 8 Mar 2011 11:06:45 -0800 Message-ID: References: <4D7667E5.4070501@mousecar.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1299611254 20858 80.91.229.12 (8 Mar 2011 19:07:34 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 8 Mar 2011 19:07:34 +0000 (UTC) To: GNU Emacs List Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Mar 08 20:07:29 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Px2Fh-0003Vb-SE for geh-help-gnu-emacs@m.gmane.org; Tue, 08 Mar 2011 20:07:26 +0100 Original-Received: from localhost ([127.0.0.1]:41266 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Px2Fh-00025R-Be for geh-help-gnu-emacs@m.gmane.org; Tue, 08 Mar 2011 14:07:25 -0500 Original-Received: from [140.186.70.92] (port=52771 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Px2F9-00025M-CQ for help-gnu-emacs@gnu.org; Tue, 08 Mar 2011 14:06:52 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Px2F8-00005E-1M for help-gnu-emacs@gnu.org; Tue, 08 Mar 2011 14:06:51 -0500 Original-Received: from p3plsmtpa01-05.prod.phx3.secureserver.net ([72.167.82.85]:48216) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1Px2F7-00004s-Oo for help-gnu-emacs@gnu.org; Tue, 08 Mar 2011 14:06:50 -0500 Original-Received: (qmail 3488 invoked from network); 8 Mar 2011 19:06:48 -0000 Original-Received: from unknown (209.85.161.41) by p3plsmtpa01-05.prod.phx3.secureserver.net (72.167.82.85) with ESMTP; 08 Mar 2011 19:06:47 -0000 Original-Received: by fxm5 with SMTP id 5so6402265fxm.0 for ; Tue, 08 Mar 2011 11:06:45 -0800 (PST) Original-Received: by 10.223.96.137 with SMTP id h9mr2180357fan.141.1299611205713; Tue, 08 Mar 2011 11:06:45 -0800 (PST) Original-Received: by 10.223.81.66 with HTTP; Tue, 8 Mar 2011 11:06:45 -0800 (PST) In-Reply-To: <4D7667E5.4070501@mousecar.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 72.167.82.85 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:79890 Archived-At: On Tue, Mar 8, 2011 at 9:31 AM, ken wrote: > > Part of this function doesn't make sense-- > > (defun html-toc-find-max () > =A0(goto-char (point-min)) > =A0(let ((max-toc 0)) > =A0 =A0(while (search-forward-regexp html-toc-tocref nil t) > =A0 =A0 =A0(if (> (string-to-int (match-string 1)) max-toc) > =A0 =A0 =A0 =A0 =A0(setq max-toc (string-to-int (match-string 1))))) > =A0 =A0(1+ max-toc))) > > -- specifically, where match-string is first called and turned into a > number. =A0The docs say that match-string returns a string.... =A0Yes, th= is > can be done I suppose, but to what end? =A0Moreover, depending upon its > value, this "number" may then be assigned to a variable, and that value > then compared with subsequent strings. > > Perhaps I'm missing some nuance here. =A0The entirety of the code is > below. =A0Does anyone understand what's going on here? Maybe it would help if you looked at the value of the regexp that's being matched. The function html-toc-find-max does (almost) exactly what it says it does: it finds the highest numbered section in the table of contents, then returns that number plus one. It's converting the strings to numbers because if it just compared the strings alphabetically "25" would come before "3", etc. -PJ