Emacs,内部进程查杀,有什么命令吗? [英] Emacs, internal process killing, any command?

查看:22
本文介绍了Emacs,内部进程查杀,有什么命令吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 Emacs 中杀死一个内部进程?例如我运行 M-x shell.

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

我可以使用 M-x list-processes 检查正在运行的进程,但是如何从该列表中终止进程?

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

推荐答案

没有默认的键绑定;然而,请参阅 pjammer 的回答——list-processes+ 包括(除其他外)对 Ck 的终止绑定——以及 Joao Tavora 的回答——它只提供了一个终止绑定(同一个键).

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 在评论中指出你可以使用 M-: (kill-process) RET 来杀死 current 缓冲区的进程.

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

更一般的:你可以使用M-: (kill-process PROCESS) RET,其中PROCESS可能是一个进程、一个缓冲区,或者一个进程或缓冲区的名称",这些名称出现在 list-processes 的输出中.如果碰巧发生冲突,进程名称优先于缓冲区名称;所以最好养成提供进程名称的习惯.

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.

或者,Emacs 23+ 有一个通用系统进程管理器(Mx proced),它更类似于运行 top,并且它有一个默认的发送绑定(任意)信号(k).当然,在该列表中您对哪个过程感兴趣可能不那么明显.

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.

迟到总比不到好:) 以下使 Mx kill-process RET 被使用(在 Emacs 26.1 中测试):

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)))

这篇关于Emacs,内部进程查杀,有什么命令吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆