Okay, I need to do a hacky #elisp thing. Yes, I know it's terrible.
Basically, I have an existing defun. Let's call it foo. I need to replace it with a new function that calls the old one and transforms its output before returning it.
I naïvely assumed I could do it like this:
(let ((oldfunc (function foo)))
(defun foo ()
(my-transform (funcall oldfunc))))...but this doesn't actually copy the old function, just a reference to the symbol, so it ends up locking itself in a recursive loop.
I'm sure there's a way to do this.
#AskFedi
Edit: Got it. It's:
(let ((oldfunc (symbol-function 'foo)))
(defun foo ()
(my-transform (funcall oldfunc))))Edit 2: It turns out there's a cleaner way still.
See: aus.social/@carlozancanaro/116…
Also, there's still something Gmail isn't liking. Looking at the differences in the headers between emacs and my other clients (whose mail does get through), the next most obvious difference is that the Content-Type header doesn't specify an encoding. Whether this is the actual problem or not, I should probably fix that. I'm just working on how.
reshared this
Jonathan Lamothe
in reply to Jonathan Lamothe • •Okay, so I wrote this hacky nonsense in my
~/.emacs.d/init.el, but it doesn't seem to be having any effect. The function in question seems completely unaffected.Perhaps this code is being evaluated before the original function is defined?
The idea is to hash the Message-ID header in outgoing mail because Gmail seems to have decided the original format looks like spam.
#emacs #elisp #AskFedi
Daniel
in reply to Jonathan Lamothe • • •Jonathan Lamothe
in reply to Daniel • •@Daniel It turns out that the better solution was here:
Carlo Zancanaro
2026-04-12 02:26:37
Carlo Zancanaro
in reply to Jonathan Lamothe • • •Sensitive content
gnu.org
www.gnu.orgJonathan Lamothe likes this.
Jonathan Lamothe
in reply to Carlo Zancanaro • •Peter J. Jones
in reply to Jonathan Lamothe • • •Sensitive content
Here's a cleaner version that should work. However, I'd be surprised if it's actually the message IDs that are the problem.
```
(defun jrl-message-unique-id (orig &rest args)
"Hash the output of ORIG.
ARGS are passed on to ORIG"
(secure-hash 'sha256 (apply orig args)))
(advice-add ''message-unique-id :around #'jrl-message-unique-id)
```
Jonathan Lamothe likes this.
Greg A. Woods
in reply to Jonathan Lamothe • • •No, you can't do that, especially not in elisp.
However there's
defadvicesitting just around the corner waiting to help you solve your problem.See also:
lispworks.com/documentation/lw…
emacsninja.com/posts/a-piece-o…
stackoverflow.com/questions/15…
Preferred method of overriding an emacs lisp function?
Stack OverflowGreg A. Woods
in reply to Jonathan Lamothe • • •Of course there's a question about your underlying logic lurking here: Why don't you just define a new function that calls the old function and transforms its output and then just call the new function.
Transforming the output of an existing function risks breaking all other callers of that function.
Jonathan Lamothe
in reply to Greg A. Woods • •