From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ken Newsgroups: gmane.emacs.help Subject: Re: string searching and saving results to a variable Date: Wed, 16 Feb 2011 01:55:56 -0500 Message-ID: <4D5B74FC.80204@mousecar.com> References: <4D5B0901.5080100@mousecar.com> Reply-To: gebser@mousecar.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1297839398 31848 80.91.229.12 (16 Feb 2011 06:56:38 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 16 Feb 2011 06:56:38 +0000 (UTC) To: GNU Emacs List Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Feb 16 07:56:34 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 1PpbJQ-0006Wn-9m for geh-help-gnu-emacs@m.gmane.org; Wed, 16 Feb 2011 07:56:32 +0100 Original-Received: from localhost ([127.0.0.1]:55801 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PpbJP-0001jn-DO for geh-help-gnu-emacs@m.gmane.org; Wed, 16 Feb 2011 01:56:31 -0500 Original-Received: from [140.186.70.92] (port=53047 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PpbIz-0001je-4X for help-gnu-emacs@gnu.org; Wed, 16 Feb 2011 01:56:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PpbIy-0004pa-0O for help-gnu-emacs@gnu.org; Wed, 16 Feb 2011 01:56:04 -0500 Original-Received: from mout.perfora.net ([74.208.4.195]:54617) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PpbIx-0004pS-Ph for help-gnu-emacs@gnu.org; Wed, 16 Feb 2011 01:56:03 -0500 Original-Received: from dellap.mousecar.net (dsl093-011-016.cle1.dsl.speakeasy.net [66.93.11.16]) by mrelay.perfora.net (node=mrus2) with ESMTP (Nemesis) id 0MHonN-1PoEOB2SVh-004GTV; Wed, 16 Feb 2011 01:56:00 -0500 User-Agent: Thunderbird 2.0.0.24 (X11/20101213) In-Reply-To: X-Enigmail-Version: 0.96.0 OpenPGP: id=5AD091E7 X-Provags-ID: V02:K0:1cidk++iKDpT81C1Dn6J0ZPI2jTKo4zpbUO4u/ZpGSF EPHOTu+GBmWA3R3AXBcvoLA21N5gZqHIIlOQD2TzNz3wfTVGzI CZkyp4jXqqW9+1I0TwDKNsVHscH4CUqGJjUfBPGE8nhkvVU1xg 734/t5ocRV26mDD3VJ2rNIjyvJqQBiAKqkoFsUw7ste2SARUCM tIZKTbYXj5h+qSIb1Q1e6QCuQ97jfFhLLr35xAeyI4= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 74.208.4.195 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:79135 Archived-At: On 02/15/2011 06:33 PM Perry Smith wrote: > 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 > Thanks!! I'm guessing it could then be done more elispishly as (setq dog (buffer-substring (re-search-backward "\\|\\|\\|\\|" nil t)))