GNU bug report logs - #79596
[PATCH] Allow creating a pipe process without a buffer

Previous Next

Package: emacs;

Reported by: Spencer Baugh <sbaugh <at> janestreet.com>

Date: Tue, 7 Oct 2025 18:43:02 UTC

Severity: normal

Tags: patch

Done: Eli Zaretskii <eliz <at> gnu.org>

To reply to this bug, email your comments to 79596 AT debbugs.gnu.org.
There is no need to reopen the bug first.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#79596; Package emacs. (Tue, 07 Oct 2025 18:43:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Spencer Baugh <sbaugh <at> janestreet.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 07 Oct 2025 18:43:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Spencer Baugh <sbaugh <at> janestreet.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Allow creating a pipe process without a buffer
Date: Tue, 07 Oct 2025 14:42:21 -0400
[Message part 1 (text/plain, inline)]
Tags: patch


Previously, even passing :buffer nil to make-pipe-process would
create a buffer.  Now, if you explicitly call (make-pipe-process
:buffer nil), it will create a pipe process without a buffer,
just like all the other process creation functions.

* src/process.c (Fmake_pipe_process): Check for explicit :buffer
nil and don't make a buffer.

In GNU Emacs 30.1.90 (build 57, x86_64-pc-linux-gnu, X toolkit, cairo
 version 1.15.12, Xaw scroll bars) of 2025-09-23 built on
 igm-qws-u22796a
Repository revision: 61402089ce10ee7d50e8923083de56571968a239
Repository branch: emacs-30
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Rocky Linux 8.10 (Green Obsidian)

Configured using:
 'configure --with-x-toolkit=lucid --without-gpm --without-gconf
 --without-selinux --without-imagemagick --with-modules --with-gif=no
 --with-cairo --with-rsvg --without-compress-install --with-tree-sitter
 --with-native-compilation=aot
 PKG_CONFIG_PATH=/usr/local/home/garnish/libtree-sitter/0.22.6-1/lib/pkgconfig/'

[0001-Allow-creating-a-pipe-process-without-a-buffer.patch (text/patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79596; Package emacs. (Wed, 08 Oct 2025 05:32:01 GMT) Full text and rfc822 format available.

Message #8 received at 79596 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Spencer Baugh <sbaugh <at> janestreet.com>
Cc: 79596 <at> debbugs.gnu.org
Subject: Re: bug#79596: [PATCH] Allow creating a pipe process without a buffer
Date: Wed, 08 Oct 2025 08:31:31 +0300
> Date: Tue, 07 Oct 2025 14:42:21 -0400
> From:  Spencer Baugh via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> Previously, even passing :buffer nil to make-pipe-process would
> create a buffer.  Now, if you explicitly call (make-pipe-process
> :buffer nil), it will create a pipe process without a buffer,
> just like all the other process creation functions.

Thanks, but this needs the corresponding changes to documentation
before we can install this.

Bonus points for adding tests for this feature.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79596; Package emacs. (Wed, 08 Oct 2025 09:49:03 GMT) Full text and rfc822 format available.

Message #11 received at 79596 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: Spencer Baugh <sbaugh <at> janestreet.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 79596 <at> debbugs.gnu.org
Subject: Re: bug#79596: [PATCH] Allow creating a pipe process without a buffer
Date: Wed, 08 Oct 2025 11:48:20 +0200
>>>>> On Wed, 08 Oct 2025 08:31:31 +0300, Eli Zaretskii <eliz <at> gnu.org> said:

    >> Date: Tue, 07 Oct 2025 14:42:21 -0400
    >> From:  Spencer Baugh via "Bug reports for GNU Emacs,
    >> the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
    >> 
    >> Previously, even passing :buffer nil to make-pipe-process would
    >> create a buffer.  Now, if you explicitly call (make-pipe-process
    >> :buffer nil), it will create a pipe process without a buffer,
    >> just like all the other process creation functions.

    Eli> Thanks, but this needs the corresponding changes to documentation
    Eli> before we can install this.

    Eli> Bonus points for adding tests for this feature.

C99 nitpick: you donʼt need a new scope to declare variables.

Code nitpick: Iʼd probably write it like this:

  Lisp_Object buffer_member = plist_member (contact, QCBuffer);
  if (!NILP (buffer_member))
    buffer = XCDR (buffer_member);
  else
    buffer = name;
  if (!NILP (buffer))
    buffer = Fget_buffer_create (buffer, Qnil);

Robert
-- 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#79596; Package emacs. (Wed, 08 Oct 2025 17:03:02 GMT) Full text and rfc822 format available.

Message #14 received at 79596 <at> debbugs.gnu.org (full text, mbox):

From: Spencer Baugh <sbaugh <at> janestreet.com>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 79596 <at> debbugs.gnu.org
Subject: Re: bug#79596: [PATCH] Allow creating a pipe process without a buffer
Date: Wed, 08 Oct 2025 13:01:47 -0400
[Message part 1 (text/plain, inline)]
Thanks for the fast review.

Robert Pluim <rpluim <at> gmail.com> writes:
>>>>>> On Wed, 08 Oct 2025 08:31:31 +0300, Eli Zaretskii <eliz <at> gnu.org> said:
>
>     >> Date: Tue, 07 Oct 2025 14:42:21 -0400
>     >> From:  Spencer Baugh via "Bug reports for GNU Emacs,
>     >> the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>     >> 
>     >> Previously, even passing :buffer nil to make-pipe-process would
>     >> create a buffer.  Now, if you explicitly call (make-pipe-process
>     >> :buffer nil), it will create a pipe process without a buffer,
>     >> just like all the other process creation functions.
>
>     Eli> Thanks, but this needs the corresponding changes to documentation
>     Eli> before we can install this.

Added.

>     Eli> Bonus points for adding tests for this feature.

Added.

> C99 nitpick: you donʼt need a new scope to declare variables.

That is true, but I wanted to constrain the scope of "buffer_member",
since it isn't used again after this bit of code, but "buffer" is used
again.

> Code nitpick: Iʼd probably write it like this:
>
>   Lisp_Object buffer_member = plist_member (contact, QCBuffer);
>   if (!NILP (buffer_member))
>     buffer = XCDR (buffer_member);
>   else
>     buffer = name;
>   if (!NILP (buffer))
>     buffer = Fget_buffer_create (buffer, Qnil);

Ah, much nicer, changed to (approximately) this.

[0001-Allow-creating-a-pipe-process-without-a-buffer.patch (text/x-patch, inline)]
From 218a75f29972a53c0c1a9ddb990df98512918d59 Mon Sep 17 00:00:00 2001
From: Spencer Baugh <sbaugh <at> janestreet.com>
Date: Tue, 7 Oct 2025 14:41:20 -0400
Subject: [PATCH] Allow creating a pipe process without a buffer

Previously, even passing :buffer nil to make-pipe-process would
create a buffer.  Now, if you explicitly call (make-pipe-process
:buffer nil), it will create a pipe process without a buffer,
just like all the other process creation functions.

* src/process.c (Fmake_pipe_process): Check for explicit :buffer
nil and don't make a buffer. (bug#79596)
* doc/lispref/processes.texi (Asynchronous Processes): Update.
* test/src/process-tests.el
(process-test-make-pipe-process-no-buffer): Add test.
---
 doc/lispref/processes.texi |  3 ++-
 src/process.c              | 16 +++++++++++-----
 test/src/process-tests.el  |  6 ++++++
 3 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi
index 59f6ddeb63b..12e43cda5a6 100644
--- a/doc/lispref/processes.texi
+++ b/doc/lispref/processes.texi
@@ -842,7 +842,8 @@ Asynchronous Processes
 @code{make-process}, it is modified if necessary to make it unique.
 
 @item :buffer @var{buffer}
-Use @var{buffer} as the process buffer.
+Use @var{buffer} as the process buffer.  If the value is @code{nil},
+the subprocess is not associated with any buffer.
 
 @item :coding @var{coding}
 If @var{coding} is a symbol, it specifies the coding system to be
diff --git a/src/process.c b/src/process.c
index 9c74cc84199..4676873e7f2 100644
--- a/src/process.c
+++ b/src/process.c
@@ -2414,7 +2414,8 @@ DEFUN ("make-pipe-process", Fmake_pipe_process, Smake_pipe_process,
 :buffer BUFFER -- BUFFER is the buffer (or buffer-name) to associate
 with the process.  Process output goes at the end of that buffer,
 unless you specify a filter function to handle the output.  If BUFFER
-is not given, the value of NAME is used.
+is not given, the value of NAME is used.  BUFFER may be also nil, meaning
+that this process is not associated with any buffer.
 
 :coding CODING -- If CODING is a symbol, it specifies the coding
 system used for both reading and writing for this process.  If CODING
@@ -2479,10 +2480,15 @@ DEFUN ("make-pipe-process", Fmake_pipe_process, Smake_pipe_process,
   if (inchannel > max_desc)
     max_desc = inchannel;
 
-  buffer = plist_get (contact, QCbuffer);
-  if (NILP (buffer))
-    buffer = name;
-  buffer = Fget_buffer_create (buffer, Qnil);
+  {
+    Lisp_Object buffer_member = plist_member (contact, QCbuffer);
+    if (NILP (buffer_member))
+      buffer = name;
+    else
+      buffer = XCAR (XCDR (buffer_member));
+  }
+  if (!NILP (buffer))
+    buffer = Fget_buffer_create (buffer, Qnil);
   pset_buffer (p, buffer);
 
   pset_childp (p, contact);
diff --git a/test/src/process-tests.el b/test/src/process-tests.el
index 5f84d9acc6d..b8ceb931533 100644
--- a/test/src/process-tests.el
+++ b/test/src/process-tests.el
@@ -1053,5 +1053,11 @@ process-num-processors
   (should (integerp (num-processors)))
   (should (< 0 (num-processors))))
 
+(ert-deftest process-test-make-pipe-process-no-buffer ()
+  "Test that a pipe process can be created without a buffer."
+  (should     (process-buffer (make-pipe-process :name "test")))
+  (should     (process-buffer (make-pipe-process :name "test" :buffer "test")))
+  (should-not (process-buffer (make-pipe-process :name "test" :buffer nil))))
+
 (provide 'process-tests)
 ;;; process-tests.el ends here
-- 
2.43.7


Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Sat, 11 Oct 2025 09:18:02 GMT) Full text and rfc822 format available.

Notification sent to Spencer Baugh <sbaugh <at> janestreet.com>:
bug acknowledged by developer. (Sat, 11 Oct 2025 09:18:02 GMT) Full text and rfc822 format available.

Message #19 received at 79596-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Spencer Baugh <sbaugh <at> janestreet.com>
Cc: 79596-done <at> debbugs.gnu.org, rpluim <at> gmail.com
Subject: Re: bug#79596: [PATCH] Allow creating a pipe process without a buffer
Date: Sat, 11 Oct 2025 12:17:31 +0300
> From: Spencer Baugh <sbaugh <at> janestreet.com>
> Cc: Eli Zaretskii <eliz <at> gnu.org>,  79596 <at> debbugs.gnu.org
> Date: Wed, 08 Oct 2025 13:01:47 -0400
> 
> 
> Thanks for the fast review.
> 
> Robert Pluim <rpluim <at> gmail.com> writes:
> >>>>>> On Wed, 08 Oct 2025 08:31:31 +0300, Eli Zaretskii <eliz <at> gnu.org> said:
> >
> >     >> Date: Tue, 07 Oct 2025 14:42:21 -0400
> >     >> From:  Spencer Baugh via "Bug reports for GNU Emacs,
> >     >> the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> >     >> 
> >     >> Previously, even passing :buffer nil to make-pipe-process would
> >     >> create a buffer.  Now, if you explicitly call (make-pipe-process
> >     >> :buffer nil), it will create a pipe process without a buffer,
> >     >> just like all the other process creation functions.
> >
> >     Eli> Thanks, but this needs the corresponding changes to documentation
> >     Eli> before we can install this.
> 
> Added.
> 
> >     Eli> Bonus points for adding tests for this feature.
> 
> Added.
> 
> > C99 nitpick: you donʼt need a new scope to declare variables.
> 
> That is true, but I wanted to constrain the scope of "buffer_member",
> since it isn't used again after this bit of code, but "buffer" is used
> again.
> 
> > Code nitpick: Iʼd probably write it like this:
> >
> >   Lisp_Object buffer_member = plist_member (contact, QCBuffer);
> >   if (!NILP (buffer_member))
> >     buffer = XCDR (buffer_member);
> >   else
> >     buffer = name;
> >   if (!NILP (buffer))
> >     buffer = Fget_buffer_create (buffer, Qnil);
> 
> Ah, much nicer, changed to (approximately) this.

Thanks, installed on the master branch, and closing the bug.




This bug report was last modified 26 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.