register.el (register--jumpable-p): Fix bug#78186

While `register--get-method-type` worked fine for `register-val-insert`
it always returns nil for `register-val-jump-to` because it presumed the
method took a single argument.  Make it work for multi-arg generic functions.

* lisp/register.el (register--get-method-type): Add `other-args-type` arg.
(register--jumpable-p): Use it.
This commit is contained in:
Stefan Monnier 2025-05-01 12:38:33 -04:00
parent 8ddb8b0e45
commit 311ea96ccf

View file

@ -575,16 +575,17 @@ With a prefix argument, prompt for BUFFER as well."
(add-hook 'kill-buffer-hook #'register-buffer-to-file-query nil t))
(set-register register (cons 'buffer buffer)))
(defun register--get-method-type (val genfun)
(defun register--get-method-type (val genfun &optional other-args-type)
(let* ((type (cl-type-of val))
(types (cl--class-allparents (cl-find-class type))))
(while (and types (not (cl-find-method genfun nil (list (car types)))))
(while (and types (not (cl-find-method genfun nil
(cons (car types) other-args-type))))
(setq types (cdr types)))
(car types)))
(defun register--jumpable-p (regval)
"Return non-nil if `register-val-insert' is implemented for REGVAL."
(pcase (register--get-method-type regval 'register-val-jump-to)
(pcase (register--get-method-type regval 'register-val-jump-to '(t))
('t nil)
('registerv (registerv-jump-func regval))
('cons