如何在emacs中自动回答yes或no [英] how to answer yes or no automatically in emacs
问题描述
我将函数语义symref绑定到密钥 Cc Cr ,如下所示:
I binded function semantic-symref to key C-c C-r like this:
(global-set-key (kbdCc Cr)'semantic-symref)
每当我按下 Cc Cr ,它提示:
everytime I pressed C-c C-r, it prompted:
查找xxxxx的参考文献(y或n)
Find references for xxxxx? (y or n)
如何自动回答?我尝试使用这样的lambda函数,但失败了
How can I answer it automatically? I tryed using lambda function like this, but failed
(global-set-key(kbdCc Cr)(lambda() )((semantic-symrefyes)))
推荐答案
@huitseeker的答案相当整洁有效。四年后,由于 flet
和 defadvice
已经过时,我写了以下函数来自动回答yes。也许这对某人有用。
The answer by @huitseeker is quite neat and effective. After four years, with flet
and defadvice
being obsolete, I wrote the following functions to answer yes automatically. Maybe it's useful for someone.
(defun my/return-t (orig-fun &rest args)
t)
(defun my/disable-yornp (orig-fun &rest args)
(advice-add 'yes-or-no-p :around #'my/return-t)
(advice-add 'y-or-n-p :around #'my/return-t)
(let ((res (apply orig-fun args)))
(advice-remove 'yes-or-no-p #'my/return-t)
(advice-remove 'y-or-n-p #'my/return-t)
res))
(advice-add 'projectile-kill-buffers :around #'my/disable-yornp)
这篇关于如何在emacs中自动回答yes或no的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!