From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.help Subject: match-string debugging problem Date: Thu, 10 Mar 2005 16:18:24 +0100 Message-ID: <87u0njjzr3.fsf@nolde.local.home> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1110469795 30572 80.91.229.2 (10 Mar 2005 15:49:55 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 10 Mar 2005 15:49:55 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Mar 10 16:49:55 2005 Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1D9Pom-0002Sl-Tb for geh-help-gnu-emacs@m.gmane.org; Thu, 10 Mar 2005 16:43:21 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1D9Q3f-0007ra-TI for geh-help-gnu-emacs@m.gmane.org; Thu, 10 Mar 2005 10:58:43 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1D9Q1H-0007et-Nw for help-gnu-emacs@gnu.org; Thu, 10 Mar 2005 10:56:16 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1D9Q14-0007as-TB for help-gnu-emacs@gnu.org; Thu, 10 Mar 2005 10:56:03 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1D9Q14-0007Rf-QN for help-gnu-emacs@gnu.org; Thu, 10 Mar 2005 10:56:02 -0500 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.34) id 1D9Pg5-0006oe-0n for help-gnu-emacs@gnu.org; Thu, 10 Mar 2005 10:34:21 -0500 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1D9PYx-00006I-1v for help-gnu-emacs@gnu.org; Thu, 10 Mar 2005 16:26:59 +0100 Original-Received: from pd957ca60.dip0.t-ipconnect.de ([217.87.202.96]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 10 Mar 2005 16:26:59 +0100 Original-Received: from Stephen.Berman by pd957ca60.dip0.t-ipconnect.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 10 Mar 2005 16:26:59 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-To: help-gnu-emacs@gnu.org Original-Lines: 43 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: pd957ca60.dip0.t-ipconnect.de User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) 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:24734 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:24734 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