Subject: Re: bug#54079: 29.0.50; Method dispatching eratically fails

From: Michael Heerdegen <[email-masked]>
Date: Wed, 23 Feb 2022 00:55:18 +0100

Michael Heerdegen <[email-masked]> writes:

> > What does `type-of` return on VAL?

`type-of' returns the expected value, the symbol which is the name of
the class.  The return value is not different whether it works or not.

This for example returns t:

  (eq (type-of (cdr (assoc ?A register-alist))) 'my-window+pos-register)

OTOH, in the *trace-output* I am currently seeing this:

1 -> (my-register-val-describe-nicely #s(#<symbol my-window+pos-register at 704865> :#<symbol window at 704894> #<window 173> :#<symbol pos at 704901> #<marker at 699485 in .gnu-emacs.el>))      00:41:15.227
  (my-register-val-describe-nicely #s(#<symbol my-window+pos-register at 704865> :#<symbol window at 704894> #<window 173> :#<symbol pos at 704901> #<marker at 699485 in .gnu-emacs.el>))
  (register-val-describe #s(#<symbol my-window+pos-register at 704865> :#<symbol window at 704894> #<window 173> :#<symbol pos at 704901> #<marker at 699485 in .gnu-emacs.el>) nil)
  (describe-register-1 65)
  (register-describe-oneline 65)
  (my-register-preview (65 . #s(#<symbol my-window+pos-register at 704865> :#<symbol window at 704894> #<window 173> :#<symbol pos at 704901> #<marker at 699485 in .gnu-emacs.el>)))
  (my-register-preview-function (65 . #s(#<symbol my-window+pos-register at 704865> :#<symbol window at 704894> #<window 173> :#<symbol pos at 704901> #<marker at 699485 in .gnu-emacs.el>)))
  (my-register-preview--around-ad #f(compiled-function (buffer &optional show-empty) "Pop up a window to show register preview in BUFFER.\nIf SHOW-EMPTY is non-nil show the window even if no registers.\nFormat of each entry is controlled by the variable `register-preview-function'." #<bytecode 0x1e3c7c22968242f1>) "*Register Preview*")
  (register-preview "*Register Preview*")
  (timer-event-handler [t 25109 29850 770721 nil #f(compiled-function () #<bytecode 0x884d14a4ec654c5>) nil nil 4000 nil])
  (read-key #("Jump to register: " 0 18 (face minibuffer-prompt)))
  (register-read-with-preview "Jump to register: ")
  (command-execute jump-to-register)
1 <- my-register-val-describe-nicely: nil

Definitions are

  (cl-defstruct my-window+pos-register "Doc" window pos)

and

(cl-defgeneric my-register-val-describe-nicely (val)
  "Alternative to `register-val-describe' - the return value is used from this one."
  ;; This should support colors at least for some preview functions
  (ignore val)
  nil)

(cl-defmethod my-register-val-describe-nicely ((val my-window+pos-register))
  (my-register-val-describe-nicely (my-window+pos-register-pos val)))

The default implementation is used and the matching implementation is
ignored.

I have now re-evaluated some of the definitions.  Sometimes this helps -
ATM it didn't.  It made the symbols with positions disappear in the
trace however, now lines are traced like

(my-register-val-describe-nicely #s(my-window+pos-register :window #<window 263 on .gnu-emacs.el> :pos #<marker at 2820 in .gnu-emacs.el>))

So I'm not sure if symbols with positions are related.

Michael.