branch: externals/listen
commit 455a60c255a510e3ceb43429cfac8f92085985c8
Author: Adam Porter <[email protected]>
Commit: Adam Porter <[email protected]>
Fix: For Emacs 30.1+
I didn't realize the cyclic indirection loop until I actually ran it
on Emacs 30.1. This is a unique hack, though, one few languages and
platforms even permit. I love (E)Lisp! (Even CL doesn't have
CL-LETF, despite the name--though I guess one could implement it on
it).
---
listen-queue.el | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/listen-queue.el b/listen-queue.el
index b579e4c985..a7b74d9a7a 100644
--- a/listen-queue.el
+++ b/listen-queue.el
@@ -1069,7 +1069,7 @@ select track as well."
(defalias 'listen-queue--vtable--recompute-numerical
;; TODO: Remove this when requiring Emacs 30+.
;; See <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=69927>.
- (if (version<= emacs-version "30")
+ (if (version< emacs-version "30.1")
(lambda (table line)
"Recompute numericalness of columns if necessary."
(let ((columns (vtable-columns table))
@@ -1082,7 +1082,24 @@ select track as well."
line)
(when recompute
(vtable--compute-columns table))))
- #'vtable--recompute-numerical))
+ ;; HACK: This is unique, one the likes of which I've never quite seen
before. This is to work
+ ;; around errors like "(cyclic-function-indirection
vtable--recompute-numerical)" and "Symbol’s
+ ;; chain of function indirections contains a loop:
vtable--recompute-numerical". Because we
+ ;; also, in the macro `listen-with-vtable-at', dynamically rebind the
function
+ ;; `vtable--recompute-numerical' with `cl-letf*', which normally creates a
loop, we use
+ ;; `cl-letf' here also, to save a reference to the original function
definition, which we make
+ ;; our own alias to. Then when the expansion of `cl-letf*' in
`listen-with-vtable-at' rebinds
+ ;; the function slot of `vtable--recompute-numerical', it binds it to the
original function,
+ ;; rather than to the symbol (which would cause the cyclic
indirection/loop).
+
+ ;; Now, you may think this is ugly or ridiculous, but it has a legitimate
purpose: to provide a
+ ;; fix for users of older Emacs versions, while also being compatible with
the Emacs version
+ ;; that has the fix included. And how many other languages and platforms
would even allow this?
+ ;; (Remember that `cl-letf' rebinds the symbol's function slot, so that
while the macro's
+ ;; expansion is on the stack, anything else--in the whole system--that
calls the rebound
+ ;; function calls our replacement for it--not just where we, ourselves,
directly reference it.)
+ (cl-letf ((orig-fn (symbol-function 'vtable--recompute-numerical)))
+ orig-fn)))
;;;; Footer