emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master fc0bd6057c: Make 'delete-process' into a command


From: Lars Ingebrigtsen
Subject: master fc0bd6057c: Make 'delete-process' into a command
Date: Sat, 7 May 2022 12:22:09 -0400 (EDT)

branch: master
commit fc0bd6057c676b9945aa739dd9365a350ca5acef
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Make 'delete-process' into a command
    
    * doc/lispref/processes.texi (Deleting Processes): Document
    missing PROCESS value.
    * src/process.c (Fdelete_process): Allow calling interactively
    (bug#10107).
---
 doc/lispref/processes.texi | 14 ++++++++------
 etc/NEWS                   |  7 +++++++
 src/process.c              | 18 ++++++++++++++++--
 3 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi
index 18f446735b..668a577870 100644
--- a/doc/lispref/processes.texi
+++ b/doc/lispref/processes.texi
@@ -1011,16 +1011,18 @@ terminated (due to calling @code{exit} or to a signal). 
 If it is
 they exit.
 @end defopt
 
-@defun delete-process process
+@defun delete-process &optional process
 This function deletes a process, killing it with a @code{SIGKILL}
 signal if the process was running a program.  The argument may be a
 process, the name of a process, a buffer, or the name of a buffer.  (A
 buffer or buffer-name stands for the process that
-@code{get-buffer-process} returns.)  Calling @code{delete-process} on
-a running process terminates it, updates the process status, and runs
-the sentinel immediately.  If the process has already terminated,
-calling @code{delete-process} has no effect on its status, or on the
-running of its sentinel (which will happen sooner or later).
+@code{get-buffer-process} returns, and a missing or @code{nil}
+@var{process} means that the current buffer's process should be
+killed.)  Calling @code{delete-process} on a running process
+terminates it, updates the process status, and runs the sentinel
+immediately.  If the process has already terminated, calling
+@code{delete-process} has no effect on its status, or on the running
+of its sentinel (which will happen sooner or later).
 
 If the process object represents a network, serial, or pipe
 connection, its status changes to @code{closed}; otherwise, it changes
diff --git a/etc/NEWS b/etc/NEWS
index 6a60231b3a..ee7a127af0 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -248,6 +248,13 @@ removed some time after that.
 
 * Changes in Emacs 29.1
 
+---
+** 'delete-process' is now a command.
+When called interactively, it will kill the process running in the
+current buffer (if any).  This can be useful if you have runaway
+output in the current buffer (from a process or a network connection),
+and want to stop it.
+
 +++
 ** New command 'restart-emacs'.
 This is like 'save-buffers-kill-emacs', but instead of just killing
diff --git a/src/process.c b/src/process.c
index 08a02ad942..2f8863aef2 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1071,13 +1071,24 @@ record_deleted_pid (pid_t pid, Lisp_Object filename)
 
 }
 
-DEFUN ("delete-process", Fdelete_process, Sdelete_process, 1, 1, 0,
+DEFUN ("delete-process", Fdelete_process, Sdelete_process, 0, 1,
+       "(list 'message)",
        doc: /* Delete PROCESS: kill it and forget about it immediately.
 PROCESS may be a process, a buffer, the name of a process or buffer, or
-nil, indicating the current buffer's process.  */)
+nil, indicating the current buffer's process.
+
+Interactively, it will kill the current buffer's process.  */)
   (register Lisp_Object process)
 {
   register struct Lisp_Process *p;
+  bool mess = false;
+
+  /* We use this to see whether we were called interactively.  */
+  if (EQ (process, Qmessage))
+    {
+      mess = true;
+      process = Qnil;
+    }
 
   process = get_process (process);
   p = XPROCESS (process);
@@ -1131,6 +1142,8 @@ nil, indicating the current buffer's process.  */)
        }
     }
   remove_process (process);
+  if (mess)
+    message ("Deleted process");
   return Qnil;
 }
 
@@ -8637,6 +8650,7 @@ sentinel or a process filter function has an error.  */);
 
   DEFSYM (Qnull, "null");
   DEFSYM (Qpipe_process_p, "pipe-process-p");
+  DEFSYM (Qmessage, "message");
 
   defsubr (&Sprocessp);
   defsubr (&Sget_process);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]