comparison lisp/emacs-lisp/advice.el @ 89909:68c22ea6027c

Sync to HEAD
author Kenichi Handa <handa@m17n.org>
date Fri, 16 Apr 2004 12:51:06 +0000
parents 375f2633d815
children e24e2e78deda
comparison
equal deleted inserted replaced
89908:ee1402f7b568 89909:68c22ea6027c
1 ;;; advice.el --- an overloading mechanism for Emacs Lisp functions 1 ;;; advice.el --- an overloading mechanism for Emacs Lisp functions
2 2
3 ;; Copyright (C) 1993,1994,2000, 2001 Free Software Foundation, Inc. 3 ;; Copyright (C) 1993,1994,2000,01,2004 Free Software Foundation, Inc.
4 4
5 ;; Author: Hans Chalupsky <hans@cs.buffalo.edu> 5 ;; Author: Hans Chalupsky <hans@cs.buffalo.edu>
6 ;; Maintainer: FSF 6 ;; Maintainer: FSF
7 ;; Created: 12 Dec 1992 7 ;; Created: 12 Dec 1992
8 ;; Keywords: extensions, lisp, tools 8 ;; Keywords: extensions, lisp, tools
2561 (defun ad-subr-arglist (subr-name) 2561 (defun ad-subr-arglist (subr-name)
2562 "Retrieve arglist of the subr with SUBR-NAME. 2562 "Retrieve arglist of the subr with SUBR-NAME.
2563 Either use the one stored under the `ad-subr-arglist' property, 2563 Either use the one stored under the `ad-subr-arglist' property,
2564 or try to retrieve it from the docstring and cache it under 2564 or try to retrieve it from the docstring and cache it under
2565 that property, or otherwise use `(&rest ad-subr-args)'." 2565 that property, or otherwise use `(&rest ad-subr-args)'."
2566 (cond ((ad-subr-args-defined-p subr-name) 2566 (if (ad-subr-args-defined-p subr-name)
2567 (ad-get-subr-args subr-name)) 2567 (ad-get-subr-args subr-name)
2568 ;; says jwz: Should use this for Lemacs 19.8 and above: 2568 ;; says jwz: Should use this for Lemacs 19.8 and above:
2569 ;;((fboundp 'subr-min-args) 2569 ;;((fboundp 'subr-min-args)
2570 ;; ...) 2570 ;; ...)
2571 ;; says hans: I guess what Jamie means is that I should use the values 2571 ;; says hans: I guess what Jamie means is that I should use the values
2572 ;; of `subr-min-args' and `subr-max-args' to construct the subr arglist 2572 ;; of `subr-min-args' and `subr-max-args' to construct the subr arglist
2573 ;; without having to look it up via parsing the docstring, e.g., 2573 ;; without having to look it up via parsing the docstring, e.g.,
2574 ;; values 1 and 2 would suggest `(arg1 &optional arg2)' as an 2574 ;; values 1 and 2 would suggest `(arg1 &optional arg2)' as an
2575 ;; argument list. However, that won't work because there is no 2575 ;; argument list. However, that won't work because there is no
2576 ;; way to distinguish a subr with args `(a &optional b &rest c)' from 2576 ;; way to distinguish a subr with args `(a &optional b &rest c)' from
2577 ;; one with args `(a &rest c)' using that mechanism. Also, the argument 2577 ;; one with args `(a &rest c)' using that mechanism. Also, the argument
2578 ;; names from the docstring are more meaningful. Hence, I'll stick with 2578 ;; names from the docstring are more meaningful. Hence, I'll stick with
2579 ;; the old way of doing things. 2579 ;; the old way of doing things.
2580 (t (let ((doc (or (ad-real-documentation subr-name t) ""))) 2580 (let ((doc (or (ad-real-documentation subr-name t) "")))
2581 (cond ((string-match "^\\(([^\)]+)\\)\n?\\'" doc) 2581 (if (not (string-match "\n\n\\((.+)\\)\\'" doc))
2582 (ad-define-subr-args 2582 ;; Signalling an error leads to bugs during bootstrapping because
2583 subr-name 2583 ;; the DOC file is not yet built (which is an error, BTW).
2584 (cdr (car (read-from-string 2584 ;; (error "The usage info is missing from the subr %s" subr-name)
2585 (downcase (match-string 1 doc)))))) 2585 '(&rest ad-subr-args)
2586 (ad-get-subr-args subr-name)) 2586 (ad-define-subr-args
2587 ;; This is actually an error. 2587 subr-name
2588 (t '(&rest ad-subr-args))))))) 2588 (cdr (car (read-from-string
2589 (downcase (match-string 1 doc))))))
2590 (ad-get-subr-args subr-name)))))
2589 2591
2590 (defun ad-docstring (definition) 2592 (defun ad-docstring (definition)
2591 "Return the unexpanded docstring of DEFINITION." 2593 "Return the unexpanded docstring of DEFINITION."
2592 (let ((docstring 2594 (let ((docstring
2593 (if (ad-compiled-p definition) 2595 (if (ad-compiled-p definition)
3981 3983
3982 (ad-start-advice) 3984 (ad-start-advice)
3983 3985
3984 (provide 'advice) 3986 (provide 'advice)
3985 3987
3988 ;;; arch-tag: 29f8c9a1-8c88-471f-95d7-e28541c6b7c0
3986 ;;; advice.el ends here 3989 ;;; advice.el ends here