From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Wehmann Newsgroups: gmane.emacs.help Subject: Re: match-string debugging problem Date: Sun, 13 Mar 2005 15:52:24 -0600 Organization: Fermi National Accelerator Laboratory Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1110750864 7933 80.91.229.2 (13 Mar 2005 21:54:24 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 13 Mar 2005 21:54:24 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Mar 13 22:54:24 2005 Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DAb2Q-0007z1-A9 for geh-help-gnu-emacs@m.gmane.org; Sun, 13 Mar 2005 22:54:18 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DAbHy-00053S-9R for geh-help-gnu-emacs@m.gmane.org; Sun, 13 Mar 2005 17:10:22 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!info4.fnal.gov!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 70 Original-NNTP-Posting-Host: fsui03.fnal.gov Original-X-Trace: info4.fnal.gov 1110750423 6316 131.225.68.24 (13 Mar 2005 21:47:03 GMT) Original-X-Complaints-To: abuse@fnnews.fnal.gov Original-NNTP-Posting-Date: 13 Mar 2005 21:47:03 GMT User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through Obscurity, usg-unix-v) Cancel-Lock: sha1:PFQeIfsBGC8QoQMPanslxJPftT8= Original-Xref: shelby.stanford.edu gnu.emacs.help:129246 Original-To: help-gnu-emacs@gnu.org 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 X-MailScanner-To: geh-help-gnu-emacs@m.gmane.org Xref: news.gmane.org gmane.emacs.help:24798 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:24798 Stephen Berman writes: > There seems to be something about match-string that I don't > understand. Here is an example of the kind of code I'm working with: > > (defvar mystring1 "+++++ ") > (defvar mystring2 " ~~~~~") > (defun mystring-list () > (interactive) > (with-current-buffer (get-buffer-create "*test*") > (switch-to-buffer "*test*") > (dotimes (num 5) > (insert mystring1 "test" (int-to-string (1+ num)) mystring2 "\n")) > (goto-char (point-min)) > (let ((mystring-list ())) > (while (re-search-forward > (concat "^" (regexp-quote mystring1) "\\(.+\\)" > (regexp-quote mystring2) "$") > (point-max) t) > (setq mystring-list (append (list (match-string 1)) mystring-list))) > (insert "\n") > (setq mystring-list (reverse mystring-list)) > (dolist (elt mystring-list) > (insert elt " "))))) > > After evalling this code and typing `M-x mystring-list', buffer *test* > consists of these lines: > > +++++ test1 ~~~~~ > +++++ test2 ~~~~~ > +++++ test3 ~~~~~ > +++++ test4 ~~~~~ > +++++ test5 ~~~~~ > test1 test2 test3 test4 test5 > > The last line indicates that match-string correctly matches the > strings that build mystring-list. But when I step through the code > with edebug, match-string always returns nil and a wrong-type-argument > error is raised at the insert (since nil is not char-or-string-p). > (Edebug isn't the problem: evalling first the regexp search code in > *test* and then (match-string 1) also returns nil.) Because of this > I'm having a hard time debugging other code that uses match-string. > Can someone explain what's going on? > > Steve Berman > > > I tried your example, with GNU Emacs 21.2.2 (sparc-sun-solaris2.8, X toolkit) of 2005-02-10 on gax and also with XEmacs 21.4 (patch 15) "Security Through Obscurity" [Lucid] (sparc-sun-solaris2.8, Mule) of Fri Feb 11 2005 on gax When I put a breakpoint in Edebug after (match-string 1) I get the strings I expect to see. Also, a breakpoint after 'elt' in (insert elt " ") behaves as I would expect & not as you describe. -- Alan Wehmann wehmann(removespam)@fnal.gov