Article View: comp.emacs
Article #8249filter processes (was Re: Asynchronous processes in GNU Emacs)
From: Randal L. Schwartz Stonehenge
Date: Fri, 06 Jan 1989 20:06
Date: Fri, 06 Jan 1989 20:06
39 lines
2099 bytes
2099 bytes
In article <2254@imagine.PAWL.RPI.EDU>, Dave Lawrence writes:
| What follows is the filter. I'm sorry if it's not good form or
| something, but (e)lisp is still new to me; in fact, I'd appreciate any
| (constructive) criticism that anyone would want to give.
| [lotsa code deleted]
Your 'connect-filter' calls 'set-buffer' OUTSIDE a 'save-excursion'.
This is a no-no.
Think of your connect-filter as an interrupt procedure in assembly
language, if you've had that background. You must save and restore
the entire environment during the execution of the connect-filter.
Typically, I wrap my entire filter inside a 'save-excursion' and then
a 'let' and then if I do any regexps, a 'unwind-protect' to restore
the 'match-data'.
#ifdef FLAME_SIDE_COMMENT
Why oh why is 'match-data' not a global variable? Then I could go:
(let (match-data) (re-search-forward "\\(foo\\|bar\\)*") ...)
and save the old match-data... instead I have to:
(let ((md (match-data)))
(unwind-protect
(progn (re-search-forward...))
(set-match-data md)))
UGLY UGLY UGLY KLUDGE
#endif FLAME_SIDE_COMMENT
Hope this helps. (it helped me :-)
--
Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095
on contract to BiiN Technical Information Services (for now :-),
in a former Intel building in Hillsboro, Oregon, USA.
<merlyn@intelob.biin.com> or ...!tektronix!inteloa[!intelob]!merlyn
SOME MAILERS REQUIRE <merlyn@intelob.intel.com> GRRRRR!
Standard disclaimer: I *am* my employer!
Technical Details
Message-ID:
<4031@omepd.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!attcan!uunet!lll-winken!ames!mailrus!cornell!uw-beaver!blake!ogccse!littlei!omepd!merlynReferences:
<2254@imagine.PAWL.RPI.EDU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!attcan!uunet!lll-winken!ames!mailrus!cornell!uw-beaver!blake!ogccse!littlei!omepd!merlyn From: merlyn@intelob.biin.com (Randal L. Schwartz @ Stonehenge) Newsgroups: comp.emacs Subject: filter processes (was Re: Asynchronous processes in GNU Emacs) Message-ID: <4031@omepd.UUCP> Date: 6 Jan 89 20:06:25 GMT References: <2254@imagine.PAWL.RPI.EDU> Sender: news@omepd.UUCP Reply-To: merlyn@intelob.biin.com (Randal L. Schwartz @ Stonehenge) Organization: Stonehenge; netaccess via BiiN, Hillsboro, Oregon, USA Lines: 39 In-reply-to: Dave Lawrence