aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2022-06-26 22:45:39 +0200
committerLars Ingebrigtsen2022-06-26 22:45:39 +0200
commited84f24a215a65dcf2ef49d343eebdbd4be178ee (patch)
tree6e0bfde02f305697efe6291a3969483df794a52d
parent19c44e2be30a2549db446308a128acdff4686c28 (diff)
downloademacs-ed84f24a215a65dcf2ef49d343eebdbd4be178ee.tar.gz
emacs-ed84f24a215a65dcf2ef49d343eebdbd4be178ee.zip
Make `signal-process' allow completing over signal names
* lisp/simple.el (read-signal-name): New function. * src/process.c (Fsignal_process): Use it to allow completing over the signal names (bug#56239). (Fsignal_names): New function.
-rw-r--r--lisp/simple.el13
-rw-r--r--src/process.c19
2 files changed, 31 insertions, 1 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index a750eed72b8..6d62c028657 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -10627,6 +10627,19 @@ If the buffer doesn't exist, create it first."
10627 "Check whether STRING is empty." 10627 "Check whether STRING is empty."
10628 (string= string "")) 10628 (string= string ""))
10629 10629
10630(defun read-signal-name ()
10631 "Read a signal number or name."
10632 (let ((value
10633 (completing-read "Signal code or name: "
10634 (signal-names)
10635 nil
10636 (lambda (value)
10637 (or (string-match "\\`[0-9]+\\'" value)
10638 (member value (signal-names)))))))
10639 (if (string-match "\\`[0-9]+\\'" value)
10640 (string-to-number value)
10641 (intern (concat "sig" (downcase value))))))
10642
10630 10643
10631 10644
10632(provide 'simple) 10645(provide 'simple)
diff --git a/src/process.c b/src/process.c
index b2847ee1725..5cb5d952229 100644
--- a/src/process.c
+++ b/src/process.c
@@ -7109,7 +7109,7 @@ See function `signal-process' for more details on usage. */)
7109} 7109}
7110 7110
7111DEFUN ("signal-process", Fsignal_process, Ssignal_process, 7111DEFUN ("signal-process", Fsignal_process, Ssignal_process,
7112 2, 3, "sProcess (name or number): \nnSignal code: ", 7112 2, 3, "(list (read-string \"Process (name or number): \") (read-signal-name))",
7113 doc: /* Send PROCESS the signal with code SIGCODE. 7113 doc: /* Send PROCESS the signal with code SIGCODE.
7114PROCESS may also be a number specifying the process id of the 7114PROCESS may also be a number specifying the process id of the
7115process to signal; in this case, the process need not be a child of 7115process to signal; in this case, the process need not be a child of
@@ -8317,6 +8317,22 @@ If QUERY is `all', also count processors not available. */)
8317#endif 8317#endif
8318} 8318}
8319 8319
8320DEFUN ("signal-names", Fsignal_names, Ssignal_names, 0, 0, 0,
8321 doc: /* Return a list of known signal names on this system. */)
8322 (void)
8323{
8324 char name[SIG2STR_MAX];
8325 Lisp_Object names = Qnil;
8326 for (int i = 0; i < 255; ++i)
8327 {
8328 if (!sig2str (i, name))
8329 {
8330 names = Fcons (build_string (name), names);
8331 }
8332 }
8333 return names;
8334}
8335
8320#ifdef subprocesses 8336#ifdef subprocesses
8321/* Arrange to catch SIGCHLD if this hasn't already been arranged. 8337/* Arrange to catch SIGCHLD if this hasn't already been arranged.
8322 Invoke this after init_process_emacs, and after glib and/or GNUstep 8338 Invoke this after init_process_emacs, and after glib and/or GNUstep
@@ -8770,4 +8786,5 @@ sentinel or a process filter function has an error. */);
8770 defsubr (&Slist_system_processes); 8786 defsubr (&Slist_system_processes);
8771 defsubr (&Sprocess_attributes); 8787 defsubr (&Sprocess_attributes);
8772 defsubr (&Snum_processors); 8788 defsubr (&Snum_processors);
8789 defsubr (&Ssignal_names);
8773} 8790}