Open alphapapa opened 7 years ago
(noflet ((find-file-noselect (file-name) (if (string-match-p "^#.*" file-name) (this-fn "/tmp/mytest") (this-fn file-name)))
I think this part of the example is wrong: this-fn
is boundp, but not fboundp, so you can only call it with funcall
. But the example never calls find-file-noselect
so the error is not triggered.
Hi Noam,
I think you're right. The macro sets the rebound function symbol's definition like this, and it sets this-fn
's value cell rather than its function cell:
(fset (quote ,name)
(cl-function
(lambda ,args
(let ((this-fn ,saved-func-namev))
,@body))))
Other than the obvious slight performance impact, is there any reason to not set this-fn
's function cell as well, so it could be called directly rather than with funcall
?
If that's not possible, it should probably be promimently stated in the docstring that this-fn
only has its value cell set, not its function cell.
I feel like that might have an impact on behaviour? Feel nervous about it. Maybe write me a test and send me a PR and I'll pull it?
Perhaps a second implementation that sets the function cell as well would be good? Or an option or something?
Sorry about the mahoosive delay.
Using Emacs 25.2.2. I'm bewildered by this.
This works fine:
But this doesn't:
Even this doesn't work:
But this does work:
I've stared at the working macro call from the readme's example, which works fine, and at my
format-time-string
one, which doesn't work, but I can't figure out why it isn't working.Thanks for your help.