diff options
| author | Richard M. Stallman | 2007-10-14 22:46:38 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2007-10-14 22:46:38 +0000 |
| commit | 15975e3514ed442cec07954afec1c5f247f5f147 (patch) | |
| tree | f8b2885c7bff389f6e26a57e6c5cee47edcdb993 | |
| parent | 0972361583b9e4a988ecd335587188111a471f26 (diff) | |
| download | emacs-15975e3514ed442cec07954afec1c5f247f5f147.tar.gz emacs-15975e3514ed442cec07954afec1c5f247f5f147.zip | |
(documentation): Advice deleted. Doc for advised functions
is now handled at C level.
(ad-stop-advice, ad-start-advice): Don't enable or disable
advice for `documentation'.
(ad-advised-definition-docstring-regexp): Var deleted.
(ad-make-advised-definition-docstring): Store orig name
as text property of string.
(ad-advised-definition-p): Check for text property of docstring.
| -rw-r--r-- | lisp/emacs-lisp/advice.el | 35 |
1 files changed, 4 insertions, 31 deletions
diff --git a/lisp/emacs-lisp/advice.el b/lisp/emacs-lisp/advice.el index d04550c187d..cabd0dd391e 100644 --- a/lisp/emacs-lisp/advice.el +++ b/lisp/emacs-lisp/advice.el | |||
| @@ -2603,17 +2603,13 @@ Like `interactive-form', but also works on pieces of advice." | |||
| 2603 | (if (ad-interactive-form definition) 1 0)) | 2603 | (if (ad-interactive-form definition) 1 0)) |
| 2604 | (cdr (cdr (ad-lambda-expression definition))))))) | 2604 | (cdr (cdr (ad-lambda-expression definition))))))) |
| 2605 | 2605 | ||
| 2606 | ;; Matches the docstring of an advised definition. | ||
| 2607 | ;; The first group of the regexp matches the function name: | ||
| 2608 | (defvar ad-advised-definition-docstring-regexp "^\\$ad-doc: \\(.+\\)\\$$") | ||
| 2609 | |||
| 2610 | (defun ad-make-advised-definition-docstring (function) | 2606 | (defun ad-make-advised-definition-docstring (function) |
| 2611 | "Make an identifying docstring for the advised definition of FUNCTION. | 2607 | "Make an identifying docstring for the advised definition of FUNCTION. |
| 2612 | Put function name into the documentation string so we can infer | 2608 | Put function name into the documentation string so we can infer |
| 2613 | the name of the advised function from the docstring. This is needed | 2609 | the name of the advised function from the docstring. This is needed |
| 2614 | to generate a proper advised docstring even if we are just given a | 2610 | to generate a proper advised docstring even if we are just given a |
| 2615 | definition (also see the defadvice for `documentation')." | 2611 | definition (see the code for `documentation')." |
| 2616 | (format "$ad-doc: %s$" (prin1-to-string function))) | 2612 | (propertize "Advice doc string" 'ad-advice-info function)) |
| 2617 | 2613 | ||
| 2618 | (defun ad-advised-definition-p (definition) | 2614 | (defun ad-advised-definition-p (definition) |
| 2619 | "Return non-nil if DEFINITION was generated from advice information." | 2615 | "Return non-nil if DEFINITION was generated from advice information." |
| @@ -2622,8 +2618,7 @@ definition (also see the defadvice for `documentation')." | |||
| 2622 | (ad-compiled-p definition)) | 2618 | (ad-compiled-p definition)) |
| 2623 | (let ((docstring (ad-docstring definition))) | 2619 | (let ((docstring (ad-docstring definition))) |
| 2624 | (and (stringp docstring) | 2620 | (and (stringp docstring) |
| 2625 | (string-match | 2621 | (get-text-property 0 'ad-advice-info docstring))))) |
| 2626 | ad-advised-definition-docstring-regexp docstring))))) | ||
| 2627 | 2622 | ||
| 2628 | (defun ad-definition-type (definition) | 2623 | (defun ad-definition-type (definition) |
| 2629 | "Return symbol that describes the type of DEFINITION." | 2624 | "Return symbol that describes the type of DEFINITION." |
| @@ -3917,24 +3912,6 @@ undone on exit of this macro." | |||
| 3917 | ;; during bootstrapping. | 3912 | ;; during bootstrapping. |
| 3918 | (ad-define-subr-args 'documentation '(function &optional raw)) | 3913 | (ad-define-subr-args 'documentation '(function &optional raw)) |
| 3919 | 3914 | ||
| 3920 | (defadvice documentation (after ad-advised-docstring first disable preact) | ||
| 3921 | "Builds an advised docstring if FUNCTION is advised." | ||
| 3922 | ;; Because we get the function name from the advised docstring | ||
| 3923 | ;; this will work for function names as well as for definitions: | ||
| 3924 | (if (and (stringp ad-return-value) | ||
| 3925 | (string-match | ||
| 3926 | ad-advised-definition-docstring-regexp ad-return-value)) | ||
| 3927 | (let ((function | ||
| 3928 | (car (read-from-string | ||
| 3929 | ad-return-value (match-beginning 1) (match-end 1))))) | ||
| 3930 | (cond ((ad-is-advised function) | ||
| 3931 | (setq ad-return-value (ad-make-advised-docstring function)) | ||
| 3932 | ;; Handle optional `raw' argument: | ||
| 3933 | (if (not (ad-get-arg 1)) | ||
| 3934 | (setq ad-return-value | ||
| 3935 | (substitute-command-keys ad-return-value)))))))) | ||
| 3936 | |||
| 3937 | |||
| 3938 | ;; @@ Starting, stopping and recovering from the advice package magic: | 3915 | ;; @@ Starting, stopping and recovering from the advice package magic: |
| 3939 | ;; =================================================================== | 3916 | ;; =================================================================== |
| 3940 | 3917 | ||
| @@ -3943,9 +3920,7 @@ undone on exit of this macro." | |||
| 3943 | (interactive) | 3920 | (interactive) |
| 3944 | ;; Advising `ad-activate-internal' means death!! | 3921 | ;; Advising `ad-activate-internal' means death!! |
| 3945 | (ad-set-advice-info 'ad-activate-internal nil) | 3922 | (ad-set-advice-info 'ad-activate-internal nil) |
| 3946 | (ad-safe-fset 'ad-activate-internal 'ad-activate) | 3923 | (ad-safe-fset 'ad-activate-internal 'ad-activate)) |
| 3947 | (ad-enable-advice 'documentation 'after 'ad-advised-docstring) | ||
| 3948 | (ad-activate 'documentation 'compile)) | ||
| 3949 | 3924 | ||
| 3950 | (defun ad-stop-advice () | 3925 | (defun ad-stop-advice () |
| 3951 | "Stop the automatic advice handling magic. | 3926 | "Stop the automatic advice handling magic. |
| @@ -3953,8 +3928,6 @@ You should only need this in case of Advice-related emergencies." | |||
| 3953 | (interactive) | 3928 | (interactive) |
| 3954 | ;; Advising `ad-activate-internal' means death!! | 3929 | ;; Advising `ad-activate-internal' means death!! |
| 3955 | (ad-set-advice-info 'ad-activate-internal nil) | 3930 | (ad-set-advice-info 'ad-activate-internal nil) |
| 3956 | (ad-disable-advice 'documentation 'after 'ad-advised-docstring) | ||
| 3957 | (ad-update 'documentation) | ||
| 3958 | (ad-safe-fset 'ad-activate-internal 'ad-activate-internal-off)) | 3931 | (ad-safe-fset 'ad-activate-internal 'ad-activate-internal-off)) |
| 3959 | 3932 | ||
| 3960 | (defun ad-recover-normality () | 3933 | (defun ad-recover-normality () |