trying to fix

This commit is contained in:
Chris Cochrun 2022-01-03 12:41:35 -06:00
parent fa407dfeb6
commit e013d7569e
22945 changed files with 447936 additions and 0 deletions

View file

@ -0,0 +1 @@
<!-- SC_OFF --><div class="md"><p>So I thought I might create a wrapper that uses advice to overwrite a function temporarily, re-routing it:</p> <pre><code>(defun ct/with-notmuch-as-compose-mail (&amp;rest body) (progn (advice-add &#39;compose-mail :override #&#39;notmuch-mua-mail) (unwind-protect (progn body) (advice-remove &#39;compose-mail #&#39;notmuch-mua-mail)))) </code></pre> <p>Turns out this doesn&#39;t work when called via:</p> <pre><code>(ct/with-notmuch-as-compose-mail (compose-mail)) </code></pre> <p>What does work, though, is a macro!</p> <pre><code>(defmacro ct/with-notmuch-as-compose-mail (&amp;rest body) `(progn (advice-add &#39;compose-mail :override #&#39;notmuch-mua-mail) (unwind-protect (progn ,@body) (advice-remove &#39;compose-mail #&#39;notmuch-mua-mail)))) </code></pre> <p>I don&#39;t understand the reason.</p> <p>Can anyone explain why the function doesn&#39;t do its thing?</p> </div><!-- SC_ON --> &#32; submitted by &#32; <a href="https://www.reddit.com/user/divinedominion"> /u/divinedominion </a> <br/> <span><a href="https://www.reddit.com/r/emacs/comments/rcsgpi/function_vs_macro_why_does_adviceadd_to_override/">[link]</a></span> &#32; <span><a href="https://www.reddit.com/r/emacs/comments/rcsgpi/function_vs_macro_why_does_adviceadd_to_override/">[comments]</a></span>