flet works, but with obsolete message; cl-flet does not work

后端 未结 1 1184
醉话见心
醉话见心 2020-12-21 17:02

I\'m trying to temporarily turn off the yes-or-no-p within a function that is defined elsewhere and then restore things to the way they were. Using flet<

相关标签:
1条回答
  • 2020-12-21 17:34

    Here's how I'd recommend you do it:

    (defvar stfu-inhibit-yonp nil)
    (defadvice yes-or-no-p (around stfu activate)
      (if stfu-inhibit-yonp (setq ad-return t) ad-do-it))
    (defadvice y-or-n-p (around stfu activate)
      (if stfu-inhibit-yonp (setq ad-return t) ad-do-it))
    
    (defadvice elmo-dop-queue-flush (around stfu activate)
      (let ((stfu-inhibit-yonp t))
        ad-do-it))
    

    Contrary to CL's flet this will make it clear (e.g. in C-h f yes-or-no-p) that something's going on with yes-or-no-p.

    0 讨论(0)
提交回复
热议问题