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 11:58:53 -0500 Message-ID: <4D5C024D.1050406@mousecar.com> References: <4D5B0901.5080100@mousecar.com> <4D5B74FC.80204@mousecar.com> Reply-To: gebser@mousecar.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1297875826 6629 80.91.229.12 (16 Feb 2011 17:03:46 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 16 Feb 2011 17:03:46 +0000 (UTC) Cc: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Feb 16 18:03:41 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 1Ppkmy-0008NT-DG for geh-help-gnu-emacs@m.gmane.org; Wed, 16 Feb 2011 18:03:40 +0100 Original-Received: from localhost ([127.0.0.1]:54964 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ppkmw-0002XC-Vl for geh-help-gnu-emacs@m.gmane.org; Wed, 16 Feb 2011 12:03:39 -0500 Original-Received: from [140.186.70.92] (port=37809 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PpkiU-0001Qb-A4 for help-gnu-emacs@gnu.org; Wed, 16 Feb 2011 11:59:03 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PpkiS-0005nc-7o for help-gnu-emacs@gnu.org; Wed, 16 Feb 2011 11:59:01 -0500 Original-Received: from mout.perfora.net ([74.208.4.195]:58786) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PpkiS-0005nU-0k for help-gnu-emacs@gnu.org; Wed, 16 Feb 2011 11:59:00 -0500 Original-Received: from dellap.mousecar.net (dsl093-011-016.cle1.dsl.speakeasy.net [66.93.11.16]) by mrelay.perfora.net (node=mrus3) with ESMTP (Nemesis) id 0M7XuJ-1Q2u5I12Bj-00wsJc; Wed, 16 Feb 2011 11:58:58 -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:QRhGCYLUDS8hB9TwrQnLUufeNC0olLi0nykV9IFat9f duRIBKQbC2Jl7YrZwETof/vskS3D4V7dREsfmhTcERb6+UoMKY 391ETktxNmt5dcUcA7XaqPhvoa5M8Xyivd42junfq1GmPR4SM2 VNjU7CUJh6LH69W7Dn4MVelUs4CcHTJX++a9fopzBYi1lx/9jS QPtClKCFQ/jY6NA6zbbBZpQTxoeE/npScWHkle31J0= 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:79153 Archived-At: On 02/16/2011 04:21 AM Oleksandr Gavenko wrote: > On 16.02.2011 8:55, ken wrote: >> I'm guessing it could then be done more elispishly as >> >> (setq dog (buffer-substring >> (re-search-backward "> (re-search-forward "\\|\\|\\|\\|" nil t))) >> > How about if search fail? > > Evaluating of > > (buffer-substring nil nil) > > take (wrong-type-argument integer-or-marker-p nil). Error-checking is an excellent idea, I agree. But I don't understand the elisp code you wrote. Could you explain it for me please. Thanks.