From unknown Fri Jun 20 19:59:42 2025 X-Loop: owner@emacsbugs.donarmstrong.com Subject: bug#3098: 23.0.92; improving documentation of process filter functions Reply-To: Markus Triska , 3098@debbugs.gnu.org Resent-From: Markus Triska Resent-To: bug-submit-list@lists.donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Fri, 24 Apr 2009 17:10:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-Emacs-PR-Message: report 3098 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Received: via spool by submit@emacsbugs.donarmstrong.com id=B.124059270522813 (code B ref -1); Fri, 24 Apr 2009 17:10:04 +0000 Received: (at submit) by emacsbugs.donarmstrong.com; 24 Apr 2009 17:05:05 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: * X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=1.1 required=4.0 tests=FOURLA,IMPRONONCABLE_2 autolearn=no version=3.2.5-bugs.debian.org_2005_01_02 Received: from fencepost.gnu.org (fencepost.gnu.org [140.186.70.10]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n3OH4w3W022332 for ; Fri, 24 Apr 2009 10:05:00 -0700 Received: from mail.gnu.org ([199.232.76.166]:37056 helo=mx10.gnu.org) by fencepost.gnu.org with esmtp (Exim 4.67) (envelope-from ) id 1LxOpe-0003r9-9s for emacs-pretest-bug@gnu.org; Fri, 24 Apr 2009 13:04:58 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1LxOpT-00081G-Ef for emacs-pretest-bug@gnu.org; Fri, 24 Apr 2009 13:04:57 -0400 Received: from mail.gmx.net ([213.165.64.20]:52432) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1LxOpS-0007zy-5X for emacs-pretest-bug@gnu.org; Fri, 24 Apr 2009 13:04:46 -0400 Received: (qmail invoked by alias); 24 Apr 2009 17:04:43 -0000 Received: from chello062178240212.3.14.tuwien.teleweb.at (EHLO mt-imac.local) [62.178.240.212] by mail.gmx.net (mp025) with SMTP; 24 Apr 2009 19:04:43 +0200 X-Authenticated: #4064391 X-Provags-ID: V01U2FsdGVkX18uhglcRj8u3th5JqN8EwmGjZwpv+sqnLmdqF2B4Q fX2qah/RaBsKFc Received: by mt-imac.local (Postfix, from userid 501) id B016B2C1EF6; Fri, 24 Apr 2009 19:04:42 +0200 (CEST) From: Markus Triska To: emacs-pretest-bug@gnu.org Date: Fri, 24 Apr 2009 19:04:42 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Y-GMX-Trusted: 0 X-FuHaFi: 0.47 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. The documentation of process filter functions states: The expression `(buffer-name (process-buffer PROCESS))' returns `nil' if the buffer is dead. Instead of `buffer-name', it seems better to use `buffer-live-p' here: For one thing, it will also work when process-buffer is `nil', whereas `buffer-name' would then evaluate to the name of the current buffer. And, although the documentation also says: A filter function that writes the output into the buffer of the process should check whether the buffer is still alive. the `ordinary-insertion-filter' example does not heed this advice. Suggestion: 2009-04-24 Markus Triska * processes.texi (Filter Functions): Use `buffer-live-p' instead of `buffer-name' in the main text as well as in the example. diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi index 64d2d7d..6f54eb6 100644 --- a/doc/lispref/processes.texi +++ b/doc/lispref/processes.texi @@ -1249,25 +1249,28 @@ filter function. @xref{Debugger}. 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 save and restore the -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: +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 save and restore +the current buffer. Such filter functions should also check whether +the buffer is still alive, since inserting into a dead buffer will +raise an error. They should also update the process marker, and in +some cases update the value of point. Here is how to do these things: @smallexample @group (defun ordinary-insertion-filter (proc string) - (with-current-buffer (process-buffer proc) - (let ((moving (= (point) (process-mark proc)))) + (when (buffer-live-p (process-buffer proc)) + (with-current-buffer (process-buffer proc) + (let ((moving (= (point) (process-mark proc)))) @end group @group - (save-excursion - ;; @r{Insert the text, advancing the process marker.} - (goto-char (process-mark proc)) - (insert string) - (set-marker (process-mark proc) (point))) - (if moving (goto-char (process-mark proc)))))) + (save-excursion + ;; @r{Insert the text, advancing the process marker.} + (goto-char (process-mark proc)) + (insert string) + (set-marker (process-mark proc) (point))) + (if moving (goto-char (process-mark proc))))))) @end group @end smallexample @@ -1294,12 +1297,6 @@ expression searching or matching had to explicitly save and restore the match data. Now Emacs does this automatically for filter functions; they never need to do it explicitly. @xref{Match Data}. - A filter function that writes the output into the buffer of the -process should check whether the buffer is still alive. If it tries to -insert into a dead buffer, it will get an error. The expression -@code{(buffer-name (process-buffer @var{process}))} returns @code{nil} -if the buffer is dead. - The output to the function may come in chunks of any size. A program that produces the same output twice in a row may send it as one batch of 200 characters one time, and five batches of 40 characters the next. If In GNU Emacs 23.0.92.2 (i386-apple-darwin9.6.1, GTK+ Version 2.14.7) of 2009-04-05 on mt-imac.local Windowing system distributor `The X.Org Foundation', version 11.0.10402000 configured using `configure '--with-tiff=no'' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: nil value of $LC_CTYPE: nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: en.UTF-8 value of $XMODIFIERS: nil locale-coding-system: utf-8-unix default-enable-multibyte-characters: t From rgm@gnu.org Sat May 2 16:52:24 2009 Received: (at control) by emacsbugs.donarmstrong.com; 2 May 2009 23:52:25 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.5-bugs.debian.org_2005_01_02 (2008-06-10) on rzlab.ucr.edu X-Spam-Level: X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. X-Spam-Status: No, score=-2.0 required=4.0 tests=VALID_BTS_CONTROL autolearn=ham version=3.2.5-bugs.debian.org_2005_01_02 Received: from fencepost.gnu.org (fencepost.gnu.org [140.186.70.10]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n42NqLhm021945 for ; Sat, 2 May 2009 16:52:23 -0700 Received: from rgm by fencepost.gnu.org with local (Exim 4.67) (envelope-from ) id 1M0P0H-0000i9-Cz; Sat, 02 May 2009 19:52:21 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <18940.56501.313879.359335@fencepost.gnu.org> Date: Sat, 2 May 2009 19:52:21 -0400 From: Glenn Morris To: control Subject: control message reassign 3071 emacs,ns reassign 3082 emacs,ns reassign 3122 emacs,w32 reassign 3185 emacs,ns severity 3175 wishlist reassign 3174 emacs,ns reassign 3149 emacs,ns reassign 3146 emacs,ns unarchive 2689 reopen 2689 severity 3098 minor From debbugs-submit-bounces@debbugs.gnu.org Tue Jan 19 20:40:54 2010 Received: (at control) by debbugs.gnu.org; 20 Jan 2010 01:40:54 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NXPYz-0007Wd-5s for submit@debbugs.gnu.org; Tue, 19 Jan 2010 20:40:53 -0500 Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NXPYl-0007WW-Uj for control@debbugs.gnu.org; Tue, 19 Jan 2010 20:40:52 -0500 Received: from rgm by fencepost.gnu.org with local (Exim 4.69) (envelope-from ) id 1NXPYi-0007Sl-Bs; Tue, 19 Jan 2010 20:40:36 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <19286.24340.350706.582414@gargle.gargle.HOWL> Date: Tue, 19 Jan 2010 20:40:36 -0500 From: Glenn Morris To: control Subject: control X-Attribution: GM X-Mailer: VM (www.wonderworks.com/vm), GNU Emacs (www.gnu.org/software/emacs) X-Hue: cyan X-Ran: 8WU:4P)DBN*0i&7=5k?sw9O_ List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.0 (-----) close 2951 tags 4206 moreinfo tags 3098 patch tags 2499 patch tags 5297 patch tags 5290 patch tags 1975 patch tags 4470 patch tags 5055 patch tags 3541 patch tags 2527 patch tags 5119 patch tags 2404 patch From unknown Fri Jun 20 19:59:42 2025 X-Loop: help-debbugs@gnu.org Subject: bug#3098: 23.0.92; improving documentation of process filter functions References: In-Reply-To: Resent-From: Chong Yidong Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 24 Aug 2010 20:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 3098 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Markus Triska Cc: 3098@debbugs.gnu.org Received: via spool by 3098-submit@debbugs.gnu.org id=B3098.128268256829840 (code B ref 3098); Tue, 24 Aug 2010 20:43:02 +0000 Received: (at 3098) by debbugs.gnu.org; 24 Aug 2010 20:42:48 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oo0KW-0007lF-D4 for submit@debbugs.gnu.org; Tue, 24 Aug 2010 16:42:48 -0400 Received: from pantheon-po45.its.yale.edu ([130.132.50.79]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oo0KU-0007lA-Jw for 3098@debbugs.gnu.org; Tue, 24 Aug 2010 16:42:47 -0400 Received: from furry (dhcp128036014154.central.yale.edu [128.36.14.154]) (authenticated bits=0) by pantheon-po45.its.yale.edu (8.12.11.20060308/8.12.11) with ESMTP id o7OKi7U3001967 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 24 Aug 2010 16:44:07 -0400 Received: by furry (Postfix, from userid 1000) id 4E2E9C013; Tue, 24 Aug 2010 16:44:07 -0400 (EDT) From: Chong Yidong Date: Tue, 24 Aug 2010 16:44:07 -0400 Message-ID: <87tymjwxk8.fsf@stupidchicken.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-YaleITSMailFilter: Version 1.2c (attachment(s) not renamed) X-Spam-Score: -2.7 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.7 (--) > 2009-04-24 Markus Triska gmx.at> > > * processes.texi (Filter Functions): Use `buffer-live-p' instead > of `buffer-name' in the main text as well as in the example. Thanks, committed. From debbugs-submit-bounces@debbugs.gnu.org Tue Aug 24 16:42:58 2010 Received: (at control) by debbugs.gnu.org; 24 Aug 2010 20:42:58 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oo0Kf-0007lS-KH for submit@debbugs.gnu.org; Tue, 24 Aug 2010 16:42:57 -0400 Received: from pantheon-po15.its.yale.edu ([130.132.50.71]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oo0Ke-0007lL-Mw for control@debbugs.gnu.org; Tue, 24 Aug 2010 16:42:56 -0400 Received: from furry (dhcp128036014154.central.yale.edu [128.36.14.154]) (authenticated bits=0) by pantheon-po15.its.yale.edu (8.12.11.20060308/8.12.11) with ESMTP id o7OKiHwi016073 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Tue, 24 Aug 2010 16:44:17 -0400 Received: by furry (Postfix, from userid 1000) id ABEE0C013; Tue, 24 Aug 2010 16:44:17 -0400 (EDT) From: Chong Yidong To: control@debbugs.gnu.org Subject: close 3098 Date: Tue, 24 Aug 2010 16:44:17 -0400 Message-ID: <87r5hnwxjy.fsf@stupidchicken.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-YaleITSMailFilter: Version 1.2c (attachment(s) not renamed) X-Spam-Score: -2.7 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.7 (--) close 3098 thanks