From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Perry Smith Newsgroups: gmane.emacs.help Subject: Re: string searching and saving results to a variable Date: Tue, 15 Feb 2011 17:33:39 -0600 Message-ID: References: <4D5B0901.5080100@mousecar.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v1082) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1297812849 21756 80.91.229.12 (15 Feb 2011 23:34:09 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 15 Feb 2011 23:34:09 +0000 (UTC) Cc: GNU Emacs List To: gebser@mousecar.com Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Feb 16 00:34:05 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 1PpUPD-0005lp-HD for geh-help-gnu-emacs@m.gmane.org; Wed, 16 Feb 2011 00:34:03 +0100 Original-Received: from localhost ([127.0.0.1]:37160 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PpUPD-0002Yc-2h for geh-help-gnu-emacs@m.gmane.org; Tue, 15 Feb 2011 18:34:03 -0500 Original-Received: from [140.186.70.92] (port=60420 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PpUOt-0002YN-PW for help-gnu-emacs@gnu.org; Tue, 15 Feb 2011 18:33:44 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PpUOs-0003zt-Q2 for help-gnu-emacs@gnu.org; Tue, 15 Feb 2011 18:33:43 -0500 Original-Received: from mail-qw0-f41.google.com ([209.85.216.41]:35474) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PpUOs-0003zp-NP for help-gnu-emacs@gnu.org; Tue, 15 Feb 2011 18:33:42 -0500 Original-Received: by qwa26 with SMTP id 26so594510qwa.0 for ; Tue, 15 Feb 2011 15:33:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:subject:mime-version:content-type:from :in-reply-to:date:cc:content-transfer-encoding:message-id:references :to:x-mailer; bh=lRBlgqDq8UG4904/ujovN7eSSqZ0LtiozncOBHWbOQo=; b=A7UlIgWeSFnJm55Yw3sGRfchcFgmi7WekKZp/zJUoBIOrmXkJEE9KQBcgcjuOz4jxe gVQ6wuUivMEqAmayDO6iyhehfMuljnGG1m24zyqTm8SwDpE877ja3BYjxv9gFJMaTCaZ pZCaUJucfOfXiKiPi8sTEZ1mM8VYtAv/Bdij4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; b=VSC54Jsui8b/b4EofHJVmjB2MG6bWVg9SQQUS9EQbGVMqJiW4hDs631qylrNeJUBYi mv8vGbX0C5IqEU//vHiVGyWV5U4QW20emZrfduW6Mr7s/kk9gTtyd18CBE4LHg5eLS0E KteT6GRG9Z0hItOu2DmpkrHFsSrEwwu61XGa8= Original-Received: by 10.229.88.82 with SMTP id z18mr4545889qcl.221.1297812821984; Tue, 15 Feb 2011 15:33:41 -0800 (PST) Original-Received: from newtoy.austin.ibm.com ([32.97.110.54]) by mx.google.com with ESMTPS id s10sm3059393qco.47.2011.02.15.15.33.40 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 15 Feb 2011 15:33:41 -0800 (PST) In-Reply-To: <4D5B0901.5080100@mousecar.com> X-Mailer: Apple Mail (2.1082) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.216.41 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:79129 Archived-At: On Feb 15, 2011, at 5:15 PM, ken wrote: > It's time again to write an elisp function!! > > One thing it needs to do a couple of times is save a string to a > variable. The string to save will be an html header, like: > >

Section 4

> > but it could be multiple lines like this > >

On > the origins of elisp confusion

> > It could even be three or four lines long. Also, the line(s) could be > indented and so have unwanted white space in the first several columns. > > Assuming the point is somewhere on that line or one of those lines, we do: To be clean, first declare some variables (defvar ....) > (end-of-line) ; to preclude the point being at the far left. > ; find the start of the string: > (re-search-backward " ;;somehow mark this as the beginning of the string??? save the current point with: (setq beg (point)) > > ;find the endpoint of the string: > (re-search-forward "\\|\\|\\|\\|" nil t) > > ;;save string to a variable to do other things with... how??? (setq dog (buffer-substring beg (point))) dog now has the string