Skip to content

Commit

Permalink
transient--func-arity: New function
Browse files Browse the repository at this point in the history
Advising a function (e.g., using elp) changes its arity (to (0 . many)).
We really need to know the "actual" arity, so we have no choice but to
peal the advice to get to the adviced function.
  • Loading branch information
tarsius committed Apr 21, 2024
1 parent 1251faf commit 91dd7bb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lisp/transient.el
Original file line number Diff line number Diff line change
Expand Up @@ -3910,7 +3910,7 @@ called inside the correct buffer (see `transient--insert-group')
and its value is returned to the caller."
(and-let* ((desc (oref obj description))
(desc (if (functionp desc)
(if (= (car (func-arity desc)) 1)
(if (= (car (transient--func-arity desc)) 1)
(funcall desc obj)
(funcall desc))
desc)))
Expand Down Expand Up @@ -4010,7 +4010,7 @@ If the OBJ's `key' is currently unreachable, then apply the face
(if (and (not (facep face))
(functionp face))
(let ((transient--pending-suffix obj))
(if (= (car (func-arity face)) 1)
(if (= (car (transient--func-arity face)) 1)
(funcall face obj)
(funcall face)))
face)))
Expand Down Expand Up @@ -4401,6 +4401,9 @@ we stop there."
(face-remap-reset-base 'default)
(face-remap-add-relative 'default 'fixed-pitch))

(defun transient--func-arity (fn)
(func-arity (advice--cd*r (if (symbolp fn) (symbol-function fn) fn))))

(defun transient--seq-reductions-from (function sequence initial-value)
(let ((acc (list initial-value)))
(seq-doseq (elt sequence)
Expand Down

0 comments on commit 91dd7bb

Please sign in to comment.