[comp.emacs] filter processes

merlyn@intelob.biin.com (Randal L. Schwartz @ Stonehenge) (01/07/89)

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!