Somewhere between emacs 23.1 and 24.1, the interface of url-retrieve changed. In emacs 23.1, it looks like this:
(url-retrieve URL CALLBACK &optional CBARGS)
In version 24.1, it looks like this:
(url-retrieve URL CALLBACK &optional CBARGS SILENT INHIBIT-COOKIES)
I have an emacs package that uses this function. I'd like to take advantage of the new SILENT argument on emacs 24.1, while maintaining backwards compatibility with older versions of emacs that don't support it.
What's the best way to manage this? Can I grab the maximum number of arguments at runtime?
You can use this function to get the argument list:
(defun my-get-arglist (obj)
;; code taken from disassemble-internal
(let ((macro 'nil)
(name 'nil)
(doc 'nil)
args)
(while (symbolp obj)
(setq name obj
obj (symbol-function obj)))
(if (subrp obj)
(error "Can't disassemble #<subr %s>" name))
(if (and (listp obj) (eq (car obj) 'autoload))
(progn
(load (nth 1 obj))
(setq obj (symbol-function name))))
(if (eq (car-safe obj) 'macro) ;handle macros
(setq macro t
obj (cdr obj)))
(if (and (listp obj) (eq (car obj) 'byte-code))
(setq obj (list 'lambda nil obj)))
(if (and (listp obj) (not (eq (car obj) 'lambda)))
(error "not a function"))
(if (consp obj)
(if (assq 'byte-code obj)
nil
(setq obj (byte-compile obj))))
(cond ((consp obj)
(setq obj (cdr obj)) ;throw lambda away
(setq args (car obj)) ;save arg list
(setq obj (cdr obj)))
((byte-code-function-p obj)
(setq args (aref obj 0)))
(t (error "Compilation failed")))
args))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With