bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#29156: 25.3; eshell/kill does not understand -<signal>, [PATCH] Make


From: Eric Skoglund
Subject: bug#29156: 25.3; eshell/kill does not understand -<signal>, [PATCH] Make eshell/kill handle -<signal> and -<SIGNALNAME>
Date: Fri, 23 Mar 2018 07:03:55 +0100

Noam Postavsky <address@hidden> writes:

> Thanks, do you have copyright assignment for Emacs? (the change is small
> enough to install regardless, I'm asking just to know if it should be
> marked as a tiny change).

Yes it was completed on 2016-12-05 when I had grand plans to contribute
to emacs (maybe thoose plans can be fullfilled now :)).

>
> A couple more minor nitpicks:
>
>>      * doc/misc/eshell.texi (kill): Update docs to reflect new
>>      function behaviour
>>      * etc/NEWS: Mention new eshell/kill behaviour
>
> Missing periods here.
>
>> +          (setq signum (intern (substring arg 1 (length arg))))))
>
> That could be just (substring arg 1)
>

Thanks!

> P.S. don't worry about the forwarding thing, it happens often enough
> that I've written an Emacs command to mostly automate it.

Ah great :)

Here is the latest patch version. Thanks for all the help for a first
time contributor!

>From 7588028d623a8312a7a359f2be4ba84426d0619e Mon Sep 17 00:00:00 2001
From: Eric Skoglund <address@hidden>
Date: Fri, 16 Mar 2018 14:49:56 +0100
Subject: [PATCH] Make eshell/kill handle -<signal> and -<SIGNALNAME>

     * lisp/eshell/esh-proc.el (eshell/kill):
     Handle the argument parsing and numeric conversion in function
     in order to parse -signal and -SIGNALNAME correctly.
     * doc/misc/eshell.texi (kill): Update docs to reflect new
     function behaviour.
     * etc/NEWS: Mention new eshell/kill behaviour.
---
 doc/misc/eshell.texi    | 2 +-
 etc/NEWS                | 5 +++++
 lisp/eshell/esh-proc.el | 9 ++++++---
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/doc/misc/eshell.texi b/doc/misc/eshell.texi
index 80077e5ccd..bda6159488 100644
--- a/doc/misc/eshell.texi
+++ b/doc/misc/eshell.texi
@@ -330,7 +330,7 @@ Built-ins
 @item kill
 @cmindex kill
 Kill processes.  Takes a PID or a process object and an optional
-signal specifier.
+signal specifier which can either be a number or a signal name.
 
 @item listify
 @cmindex listify
diff --git a/etc/NEWS b/etc/NEWS
index b6c4157384..7df6eb4387 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -273,6 +273,11 @@ To restore the old behavior, use
 *** The function 'shell-uniquify-list' has been renamed from
 'eshell-uniqify-list'.
 
+*** The function eshell/kill is now able to handle signal switches.
+Previously eshell/kill would fail if provided a kill signal to send to the
+process.  It now accepts signals specified either by name or by its number.
+
+
 ** Pcomplete
 *** The function 'pcomplete-uniquify-list' has been renamed from
 'pcomplete-uniqify-list'.
diff --git a/lisp/eshell/esh-proc.el b/lisp/eshell/esh-proc.el
index b3bd7a7245..a7855d81db 100644
--- a/lisp/eshell/esh-proc.el
+++ b/lisp/eshell/esh-proc.el
@@ -167,7 +167,8 @@ eshell/jobs
 (defun eshell/kill (&rest args)
   "Kill processes.
 Usage: kill [-<signal>] <pid>|<process> ...
-Accepts PIDs and process objects."
+Accepts PIDs and process objects.  Optionally accept signals
+and signal names."
   ;; If the first argument starts with a dash, treat it as the signal
   ;; specifier.
   (let ((signum 'SIGINT))
@@ -178,12 +179,12 @@ eshell/kill
          ((string-match "\\`-[[:digit:]]+\\'" arg)
           (setq signum (abs (string-to-number arg))))
          ((string-match "\\`-\\([[:upper:]]+\\|[[:lower:]]+\\)\\'" arg)
-          (setq signum (abs (string-to-number arg)))))
+          (setq signum (intern (substring arg 1)))))
         (setq args (cdr args))))
     (while args
       (let ((arg (if (eshell-processp (car args))
                      (process-id (car args))
-                   (car args))))
+                   (string-to-number (car args)))))
         (when arg
           (cond
            ((null arg)
@@ -198,6 +199,8 @@ eshell/kill
       (setq args (cdr args))))
   nil)
 
+(put 'eshell/kill 'eshell-no-numeric-conversions t)
+
 (defun eshell-read-process-name (prompt)
   "Read the name of a process from the minibuffer, using completion.
 The prompt will be set to PROMPT."
-- 
2.13.6


reply via email to

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