34
34
Visit the library in a buffer, and return a cons cell (BUFFER . POSITION),
35
35
or just (BUFFER . nil) if the definition can't be found in the file.
36
36
37
- If TYPE is nil, look for a function definition.
38
- Otherwise, TYPE specifies the kind of definition,
39
- and it is interpreted via `find-function-regexp-alist' .
37
+ If TYPE is nil, look for a function definition,
38
+ otherwise, TYPE specifies the kind of definition.
39
+ If SYMBOL has a property `definition-type' ,
40
+ the property value is used instead of TYPE.
41
+ TYPE is interpreted via `find-function-regexp-alist' .
42
+
40
43
The search is done in the source for library LIBRARY."
41
44
(if (null library)
42
45
(error " Don't know where `%s' is defined " symbol))
43
46
; ; Some functions are defined as part of the construct
44
47
; ; that defines something else.
45
48
(while (and (symbolp symbol) (get symbol 'definition-name ))
46
49
(setq symbol (get symbol 'definition-name )))
50
+ (setq type (or (get symbol 'definition-type )
51
+ type))
47
52
(if (string-match " \\ `src/\\ (.*\\ .\\ (c\\ |m\\ )\\ )\\ '" library)
48
53
(find-function-C-source symbol (match-string 1 library) type)
49
54
(when (string-match " \\ .el\\ (c\\ )\\ '" library)
@@ -53,17 +58,17 @@ The search is done in the source for library LIBRARY."
53
58
(when (string-match " \\ .emacs\\ (.el\\ )\\ '" library)
54
59
(setq library (substring library 0 (match-beginning 1 ))))
55
60
(let* ((filename (find-library-name library))
56
- (regexp-symbol (cdr (assq type find-function-regexp-alist))))
61
+ (regexp-symbol (cdr (assq type find-function-regexp-alist))))
57
62
(with-current-buffer (find-file-noselect filename)
58
- (let ((regexp (if (functionp regexp-symbol) regexp-symbol
63
+ (let ((regexp (if (functionp regexp-symbol) regexp-symbol
59
64
(format (symbol-value regexp-symbol)
60
65
; ; Entry for ` (backquote) macro in loaddefs.el,
61
66
; ; (defalias (quote \`)..., has a \ but
62
67
; ; (symbol-name symbol) doesn't. Add an
63
68
; ; optional \ to catch this.
64
69
(concat " \\\\ ?"
65
70
(regexp-quote (symbol-name symbol))))))
66
- (case-fold-search ))
71
+ (case-fold-search ))
67
72
(el-patch-wrap 1 0
68
73
(save-excursion
69
74
(save-restriction
@@ -73,14 +78,15 @@ The search is done in the source for library LIBRARY."
73
78
(if (if (functionp regexp)
74
79
(funcall regexp symbol)
75
80
(or (re-search-forward regexp nil t )
76
- ; ; `regexp' matches definitions using known forms like
77
- ; ; `defun' , or `defvar' . But some functions/variables
78
- ; ; are defined using special macros (or functions), so
79
- ; ; if `regexp' can't find the definition, we look for
80
- ; ; something of the form "(SOMETHING <symbol> ...)".
81
- ; ; This fails to distinguish function definitions from
82
- ; ; variable declarations (or even uses thereof), but is
83
- ; ; a good pragmatic fallback.
81
+ ; ; `regexp' matches definitions using known forms
82
+ ; ; like `defun' , or `defvar' . But some
83
+ ; ; functions/variables are defined using special
84
+ ; ; macros (or functions), so if `regexp' can't find
85
+ ; ; the definition, we look for something of the
86
+ ; ; form "(SOMETHING <symbol> ...)". This fails to
87
+ ; ; distinguish function definitions from variable
88
+ ; ; declarations (or even uses thereof), but is a
89
+ ; ; good pragmatic fallback.
84
90
(re-search-forward
85
91
(concat " ^([^ ]+" find-function-space-re " ['(]?"
86
92
(regexp-quote (symbol-name symbol))
0 commit comments