I have some code that I use in my .emacs file that works with version 25.5 where the definition of windows--sanitize-window-sizes looks something like this:
(defun window--sanitize-window-sizes (frame horizontal) ;; emacs 25.5
That I want to make work both there and in emacs 27.1 where the definition of windows--sanitize-window-sizes looks something like this:
(defun window--sanitize-window-sizes (horizontal) ;; emacs 27.1
So, how do I check in my calling function how many arguments the function expects, what do I write to ask this question, as in:
(cond
((not (fboundp 'window--sanitize-window-sizes))
t ; no function to call, assume sizes ok
)
((= (max-number-of-arguments 'window--sanitize-window-sizes) 1)
;; probably something like (cdr (arguments-accepted 'window--sanitize-window-sizes))
(window--sanitize-window-sizes size) ; 27.1 expects only size
)
(t
(window--sanitize-window-sizes frame size) ; 25.5 expects only size
)
)
I presume there is a function I can apply to a symbol that tells me how many
arguments are expected (min max) or maybe something more complex to handle &optional
and &rest
cases.