Emacs, internal process killing, any command?

白昼怎懂夜的黑 提交于 2019-11-27 15:33:46

问题


How to kill an internal process in Emacs? For example I run M-x shell.

I can check running processes with M-x list-processes but how can I kill a process from this list?


回答1:


There is no default key binding for this; however see pjammer's answer -- list-processes+ includes (among other things) a kill binding on C-k -- and also Joao Tavora's answer -- which provides just a kill binding (for the same key).

event_jr points out in the comments that you can use M-: (kill-process) RET to kill the current buffer's process.

More generally: You can use M-: (kill-process PROCESS) RET, where PROCESS "may be a process, a buffer, or the name of a process or buffer", with those names being as they appear in the output of list-processes. Process names take precedence over buffer names, should you happen to have a conflict; so it's probably best to be in the habit of supplying the process name.

Alternatively, Emacs 23+ has a general system process manager (M-x proced) which is more akin to running top, and which does have a default binding for sending (arbitrary) signals (k). Of course it may be far less obvious in that listing which process you're interested in.


Edit: Better late than never :) The following enables M-x kill-process RET to be used (tested in Emacs 26.1):

;; Enable M-x kill-process (to kill the current buffer's process).
(put 'kill-process 'interactive-form
     '(interactive
       (let ((proc (get-buffer-process (current-buffer))))
         (if (process-live-p proc)
             (unless (yes-or-no-p (format "Kill %S? " proc))
               (error "Process not killed"))
           (error (format "Buffer %s has no process" (buffer-name))))
         nil)))



回答2:


This thread is ancient but here's a very quick hack that works perfectly for me

(define-key process-menu-mode-map (kbd "C-k") 'joaot/delete-process-at-point)

(defun joaot/delete-process-at-point ()
  (interactive)
  (let ((process (get-text-property (point) 'tabulated-list-id)))
    (cond ((and process
                (processp process))
           (delete-process process)
           (revert-buffer))
          (t
           (error "no process at point!")))))



回答3:


An alternative way:

You can use M-x eval-expression RET

Then type: (delete-process "<name-of-the-process>") RET

(where "name-of-the-process" was previously obtained from M-x list-processes RET).

Confirm that the process was killed by repeating M-x list-processes RET).

And that's it.




回答4:


it looks like there is a new mode or add on you can use instead called list process +



来源:https://stackoverflow.com/questions/10627289/emacs-internal-process-killing-any-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!