[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Killing a named process.
From: |
Matt Hodges |
Subject: |
Killing a named process. |
Date: |
Tue, 14 Nov 2000 14:46:04 +0000 |
[I posted this to gnu.emacs.bug but it seems to have got lost]
Feature request: occasionally I want to be able to kill a process (as
seen in the *Process List* buffer) and no convenience command (eg
ispell-kill-ispell) exists.
Did I miss a way of easily doing this? If not, the following can be
used.
(defun kill-named-process ()
"Kill a process chosen from a list.
The list is built from the function `process-list'."
(interactive)
(if (equal (length (process-list)) 0)
(error "No processes exist"))
(let* ((process-list
(mapcar
(function (lambda (w)
(list (process-name w) w)))
(process-list)))
(process-name
(completing-read
"Choose process to kill: " process-list nil t))
process)
(cond
((> (length process-name) 0)
(setq process (cadr (assoc process-name process-list)))
(kill-process process)
;; Update the *Process List* buffer
(if (buffer-live-p (get-buffer "*Process List*"))
(progn
;; Wait until process disappears off list
(while (member process (process-list))
(sit-for 0 100))
(save-window-excursion
(list-processes))))
(message "Process \"%s\" killed" process-name))
(t
(message "No process chosen")))))