Article View: gnu.emacs.sources
Article #259Re: more functions needed (sorry)
From: Hallvard B Furuseth
Date: Fri, 11 Dec 1992 19:37
Date: Fri, 11 Dec 1992 19:37
24 lines
1627 bytes
1627 bytes
In article <DODD.92Dec11074209@mycenae.cchem.berkeley.edu> dodd@mycenae.cchem.berkeley.edu (Lawrence R. Dodd) writes:
> `looking-back' is not standard but probably can be constructed using
> `looking-at' although it seems interesting that it isn't in the standard
> distribution. Can anyone out there explain this?
Probably because our heroes do not want to encourage backwards regexp
processing. Emacs' regexp implementation works better forwards. For
example, notice that (re-search-backward "x+") only finds the last x in
`xxx'. Also, I suspect backwards is slower.
Anyway, here is a quick and dirty version:
(defun looking-back (regexp &optional span)
"t if text before point matches regular expression PAT.
For simplicity, only the preceding SPAN chars (default 2000) are searched."
(save-excursion
(eq (point)
(and (re-search-backward regexp (- (point) (or span 2000)) t)
(match-end 0)))))
--
Hallvard
Technical Details
Message-ID:
<HBF.92Dec11203729@durin.uio.no>Path:
arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!agate!spool.mu.edu!sdd.hp.com!think.com!enterpoop.mit.edu!eru.mt.luth.se!lunic!sunic!aun.uninett.no!nuug!ifi.uio.no!nntp.uio.no!hbfReferences:
<SNOW.92Dec11075738@castor.hahnemann.edu> <DODD.92Dec11074209@mycenae.cchem.berkeley.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!agate!spool.mu.edu!sdd.hp.com!think.com!enterpoop.mit.edu!eru.mt.luth.se!lunic!sunic!aun.uninett.no!nuug!ifi.uio.no!nntp.uio.no!hbf From: hbf@durin.uio.no (Hallvard B Furuseth) Newsgroups: gnu.emacs.sources Subject: Re: more functions needed (sorry) Message-ID: <HBF.92Dec11203729@durin.uio.no> Date: 11 Dec 92 19:37:29 GMT References: <SNOW.92Dec11075738@castor.hahnemann.edu> <DODD.92Dec11074209@mycenae.cchem.berkeley.edu> Sender: news@ulrik.uio.no (Mr News) Organization: University of Oslo, Norway Lines: 24 In-Reply-To: dodd@mycenae.cchem.berkeley.edu's message of 11 Dec 92 07:42:09 Nntp-Posting-Host: durin.uio.no