yes-or-no-p中的yes大家全都改的是y吗,能不能改成回车

(fset 'yes-or-no-p 'y-or-n-p),这应该是个经典设置,我估计百分之99%的emacs用户都有这个设置,但我发现的我用了这么几年emacs还是没习惯过来,每当看到yes or no,还是会直接按回车,然后发现没反应,又回去按y, :rofl: ,应该是因为大部分软件的确认键都是回车键而不是y。

不知道有人没人改过这个,究竟能不能把yes or no改成<return> or no

终端安装或者更新个什么都不都是y吗

yes-or-no-p is an alias for ‘y-or-n-p’.

(yes-or-no-p PROMPT)

  Probably introduced at or before Emacs version 19.23.

Ask user a "y or n" question.
Return t if answer is "y" and nil if it is "n".
PROMPT is the string to display to ask the question.  It should
end in a space; ‘y-or-n-p’ adds "(y or n) " to it.

No confirmation of the answer is requested; a single character is
enough.  SPC also means yes, and DEL means no.

To be precise, this function translates user input into responses
by consulting the bindings in ‘query-replace-map’; see the
documentation of that variable for more information.  In this
case, the useful bindings are ‘act’, ‘skip’, ‘recenter’,
‘scroll-up’, ‘scroll-down’, and ‘quit’.
An ‘act’ response means yes, and a ‘skip’ response means no.
A ‘quit’ response means to invoke ‘abort-recursive-edit’.
If the user enters ‘recenter’, ‘scroll-up’, or ‘scroll-down’
responses, perform the requested window recentering or scrolling
and ask again.

Under a windowing system a dialog box will be used if ‘last-nonmenu-event’
is nil and ‘use-dialog-box’ is non-nil.
(define-key query-replace-map (kbd "RET") 'act)
2 个赞

终端确实是,我主要在图形界面下使用emacs。终端也是shell-mode用的比较多

这个在windows图形界面有用吗,我这好像没用,我是emacs-q 在配置后执行 m-x shell,然后c-x k,关闭这个shell buffer,回车还是关不掉这个shell,还是要用y

(define-key query-replace-map (kbd "RET") 'act) 原来这里RET指的是空格不是回车,我按空格关掉了

那就是不能改。除非重写 y-or-no-p

想多了,空格是本來就有的

emacs master 分支的在这个新提交后可以使用 (setq use-short-answers t) 代替 (fset 'yes-or-no-p 'y-or-n-p)了。

emacs27 y-or-n-p 中可以设置 (define-key y-or-n-p-map [return] 'act) 让回车键表示输入 y

7 个赞

感谢,使用上了