🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #99389

using set-buffer in a filter.

#99389
From: Richard Stallman
Date: Wed, 19 Sep 1990 00:47
24 lines
1592 bytes
I just added this text to the Lisp manual:

  Many filter functions sometimes or always insert the text in the
process's buffer, mimicking the actions of Emacs when there is no
filter.  Such filter functions need to use @code{set-buffer} in order to
be sure to insert in that buffer.  To avoid setting the current buffer
semipermanently, these filter functions must use @code{unwind-protect}
to make sure to restore the previous current buffer.  They should also
update the process marker, and in some cases update the value of point.
Here is how to do these things:

@example
(let ((moving (= (point) (process-mark proc)))
      (old-buffer (current-buffer)))
  (set-buffer (process-buffer proc))
  (unwind-protect
      (save-excursion
	;; Insert the text, moving the process-marker.
	(goto-char (process-mark proc))
	(insert string)
	(set-marker (process-mark proc) (point)))
    (set-buffer old-buffer))
  (if moving (goto-char (process-mark proc))))
@end example
Technical Details
Message-ID: <9009190047.AA23624@pogo>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!AI.MIT.EDU!rms
References: <9009182329.AA05806@shadow.twinsun.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,a4a0dbdb4374810
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1990-09-18 17:47:32 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!AI.MIT.EDU!rms
From: rms@AI.MIT.EDU (Richard Stallman)
Newsgroups: gnu.emacs.bug
Subject: using set-buffer in a filter.
Message-ID: <9009190047.AA23624@pogo>
Date: 19 Sep 90 00:47:32 GMT
References: <9009182329.AA05806@shadow.twinsun.com>
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 24
Posted: Wed Sep 19 01:47:32 1990