comparison lisp/subr.el @ 4575:eecd28508f4a

Add #'subr-arity, API taken from GNU, implementation our own. lisp/ChangeLog addition: 2009-01-11 Aidan Kehoe <kehoea@parhasard.net> * subr.el: Correct a comment, we now have #'syntax-after in syntax.el. (subr-arity): New. Docstring and API taken initially from GNU's data.c, revision 1.275, GPLv2. tests/ChangeLog addition: 2009-01-11 Aidan Kehoe <kehoea@parhasard.net> * automated/lisp-tests.el (): Test #'subr-arity, recently added to subr.el.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 11 Jan 2009 13:18:42 +0000
parents e96f3aca4d63
children fd36a980d701
comparison
equal deleted inserted replaced
4574:302136a857ec 4575:eecd28508f4a
1697 1697
1698 ;; (defun shell-quote-argument (argument) in process.el. 1698 ;; (defun shell-quote-argument (argument) in process.el.
1699 1699
1700 ;; (defun make-syntax-table (&optional oldtable) in syntax.el. 1700 ;; (defun make-syntax-table (&optional oldtable) in syntax.el.
1701 1701
1702 ;; (defun syntax-after (pos) #### doesn't exist. 1702 ;; (defun syntax-after (pos) in syntax.el.
1703 1703
1704 ;; global-set-key, local-set-key, global-unset-key, local-unset-key in 1704 ;; global-set-key, local-set-key, global-unset-key, local-unset-key in
1705 ;; keymap.el. 1705 ;; keymap.el.
1706 1706
1707 ;; frame-configuration-p is in frame.el. 1707 ;; frame-configuration-p is in frame.el.
1740 (when (memq ?- list) 1740 (when (memq ?- list)
1741 (setq list (delq ?- list) 1741 (setq list (delq ?- list)
1742 list (nconc list '(?\\ ?-))))) 1742 list (nconc list '(?\\ ?-)))))
1743 (apply #'string list))) 1743 (apply #'string list)))
1744 1744
1745 ;; XEmacs addition to subr.el; docstring and API taken initially from GNU's
1746 ;; data.c, revision 1.275, GPLv2.
1747 (defun subr-arity (subr)
1748 "Return minimum and maximum number of args allowed for SUBR.
1749 SUBR must be a built-in function (not just a symbol that refers to one).
1750 The returned value is a pair (MIN . MAX). MIN is the minimum number
1751 of args. MAX is the maximum number or the symbol `many', for a
1752 function with `&rest' args, or `unevalled' for a special form.
1753
1754 See also `special-form-p', `subr-min-args', `subr-max-args',
1755 `function-allows-args'. "
1756 (check-argument-type #'subrp subr)
1757 (cons (subr-min-args subr)
1758 (cond
1759 ((special-form-p subr)
1760 'unevalled)
1761 ((null (subr-max-args subr))
1762 'many)
1763 (t (subr-max-args subr)))))
1764
1745 ;;; subr.el ends here 1765 ;;; subr.el ends here