how to answer yes or no automatically in emacs

后端 未结 3 960
陌清茗
陌清茗 2021-02-20 06:43

I binded function semantic-symref to key C-c C-r like this:

(global-set-key (kbd \"C-c C-r\") \'semantic-symref)

everytime I pressed

3条回答
  •  猫巷女王i
    2021-02-20 07:33

    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)
    

提交回复
热议问题