Mercurial > hg > xemacs-beta
comparison lisp/loadhist.el @ 4540:7e01763ea656
Correct a misunderstanding of the semantics of #'return in #'symbol-file.
2008-12-27 Aidan Kehoe <kehoea@parhasard.net>
* loadhist.el (symbol-file):
Use #'defun*, not #'defun, to allow the checks for autoloaded
functions and variables to call #'return-from correctly. Use
#'return-from instead of #'return throughout the function.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sat, 27 Dec 2008 16:02:25 +0000 |
parents | 061e030e3270 |
children | e29fcfd8df5f |
comparison
equal
deleted
inserted
replaced
4539:061e030e3270 | 4540:7e01763ea656 |
---|---|
39 ;; load-history is a list of entries that look like this: | 39 ;; load-history is a list of entries that look like this: |
40 ;; ("outline" outline-regexp ... (require . wid-edit) ... (provide . outline) ...) | 40 ;; ("outline" outline-regexp ... (require . wid-edit) ... (provide . outline) ...) |
41 | 41 |
42 ;; XEmacs; this function is in subr.el in GNU, and does not deal with | 42 ;; XEmacs; this function is in subr.el in GNU, and does not deal with |
43 ;; built-in symbols. | 43 ;; built-in symbols. |
44 (defun symbol-file (sym &optional type) | 44 (defun* symbol-file (sym &optional type) |
45 "Return the input source from which SYM was loaded. | 45 "Return the input source from which SYM was loaded. |
46 This is a file name, or nil if the source was a buffer with no associated file. | 46 This is a file name, or nil if the source was a buffer with no associated file. |
47 | 47 |
48 If TYPE is nil or omitted, any kind of definition is acceptable. | 48 If TYPE is nil or omitted, any kind of definition is acceptable. |
49 If TYPE is `defun', then function, subr, special form or macro definitions | 49 If TYPE is `defun', then function, subr, special form or macro definitions |
61 (and (fboundp sym) (symbol-function sym))))) | 61 (and (fboundp sym) (symbol-function sym))))) |
62 (or (and (or (null type) (eq 'defvar type)) | 62 (or (and (or (null type) (eq 'defvar type)) |
63 (eq (fifth autoload-cons) 'keymap)) | 63 (eq (fifth autoload-cons) 'keymap)) |
64 (and (or (null type) (eq 'defun type)) | 64 (and (or (null type) (eq 'defun type)) |
65 (memq (fifth autoload-cons) '(nil macro))))) | 65 (memq (fifth autoload-cons) '(nil macro))))) |
66 (return (locate-library (second autoload-cons)))) | 66 (return-from symbol-file (locate-library (second autoload-cons)))) |
67 ((eq 'defvar type) | 67 ((eq 'defvar type) |
68 ;; Load history entries corresponding to variables are just | 68 ;; Load history entries corresponding to variables are just |
69 ;; symbols. | 69 ;; symbols. |
70 (dolist (entry load-history) | 70 (dolist (entry load-history) |
71 (when (memq sym (cdr entry)) | 71 (when (memq sym (cdr entry)) |
72 (return (car entry))))) | 72 (return-from symbol-file (car entry))))) |
73 ((not (null type)) | 73 ((not (null type)) |
74 ;; Non-variables have the type stored as the car of the entry. | 74 ;; Non-variables have the type stored as the car of the entry. |
75 (dolist (entry load-history) | 75 (dolist (entry load-history) |
76 (when (and (setq symbol-details (rassq sym (cdr entry))) | 76 (when (and (setq symbol-details (rassq sym (cdr entry))) |
77 (eq type (car symbol-details))) | 77 (eq type (car symbol-details))) |
78 (return (car entry))))) | 78 (return-from symbol-file (car entry))))) |
79 (t | 79 (t |
80 ;; If TYPE hasn't been specified, we need to check both for | 80 ;; If TYPE hasn't been specified, we need to check both for |
81 ;; variables and other symbols. | 81 ;; variables and other symbols. |
82 (dolist (entry load-history) | 82 (dolist (entry load-history) |
83 (when (or (memq sym (cdr entry)) | 83 (when (or (memq sym (cdr entry)) |
84 (rassq sym (cdr entry))) | 84 (rassq sym (cdr entry))) |
85 (return (car entry)))))) | 85 (return-from symbol-file (car entry)))))) |
86 (when (setq built-in-file (built-in-symbol-file sym type)) | 86 (when (setq built-in-file (built-in-symbol-file sym type)) |
87 (if (equal built-in-file (file-truename built-in-file)) | 87 (if (equal built-in-file (file-truename built-in-file)) |
88 ;; Probably a full path name: | 88 ;; Probably a full path name: |
89 built-in-file | 89 built-in-file |
90 ;; This is a bit heuristic, but shouldn't realistically be a | 90 ;; This is a bit heuristic, but shouldn't realistically be a |