Mercurial > emacs
annotate lisp/emacs-lisp/find-func.el @ 103398:8cc2b1e9767f
Re-generated.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Fri, 12 Jun 2009 12:34:00 +0000 |
parents | 9bfebe85710d |
children | 1d1d5d9bd884 |
rev | line source |
---|---|
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
1 ;;; find-func.el --- find the definition of the Emacs Lisp function near point |
20183 | 2 |
64751
5b1a238fcbb4
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64510
diff
changeset
|
3 ;; Copyright (C) 1997, 1999, 2001, 2002, 2003, 2004, |
100908 | 4 ;; 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. |
20183 | 5 |
6 ;; Author: Jens Petersen <petersen@kurims.kyoto-u.ac.jp> | |
7 ;; Maintainer: petersen@kurims.kyoto-u.ac.jp | |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
8 ;; Keywords: emacs-lisp, functions, variables |
20183 | 9 ;; Created: 97/07/25 |
10 | |
11 ;; This file is part of GNU Emacs. | |
12 | |
94655
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94181
diff
changeset
|
13 ;; GNU Emacs is free software: you can redistribute it and/or modify |
20183 | 14 ;; it under the terms of the GNU General Public License as published by |
94655
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94181
diff
changeset
|
15 ;; the Free Software Foundation, either version 3 of the License, or |
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94181
diff
changeset
|
16 ;; (at your option) any later version. |
20183 | 17 |
18 ;; GNU Emacs is distributed in the hope that it will be useful, | |
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 ;; GNU General Public License for more details. | |
22 | |
23 ;; You should have received a copy of the GNU General Public License | |
94655
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94181
diff
changeset
|
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
20183 | 25 |
26 ;;; Commentary: | |
27 ;; | |
28 ;; The funniest thing about this is that I can't imagine why a package | |
29 ;; so obviously useful as this hasn't been written before!! | |
30 ;; ;;; find-func | |
22759
be3e1a724828
(find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents:
22641
diff
changeset
|
31 ;; (find-function-setup-keys) |
be3e1a724828
(find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents:
22641
diff
changeset
|
32 ;; |
be3e1a724828
(find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents:
22641
diff
changeset
|
33 ;; or just: |
be3e1a724828
(find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents:
22641
diff
changeset
|
34 ;; |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
35 ;; (load "find-func") |
20183 | 36 ;; |
22759
be3e1a724828
(find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents:
22641
diff
changeset
|
37 ;; if you don't like the given keybindings and away you go! It does |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
38 ;; pretty much what you would expect, putting the cursor at the |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
39 ;; definition of the function or variable at point. |
20183 | 40 ;; |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
41 ;; The code started out from `describe-function', `describe-key' |
20183 | 42 ;; ("help.el") and `fff-find-loaded-emacs-lisp-function' (Noah Friedman's |
43 ;; "fff.el"). | |
44 | |
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
33198
diff
changeset
|
45 ;;; Code: |
20183 | 46 |
47 ;;; User variables: | |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
48 |
20962 | 49 (defgroup find-function nil |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
50 "Finds the definition of the Emacs Lisp symbol near point." |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
51 ;; :prefix "find-function" |
20962 | 52 :group 'lisp) |
20183 | 53 |
45326
892ea515fb3a
(find-function-search-for-symbol): Find funs defined with defun-cvs-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45257
diff
changeset
|
54 (defconst find-function-space-re "\\(?:\\s-\\|\n\\|;.*\n\\)+") |
892ea515fb3a
(find-function-search-for-symbol): Find funs defined with defun-cvs-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45257
diff
changeset
|
55 |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
56 (defcustom find-function-regexp |
24013 | 57 ;; Match things like (defun foo ...), (defmacro foo ...), |
58 ;; (define-skeleton foo ...), (define-generic-mode 'foo ...), | |
26558
2daba92c1033
(find-function-regexp): Use `define-minor-mode' after easy-menu
Dave Love <fx@gnu.org>
parents:
25424
diff
changeset
|
59 ;; (define-derived-mode foo ...), (define-minor-mode foo) |
45326
892ea515fb3a
(find-function-search-for-symbol): Find funs defined with defun-cvs-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45257
diff
changeset
|
60 (concat |
892ea515fb3a
(find-function-search-for-symbol): Find funs defined with defun-cvs-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45257
diff
changeset
|
61 "^\\s-*(\\(def\\(ine-skeleton\\|ine-generic-mode\\|ine-derived-mode\\|\ |
67294 | 62 ine\\(?:-global\\)?-minor-mode\\|ine-compilation-mode\\|un-cvs-mode\\|\ |
73208
4a95d08e5126
(find-function-regexp): Don't match "define-button-type".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
72079
diff
changeset
|
63 foo\\|[^icfgv]\\(\\w\\|\\s_\\)+\\*?\\)\\|easy-mmode-define-[a-z-]+\\|easy-menu-define\\|\ |
67294 | 64 menu-bar-make-toggle\\)" |
60628
532be1846a28
(find-function-regexp): Add defun-emitting macro `menu-bar-make-toggle'.
Juri Linkov <juri@jurta.org>
parents:
59996
diff
changeset
|
65 find-function-space-re |
45326
892ea515fb3a
(find-function-search-for-symbol): Find funs defined with defun-cvs-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45257
diff
changeset
|
66 "\\('\\|\(quote \\)?%s\\(\\s-\\|$\\|\(\\|\)\\)") |
24013 | 67 "The regexp used by `find-function' to search for a function definition. |
68 Note it must contain a `%s' at the place where `format' | |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
69 should insert the function name. The default value avoids `defconst', |
58261
212733e53508
(find-function-regexp): Optimize `define-minor-mode'. Add `defun-cvs-mode'.
Juri Linkov <juri@jurta.org>
parents:
55231
diff
changeset
|
70 `defgroup', `defvar', `defface'. |
20183 | 71 |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
72 Please send improvements and fixes to the maintainer." |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
73 :type 'regexp |
22759
be3e1a724828
(find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents:
22641
diff
changeset
|
74 :group 'find-function |
26558
2daba92c1033
(find-function-regexp): Use `define-minor-mode' after easy-menu
Dave Love <fx@gnu.org>
parents:
25424
diff
changeset
|
75 :version "21.1") |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
76 |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
77 (defcustom find-variable-regexp |
67294 | 78 (concat |
79 "^\\s-*(\\(def[^fumag]\\(\\w\\|\\s_\\)+\\*?\\|\ | |
80 easy-mmode-def\\(map\\|syntax\\)\\|easy-menu-define\\)" | |
81 find-function-space-re | |
82 "%s\\(\\s-\\|$\\)") | |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
83 "The regexp used by `find-variable' to search for a variable definition. |
59367 | 84 Note it must contain a `%s' at the place where `format' |
85 should insert the variable name. The default value | |
59330
03306a6707b9
(find-variable-regexp): Avoid defface.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59122
diff
changeset
|
86 avoids `defun', `defmacro', `defalias', `defadvice', `defgroup', `defface'. |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
87 |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
88 Please send improvements and fixes to the maintainer." |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
89 :type 'regexp |
22759
be3e1a724828
(find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents:
22641
diff
changeset
|
90 :group 'find-function |
32226
2af46c6c8bde
(find-function-regexp): Remove spurion.
Dave Love <fx@gnu.org>
parents:
26593
diff
changeset
|
91 :version "21.1") |
20183 | 92 |
59367 | 93 (defcustom find-face-regexp |
94 (concat"^\\s-*(defface" find-function-space-re "%s\\(\\s-\\|$\\)") | |
95 "The regexp used by `find-face' to search for a face definition. | |
96 Note it must contain a `%s' at the place where `format' | |
97 should insert the face name. | |
98 | |
99 Please send improvements and fixes to the maintainer." | |
100 :type 'regexp | |
101 :group 'find-function | |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
59404
diff
changeset
|
102 :version "22.1") |
59367 | 103 |
104 (defvar find-function-regexp-alist | |
105 '((nil . find-function-regexp) | |
106 (defvar . find-variable-regexp) | |
107 (defface . find-face-regexp)) | |
108 "Alist mapping definition types into regexp variables. | |
109 Each regexp variable's value should actually be a format string | |
110 to be used to substitute the desired symbol name into the regexp.") | |
111 (put 'find-function-regexp-alist 'risky-local-variable t) | |
112 | |
20962 | 113 (defcustom find-function-source-path nil |
24013 | 114 "The default list of directories where `find-function' searches. |
20183 | 115 |
24013 | 116 If this variable is nil then `find-function' searches `load-path' by |
20962 | 117 default." |
118 :type '(repeat directory) | |
119 :group 'find-function) | |
20183 | 120 |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
121 (defcustom find-function-recenter-line 1 |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
122 "The window line-number from which to start displaying a symbol definition. |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
123 A value of nil implies center the beginning of the definition. |
47298
c6dddb2746ee
* emacs-lisp/cl-indent.el (extended-loop-p): Doc fix.
John Paul Wallington <jpw@pobox.com>
parents:
47255
diff
changeset
|
124 See `find-function' and `find-variable'." |
c6dddb2746ee
* emacs-lisp/cl-indent.el (extended-loop-p): Doc fix.
John Paul Wallington <jpw@pobox.com>
parents:
47255
diff
changeset
|
125 :type '(choice (const :tag "Center" nil) |
c6dddb2746ee
* emacs-lisp/cl-indent.el (extended-loop-p): Doc fix.
John Paul Wallington <jpw@pobox.com>
parents:
47255
diff
changeset
|
126 integer) |
22759
be3e1a724828
(find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents:
22641
diff
changeset
|
127 :group 'find-function |
23100
043247d0ced9
Fix :version tags to have a string value, not a float.
Andreas Schwab <schwab@suse.de>
parents:
22867
diff
changeset
|
128 :version "20.3") |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
129 |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
130 (defcustom find-function-after-hook nil |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
131 "Hook run after finding symbol definition. |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
132 |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
133 See the functions `find-function' and `find-variable'." |
79573
d5a339d25938
(find-function-after-hook): Add :type.
Richard M. Stallman <rms@gnu.org>
parents:
79289
diff
changeset
|
134 :type 'hook |
22759
be3e1a724828
(find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents:
22641
diff
changeset
|
135 :group 'find-function |
23100
043247d0ced9
Fix :version tags to have a string value, not a float.
Andreas Schwab <schwab@suse.de>
parents:
22867
diff
changeset
|
136 :version "20.3") |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
137 |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
138 ;;; Functions: |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
139 |
47345
8268e926d8e9
(find-library-suffixes, find-library-name)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47298
diff
changeset
|
140 (defun find-library-suffixes () |
8268e926d8e9
(find-library-suffixes, find-library-name)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47298
diff
changeset
|
141 (let ((suffixes nil)) |
69169
10a4ff23378e
(find-library-suffixes): Use `get-load-suffixes' instead of `load-suffixes'.
Luc Teirlinck <teirllm@auburn.edu>
parents:
68648
diff
changeset
|
142 (dolist (suffix (get-load-suffixes) (nreverse suffixes)) |
47345
8268e926d8e9
(find-library-suffixes, find-library-name)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47298
diff
changeset
|
143 (unless (string-match "elc" suffix) (push suffix suffixes))))) |
8268e926d8e9
(find-library-suffixes, find-library-name)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47298
diff
changeset
|
144 |
8268e926d8e9
(find-library-suffixes, find-library-name)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47298
diff
changeset
|
145 (defun find-library-name (library) |
101934
9bfebe85710d
(find-library-name, find-library): Doc fixes.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
146 "Return the absolute file name of the Emacs Lisp source of LIBRARY. |
9bfebe85710d
(find-library-name, find-library): Doc fixes.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
147 LIBRARY should be a string (the name of the library)." |
74117
db85df5747ae
(find-library-name): Don't strip ".el" from library name (reverts change
Romain Francoise <romain@orebokech.com>
parents:
73648
diff
changeset
|
148 ;; If the library is byte-compiled, try to find a source library by |
db85df5747ae
(find-library-name): Don't strip ".el" from library name (reverts change
Romain Francoise <romain@orebokech.com>
parents:
73648
diff
changeset
|
149 ;; the same name. |
db85df5747ae
(find-library-name): Don't strip ".el" from library name (reverts change
Romain Francoise <romain@orebokech.com>
parents:
73648
diff
changeset
|
150 (if (string-match "\\.el\\(c\\(\\..*\\)?\\)\\'" library) |
47610
8a24f7edde82
(find-library-name): Correctly find "f.el.gz" from "f.elc" or "f.elc.gz".
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47447
diff
changeset
|
151 (setq library (replace-match "" t t library))) |
87095
8f23eba1a316
Make `find-function' prefer ".el" over "" to fix a bug (see emacs-devel)
Deepak Goel <deego@gnufans.org>
parents:
85832
diff
changeset
|
152 (or |
8f23eba1a316
Make `find-function' prefer ".el" over "" to fix a bug (see emacs-devel)
Deepak Goel <deego@gnufans.org>
parents:
85832
diff
changeset
|
153 (locate-file library |
8f23eba1a316
Make `find-function' prefer ".el" over "" to fix a bug (see emacs-devel)
Deepak Goel <deego@gnufans.org>
parents:
85832
diff
changeset
|
154 (or find-function-source-path load-path) |
8f23eba1a316
Make `find-function' prefer ".el" over "" to fix a bug (see emacs-devel)
Deepak Goel <deego@gnufans.org>
parents:
85832
diff
changeset
|
155 (find-library-suffixes)) |
8f23eba1a316
Make `find-function' prefer ".el" over "" to fix a bug (see emacs-devel)
Deepak Goel <deego@gnufans.org>
parents:
85832
diff
changeset
|
156 (locate-file library |
8f23eba1a316
Make `find-function' prefer ".el" over "" to fix a bug (see emacs-devel)
Deepak Goel <deego@gnufans.org>
parents:
85832
diff
changeset
|
157 (or find-function-source-path load-path) |
8f23eba1a316
Make `find-function' prefer ".el" over "" to fix a bug (see emacs-devel)
Deepak Goel <deego@gnufans.org>
parents:
85832
diff
changeset
|
158 load-file-rep-suffixes) |
8f23eba1a316
Make `find-function' prefer ".el" over "" to fix a bug (see emacs-devel)
Deepak Goel <deego@gnufans.org>
parents:
85832
diff
changeset
|
159 (error "Can't find library %s" library))) |
47345
8268e926d8e9
(find-library-suffixes, find-library-name)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47298
diff
changeset
|
160 |
55231
7fc34677dcb8
(find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
161 (defvar find-function-C-source-directory |
7fc34677dcb8
(find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
162 (let ((dir (expand-file-name "src" source-directory))) |
7fc34677dcb8
(find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
163 (when (and (file-directory-p dir) (file-readable-p dir)) |
7fc34677dcb8
(find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
164 dir)) |
7fc34677dcb8
(find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
165 "Directory where the C source files of Emacs can be found. |
7fc34677dcb8
(find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
166 If nil, do not try to find the source code of functions and variables |
7fc34677dcb8
(find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
167 defined in C.") |
7fc34677dcb8
(find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
168 |
99591
1d05897d32a7
(find-function-advised-original): New.
Glenn Morris <rgm@gnu.org>
parents:
97060
diff
changeset
|
169 (declare-function ad-get-advice-info "advice" (function)) |
1d05897d32a7
(find-function-advised-original): New.
Glenn Morris <rgm@gnu.org>
parents:
97060
diff
changeset
|
170 |
1d05897d32a7
(find-function-advised-original): New.
Glenn Morris <rgm@gnu.org>
parents:
97060
diff
changeset
|
171 (defun find-function-advised-original (func) |
1d05897d32a7
(find-function-advised-original): New.
Glenn Morris <rgm@gnu.org>
parents:
97060
diff
changeset
|
172 "Return the original function symbol of an advised function FUNC. |
1d05897d32a7
(find-function-advised-original): New.
Glenn Morris <rgm@gnu.org>
parents:
97060
diff
changeset
|
173 If FUNC is not the symbol of an advised function, just returns FUNC." |
1d05897d32a7
(find-function-advised-original): New.
Glenn Morris <rgm@gnu.org>
parents:
97060
diff
changeset
|
174 (or (and (symbolp func) |
1d05897d32a7
(find-function-advised-original): New.
Glenn Morris <rgm@gnu.org>
parents:
97060
diff
changeset
|
175 (featurep 'advice) |
1d05897d32a7
(find-function-advised-original): New.
Glenn Morris <rgm@gnu.org>
parents:
97060
diff
changeset
|
176 (let ((ofunc (cdr (assq 'origname (ad-get-advice-info func))))) |
1d05897d32a7
(find-function-advised-original): New.
Glenn Morris <rgm@gnu.org>
parents:
97060
diff
changeset
|
177 (and (fboundp ofunc) ofunc))) |
1d05897d32a7
(find-function-advised-original): New.
Glenn Morris <rgm@gnu.org>
parents:
97060
diff
changeset
|
178 func)) |
1d05897d32a7
(find-function-advised-original): New.
Glenn Morris <rgm@gnu.org>
parents:
97060
diff
changeset
|
179 |
59367 | 180 (defun find-function-C-source (fun-or-var file type) |
68320
a2ccca4b13a3
(find-definition-noselect, find-variable-noselect): Search variables in
Eli Zaretskii <eliz@gnu.org>
parents:
68066
diff
changeset
|
181 "Find the source location where FUN-OR-VAR is defined in FILE. |
59367 | 182 TYPE should be nil to find a function, or `defvar' to find a variable." |
55231
7fc34677dcb8
(find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
183 (unless find-function-C-source-directory |
7fc34677dcb8
(find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
184 (setq find-function-C-source-directory |
7fc34677dcb8
(find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
185 (read-directory-name "Emacs C source dir: " nil nil t))) |
7fc34677dcb8
(find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
186 (setq file (expand-file-name file find-function-C-source-directory)) |
7fc34677dcb8
(find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
187 (unless (file-readable-p file) |
7fc34677dcb8
(find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
188 (error "The C source file %s is not available" |
7fc34677dcb8
(find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
189 (file-name-nondirectory file))) |
59367 | 190 (unless type |
99591
1d05897d32a7
(find-function-advised-original): New.
Glenn Morris <rgm@gnu.org>
parents:
97060
diff
changeset
|
191 ;; Either or both an alias and its target might be advised. |
1d05897d32a7
(find-function-advised-original): New.
Glenn Morris <rgm@gnu.org>
parents:
97060
diff
changeset
|
192 (setq fun-or-var (find-function-advised-original |
1d05897d32a7
(find-function-advised-original): New.
Glenn Morris <rgm@gnu.org>
parents:
97060
diff
changeset
|
193 (indirect-function |
1d05897d32a7
(find-function-advised-original): New.
Glenn Morris <rgm@gnu.org>
parents:
97060
diff
changeset
|
194 (find-function-advised-original fun-or-var))))) |
55231
7fc34677dcb8
(find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
195 (with-current-buffer (find-file-noselect file) |
7fc34677dcb8
(find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
196 (goto-char (point-min)) |
7fc34677dcb8
(find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
197 (unless (re-search-forward |
59367 | 198 (if type |
55231
7fc34677dcb8
(find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
199 (concat "DEFVAR[A-Z_]*[ \t\n]*([ \t\n]*\"" |
7fc34677dcb8
(find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
200 (regexp-quote (symbol-name fun-or-var)) |
7fc34677dcb8
(find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
201 "\"") |
7fc34677dcb8
(find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
202 (concat "DEFUN[ \t\n]*([ \t\n]*\"" |
7fc34677dcb8
(find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
203 (regexp-quote (subr-name fun-or-var)) |
7fc34677dcb8
(find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
204 "\"")) |
7fc34677dcb8
(find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
205 nil t) |
7fc34677dcb8
(find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
206 (error "Can't find source for %s" fun-or-var)) |
7fc34677dcb8
(find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
207 (cons (current-buffer) (match-beginning 0)))) |
7fc34677dcb8
(find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
208 |
47345
8268e926d8e9
(find-library-suffixes, find-library-name)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47298
diff
changeset
|
209 ;;;###autoload |
8268e926d8e9
(find-library-suffixes, find-library-name)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47298
diff
changeset
|
210 (defun find-library (library) |
101934
9bfebe85710d
(find-library-name, find-library): Doc fixes.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
211 "Find the Emacs Lisp source of LIBRARY. |
9bfebe85710d
(find-library-name, find-library): Doc fixes.
Chong Yidong <cyd@stupidchicken.com>
parents:
100908
diff
changeset
|
212 LIBRARY should be a string (the name of the library)." |
47345
8268e926d8e9
(find-library-suffixes, find-library-name)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47298
diff
changeset
|
213 (interactive |
94181
959a3833d833
* files.el (locate-file-completion-table): Rename from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
88060
diff
changeset
|
214 (let* ((dirs (or find-function-source-path load-path)) |
959a3833d833
* files.el (locate-file-completion-table): Rename from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
88060
diff
changeset
|
215 (suffixes (find-library-suffixes)) |
79289
a6f04138250e
Default argument for find-library
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
78217
diff
changeset
|
216 (def (if (eq (function-called-at-point) 'require) |
87969
08990d4db481
(find-library): Wrap search for library name in condition-case
Martin Rudalics <rudalics@gmx.at>
parents:
87649
diff
changeset
|
217 ;; `function-called-at-point' may return 'require |
08990d4db481
(find-library): Wrap search for library name in condition-case
Martin Rudalics <rudalics@gmx.at>
parents:
87649
diff
changeset
|
218 ;; with `point' anywhere on this line. So wrap the |
08990d4db481
(find-library): Wrap search for library name in condition-case
Martin Rudalics <rudalics@gmx.at>
parents:
87649
diff
changeset
|
219 ;; `save-excursion' below in a `condition-case' to |
08990d4db481
(find-library): Wrap search for library name in condition-case
Martin Rudalics <rudalics@gmx.at>
parents:
87649
diff
changeset
|
220 ;; avoid reporting a scan-error here. |
08990d4db481
(find-library): Wrap search for library name in condition-case
Martin Rudalics <rudalics@gmx.at>
parents:
87649
diff
changeset
|
221 (condition-case nil |
08990d4db481
(find-library): Wrap search for library name in condition-case
Martin Rudalics <rudalics@gmx.at>
parents:
87649
diff
changeset
|
222 (save-excursion |
08990d4db481
(find-library): Wrap search for library name in condition-case
Martin Rudalics <rudalics@gmx.at>
parents:
87649
diff
changeset
|
223 (backward-up-list) |
08990d4db481
(find-library): Wrap search for library name in condition-case
Martin Rudalics <rudalics@gmx.at>
parents:
87649
diff
changeset
|
224 (forward-char) |
08990d4db481
(find-library): Wrap search for library name in condition-case
Martin Rudalics <rudalics@gmx.at>
parents:
87649
diff
changeset
|
225 (forward-sexp 2) |
08990d4db481
(find-library): Wrap search for library name in condition-case
Martin Rudalics <rudalics@gmx.at>
parents:
87649
diff
changeset
|
226 (thing-at-point 'symbol)) |
08990d4db481
(find-library): Wrap search for library name in condition-case
Martin Rudalics <rudalics@gmx.at>
parents:
87649
diff
changeset
|
227 (error nil)) |
79289
a6f04138250e
Default argument for find-library
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
78217
diff
changeset
|
228 (thing-at-point 'symbol)))) |
a6f04138250e
Default argument for find-library
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
78217
diff
changeset
|
229 (when def |
94181
959a3833d833
* files.el (locate-file-completion-table): Rename from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
88060
diff
changeset
|
230 (setq def (and (locate-file-completion-table |
959a3833d833
* files.el (locate-file-completion-table): Rename from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
88060
diff
changeset
|
231 dirs suffixes def nil 'lambda) |
959a3833d833
* files.el (locate-file-completion-table): Rename from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
88060
diff
changeset
|
232 def))) |
79289
a6f04138250e
Default argument for find-library
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
78217
diff
changeset
|
233 (list |
a6f04138250e
Default argument for find-library
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
78217
diff
changeset
|
234 (completing-read (if def (format "Library name (default %s): " def) |
a6f04138250e
Default argument for find-library
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
78217
diff
changeset
|
235 "Library name: ") |
94181
959a3833d833
* files.el (locate-file-completion-table): Rename from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
88060
diff
changeset
|
236 (apply-partially 'locate-file-completion-table |
959a3833d833
* files.el (locate-file-completion-table): Rename from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
88060
diff
changeset
|
237 dirs suffixes) |
959a3833d833
* files.el (locate-file-completion-table): Rename from
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
88060
diff
changeset
|
238 nil nil nil nil def)))) |
47345
8268e926d8e9
(find-library-suffixes, find-library-name)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47298
diff
changeset
|
239 (let ((buf (find-file-noselect (find-library-name library)))) |
8268e926d8e9
(find-library-suffixes, find-library-name)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47298
diff
changeset
|
240 (condition-case nil (switch-to-buffer buf) (error (pop-to-buffer buf))))) |
8268e926d8e9
(find-library-suffixes, find-library-name)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
47298
diff
changeset
|
241 |
45190
9c3195b605f7
(find-function-search-for-symbol): Add autoload cookie.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
45150
diff
changeset
|
242 ;;;###autoload |
59367 | 243 (defun find-function-search-for-symbol (symbol type library) |
244 "Search for SYMBOL's definition of type TYPE in LIBRARY. | |
71851
fcc45339ef47
(find-function-search-for-symbol):
Richard M. Stallman <rms@gnu.org>
parents:
70013
diff
changeset
|
245 Visit the library in a buffer, and return a cons cell (BUFFER . POSITION), |
fcc45339ef47
(find-function-search-for-symbol):
Richard M. Stallman <rms@gnu.org>
parents:
70013
diff
changeset
|
246 or just (BUFFER . nil) if the definition can't be found in the file. |
fcc45339ef47
(find-function-search-for-symbol):
Richard M. Stallman <rms@gnu.org>
parents:
70013
diff
changeset
|
247 |
59367 | 248 If TYPE is nil, look for a function definition. |
249 Otherwise, TYPE specifies the kind of definition, | |
250 and it is interpreted via `find-function-regexp-alist'. | |
251 The search is done in the source for library LIBRARY." | |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
252 (if (null library) |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
253 (error "Don't know where `%s' is defined" symbol)) |
46874
cbd462ecc9ad
(find-function-search-for-symbol): Obey `definition-name' properties.
Richard M. Stallman <rms@gnu.org>
parents:
45326
diff
changeset
|
254 ;; Some functions are defined as part of the construct |
cbd462ecc9ad
(find-function-search-for-symbol): Obey `definition-name' properties.
Richard M. Stallman <rms@gnu.org>
parents:
45326
diff
changeset
|
255 ;; that defines something else. |
55231
7fc34677dcb8
(find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
256 (while (and (symbolp symbol) (get symbol 'definition-name)) |
46874
cbd462ecc9ad
(find-function-search-for-symbol): Obey `definition-name' properties.
Richard M. Stallman <rms@gnu.org>
parents:
45326
diff
changeset
|
257 (setq symbol (get symbol 'definition-name))) |
97060
a5fc76bb12d1
apply patch from Seiji Zenitani to find doc strings in ns*.m files
Adrian Robert <Adrian.B.Robert@gmail.com>
parents:
94655
diff
changeset
|
258 (if (string-match "\\`src/\\(.*\\.\\(c\\|m\\)\\)\\'" library) |
59367 | 259 (find-function-C-source symbol (match-string 1 library) type) |
88060
54e63ce02006
(find-function-search-for-symbol): Strip extension
Martin Rudalics <rudalics@gmx.at>
parents:
87969
diff
changeset
|
260 (when (string-match "\\.el\\(c\\)\\'" library) |
54e63ce02006
(find-function-search-for-symbol): Strip extension
Martin Rudalics <rudalics@gmx.at>
parents:
87969
diff
changeset
|
261 (setq library (substring library 0 (match-beginning 1)))) |
54e63ce02006
(find-function-search-for-symbol): Strip extension
Martin Rudalics <rudalics@gmx.at>
parents:
87969
diff
changeset
|
262 ;; Strip extension from .emacs.el to make sure symbol is searched in |
54e63ce02006
(find-function-search-for-symbol): Strip extension
Martin Rudalics <rudalics@gmx.at>
parents:
87969
diff
changeset
|
263 ;; .emacs too. |
54e63ce02006
(find-function-search-for-symbol): Strip extension
Martin Rudalics <rudalics@gmx.at>
parents:
87969
diff
changeset
|
264 (when (string-match "\\.emacs\\(.el\\)" library) |
54e63ce02006
(find-function-search-for-symbol): Strip extension
Martin Rudalics <rudalics@gmx.at>
parents:
87969
diff
changeset
|
265 (setq library (substring library 0 (match-beginning 1)))) |
59367 | 266 (let* ((filename (find-library-name library)) |
267 (regexp-symbol (cdr (assq type find-function-regexp-alist)))) | |
23862
d0e08cc0aa3d
(find-function-search-for-symbol):
Dave Love <fx@gnu.org>
parents:
23737
diff
changeset
|
268 (with-current-buffer (find-file-noselect filename) |
59367 | 269 (let ((regexp (format (symbol-value regexp-symbol) |
72079
811ddd9e59a1
(find-function-search-for-symbol): Expand comment.
Nick Roberts <nickrob@snap.net.nz>
parents:
72076
diff
changeset
|
270 ;; Entry for ` (backquote) macro in loaddefs.el, |
811ddd9e59a1
(find-function-search-for-symbol): Expand comment.
Nick Roberts <nickrob@snap.net.nz>
parents:
72076
diff
changeset
|
271 ;; (defalias (quote \`)..., has a \ but |
811ddd9e59a1
(find-function-search-for-symbol): Expand comment.
Nick Roberts <nickrob@snap.net.nz>
parents:
72076
diff
changeset
|
272 ;; (symbol-name symbol) doesn't. Add an |
811ddd9e59a1
(find-function-search-for-symbol): Expand comment.
Nick Roberts <nickrob@snap.net.nz>
parents:
72076
diff
changeset
|
273 ;; optional \ to catch this. |
72076
3272294d88e3
(find-function-search-for-symbol): Handle "C-h f `".
Nick Roberts <nickrob@snap.net.nz>
parents:
71851
diff
changeset
|
274 (concat "\\\\?" |
3272294d88e3
(find-function-search-for-symbol): Handle "C-h f `".
Nick Roberts <nickrob@snap.net.nz>
parents:
71851
diff
changeset
|
275 (regexp-quote (symbol-name symbol))))) |
45120
254bce531056
(find-function-search-for-symbol): Bind case-fold-search when searching.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
40480
diff
changeset
|
276 (case-fold-search)) |
45150
4a2bcce6b13a
(find-function-search-for-symbol): Use with-syntax-table.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
45120
diff
changeset
|
277 (with-syntax-table emacs-lisp-mode-syntax-table |
4a2bcce6b13a
(find-function-search-for-symbol): Use with-syntax-table.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
45120
diff
changeset
|
278 (goto-char (point-min)) |
4a2bcce6b13a
(find-function-search-for-symbol): Use with-syntax-table.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
45120
diff
changeset
|
279 (if (or (re-search-forward regexp nil t) |
70013
d30be4cf861a
(find-function-search-for-symbol): Add comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
69921
diff
changeset
|
280 ;; `regexp' matches definitions using known forms like |
d30be4cf861a
(find-function-search-for-symbol): Add comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
69921
diff
changeset
|
281 ;; `defun', or `defvar'. But some functions/variables |
d30be4cf861a
(find-function-search-for-symbol): Add comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
69921
diff
changeset
|
282 ;; are defined using special macros (or functions), so |
d30be4cf861a
(find-function-search-for-symbol): Add comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
69921
diff
changeset
|
283 ;; if `regexp' can't find the definition, we look for |
d30be4cf861a
(find-function-search-for-symbol): Add comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
69921
diff
changeset
|
284 ;; something of the form "(SOMETHING <symbol> ...)". |
d30be4cf861a
(find-function-search-for-symbol): Add comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
69921
diff
changeset
|
285 ;; This fails to distinguish function definitions from |
d30be4cf861a
(find-function-search-for-symbol): Add comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
69921
diff
changeset
|
286 ;; variable declarations (or even uses thereof), but is |
d30be4cf861a
(find-function-search-for-symbol): Add comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
69921
diff
changeset
|
287 ;; a good pragmatic fallback. |
45150
4a2bcce6b13a
(find-function-search-for-symbol): Use with-syntax-table.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
45120
diff
changeset
|
288 (re-search-forward |
69916
62a4fbb2cb81
(find-function-search-for-symbol): Fix regexp so the defined var/fun doesn't
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
69169
diff
changeset
|
289 (concat "^([^ ]+" find-function-space-re "['(]?" |
45150
4a2bcce6b13a
(find-function-search-for-symbol): Use with-syntax-table.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
45120
diff
changeset
|
290 (regexp-quote (symbol-name symbol)) |
58261
212733e53508
(find-function-regexp): Optimize `define-minor-mode'. Add `defun-cvs-mode'.
Juri Linkov <juri@jurta.org>
parents:
55231
diff
changeset
|
291 "\\_>") |
45150
4a2bcce6b13a
(find-function-search-for-symbol): Use with-syntax-table.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
45120
diff
changeset
|
292 nil t)) |
4a2bcce6b13a
(find-function-search-for-symbol): Use with-syntax-table.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
45120
diff
changeset
|
293 (progn |
4a2bcce6b13a
(find-function-search-for-symbol): Use with-syntax-table.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
45120
diff
changeset
|
294 (beginning-of-line) |
4a2bcce6b13a
(find-function-search-for-symbol): Use with-syntax-table.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
45120
diff
changeset
|
295 (cons (current-buffer) (point))) |
71851
fcc45339ef47
(find-function-search-for-symbol):
Richard M. Stallman <rms@gnu.org>
parents:
70013
diff
changeset
|
296 (cons (current-buffer) nil)))))))) |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
297 |
22851
2c2eb47ec8e3
(find-function-noselect): Autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
22759
diff
changeset
|
298 ;;;###autoload |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
299 (defun find-function-noselect (function) |
24013 | 300 "Return a pair (BUFFER . POINT) pointing to the definition of FUNCTION. |
20183 | 301 |
68320
a2ccca4b13a3
(find-definition-noselect, find-variable-noselect): Search variables in
Eli Zaretskii <eliz@gnu.org>
parents:
68066
diff
changeset
|
302 Finds the source file containing the definition of FUNCTION |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
303 in a buffer and the point of the definition. The buffer is |
71851
fcc45339ef47
(find-function-search-for-symbol):
Richard M. Stallman <rms@gnu.org>
parents:
70013
diff
changeset
|
304 not selected. If the function definition can't be found in |
fcc45339ef47
(find-function-search-for-symbol):
Richard M. Stallman <rms@gnu.org>
parents:
70013
diff
changeset
|
305 the buffer, returns (BUFFER). |
20183 | 306 |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
307 If the file where FUNCTION is defined is not known, then it is |
73648
3dde4ab997f4
(find-function-noselect, find-function, find-variable-noselect, find-variable,
Juanma Barranquero <lekktu@gmail.com>
parents:
73208
diff
changeset
|
308 searched for in `find-function-source-path' if non-nil, otherwise |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
309 in `load-path'." |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
310 (if (not function) |
99591
1d05897d32a7
(find-function-advised-original): New.
Glenn Morris <rgm@gnu.org>
parents:
97060
diff
changeset
|
311 (error "You didn't specify a function")) |
1d05897d32a7
(find-function-advised-original): New.
Glenn Morris <rgm@gnu.org>
parents:
97060
diff
changeset
|
312 (let ((def (symbol-function (find-function-advised-original function))) |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
313 aliases) |
99591
1d05897d32a7
(find-function-advised-original): New.
Glenn Morris <rgm@gnu.org>
parents:
97060
diff
changeset
|
314 ;; FIXME for completeness, it might be nice to print something like: |
1d05897d32a7
(find-function-advised-original): New.
Glenn Morris <rgm@gnu.org>
parents:
97060
diff
changeset
|
315 ;; foo (which is advised), which is an alias for bar (which is advised). |
20183 | 316 (while (symbolp def) |
317 (or (eq def function) | |
318 (if aliases | |
319 (setq aliases (concat aliases | |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
320 (format ", which is an alias for `%s'" |
20183 | 321 (symbol-name def)))) |
99591
1d05897d32a7
(find-function-advised-original): New.
Glenn Morris <rgm@gnu.org>
parents:
97060
diff
changeset
|
322 (setq aliases (format "`%s' is an alias for `%s'" |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
323 function (symbol-name def))))) |
99591
1d05897d32a7
(find-function-advised-original): New.
Glenn Morris <rgm@gnu.org>
parents:
97060
diff
changeset
|
324 (setq function (symbol-function (find-function-advised-original function)) |
1d05897d32a7
(find-function-advised-original): New.
Glenn Morris <rgm@gnu.org>
parents:
97060
diff
changeset
|
325 def (symbol-function (find-function-advised-original function)))) |
20183 | 326 (if aliases |
65590
c45ae2a74f0f
message format spec fixes, commit # 9
Deepak Goel <deego@gnufans.org>
parents:
64751
diff
changeset
|
327 (message "%s" aliases)) |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
328 (let ((library |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
329 (cond ((eq (car-safe def) 'autoload) |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
330 (nth 1 def)) |
62908
af6dffb5d180
* emacs-lisp/find-func.el (find-function-noselect): Handle
Masatake YAMATO <jet@gyve.org>
parents:
60628
diff
changeset
|
331 ((subrp def) |
af6dffb5d180
* emacs-lisp/find-func.el (find-function-noselect): Handle
Masatake YAMATO <jet@gyve.org>
parents:
60628
diff
changeset
|
332 (help-C-file-name def 'subr)) |
59122
9b98188d56ae
(find-function-noselect): Call symbol-file with `defun'.
Richard M. Stallman <rms@gnu.org>
parents:
58261
diff
changeset
|
333 ((symbol-file function 'defun))))) |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
334 (find-function-search-for-symbol function nil library)))) |
20183 | 335 |
59367 | 336 (defun find-function-read (&optional type) |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
337 "Read and return an interned symbol, defaulting to the one near point. |
20183 | 338 |
59367 | 339 If TYPE is nil, insist on a symbol with a function definition. |
340 Otherwise TYPE should be `defvar' or `defface'. | |
341 If TYPE is nil, defaults using `function-called-at-point', | |
342 otherwise uses `variable-at-point'." | |
343 (let ((symb (if (null type) | |
344 (function-called-at-point) | |
345 (if (eq type 'defvar) | |
346 (variable-at-point) | |
347 (variable-at-point t)))) | |
348 (predicate (cdr (assq type '((nil . fboundp) (defvar . boundp) | |
349 (defface . facep))))) | |
350 (prompt (cdr (assq type '((nil . "function") (defvar . "variable") | |
351 (defface . "face"))))) | |
20183 | 352 (enable-recursive-minibuffers t) |
353 val) | |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
354 (if (equal symb 0) |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
355 (setq symb nil)) |
59367 | 356 (setq val (completing-read |
357 (concat "Find " | |
358 prompt | |
359 (if symb | |
360 (format " (default %s)" symb)) | |
361 ": ") | |
362 obarray predicate t nil)) | |
20183 | 363 (list (if (equal val "") |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
364 symb |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
365 (intern val))))) |
20183 | 366 |
59367 | 367 (defun find-function-do-it (symbol type switch-fn) |
24013 | 368 "Find Emacs Lisp SYMBOL in a buffer and display it. |
59367 | 369 TYPE is nil to search for a function definition, |
370 or else `defvar' or `defface'. | |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
371 |
59367 | 372 The variable `find-function-recenter-line' controls how |
373 to recenter the display. SWITCH-FN is the function to call | |
374 to display and select the buffer. | |
375 See also `find-function-after-hook'. | |
376 | |
377 Set mark before moving, if the buffer already existed." | |
22759
be3e1a724828
(find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents:
22641
diff
changeset
|
378 (let* ((orig-point (point)) |
be3e1a724828
(find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents:
22641
diff
changeset
|
379 (orig-buf (window-buffer)) |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
380 (orig-buffers (buffer-list)) |
22759
be3e1a724828
(find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents:
22641
diff
changeset
|
381 (buffer-point (save-excursion |
59367 | 382 (find-definition-noselect symbol type))) |
22759
be3e1a724828
(find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents:
22641
diff
changeset
|
383 (new-buf (car buffer-point)) |
be3e1a724828
(find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents:
22641
diff
changeset
|
384 (new-point (cdr buffer-point))) |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
385 (when buffer-point |
22759
be3e1a724828
(find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents:
22641
diff
changeset
|
386 (when (memq new-buf orig-buffers) |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
387 (push-mark orig-point)) |
22759
be3e1a724828
(find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents:
22641
diff
changeset
|
388 (funcall switch-fn new-buf) |
71851
fcc45339ef47
(find-function-search-for-symbol):
Richard M. Stallman <rms@gnu.org>
parents:
70013
diff
changeset
|
389 (when new-point (goto-char new-point)) |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
390 (recenter find-function-recenter-line) |
33198
167dad6064bf
(find-function-do-it): Quote the hook.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
33155
diff
changeset
|
391 (run-hooks 'find-function-after-hook)))) |
20183 | 392 |
20184
c8d4024e07de
(find-function, find-function-other-window, find-function-other-frame,
Dave Love <fx@gnu.org>
parents:
20183
diff
changeset
|
393 ;;;###autoload |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
394 (defun find-function (function) |
24021 | 395 "Find the definition of the FUNCTION near point. |
20183 | 396 |
68320
a2ccca4b13a3
(find-definition-noselect, find-variable-noselect): Search variables in
Eli Zaretskii <eliz@gnu.org>
parents:
68066
diff
changeset
|
397 Finds the source file containing the definition of the function |
59377
b9540957b07c
(find-variable, find-variable-other-window, find-variable-other-frame):
Richard M. Stallman <rms@gnu.org>
parents:
59367
diff
changeset
|
398 near point (selected by `function-called-at-point') in a buffer and |
59367 | 399 places point before the definition. |
400 Set mark before moving, if the buffer already existed. | |
20183 | 401 |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
402 The library where FUNCTION is defined is searched for in |
73648
3dde4ab997f4
(find-function-noselect, find-function, find-variable-noselect, find-variable,
Juanma Barranquero <lekktu@gmail.com>
parents:
73208
diff
changeset
|
403 `find-function-source-path', if non-nil, otherwise in `load-path'. |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
404 See also `find-function-recenter-line' and `find-function-after-hook'." |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
405 (interactive (find-function-read)) |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
406 (find-function-do-it function nil 'switch-to-buffer)) |
20183 | 407 |
20184
c8d4024e07de
(find-function, find-function-other-window, find-function-other-frame,
Dave Love <fx@gnu.org>
parents:
20183
diff
changeset
|
408 ;;;###autoload |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
409 (defun find-function-other-window (function) |
24021 | 410 "Find, in another window, the definition of FUNCTION near point. |
20183 | 411 |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
412 See `find-function' for more details." |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
413 (interactive (find-function-read)) |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
414 (find-function-do-it function nil 'switch-to-buffer-other-window)) |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
415 |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
416 ;;;###autoload |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
417 (defun find-function-other-frame (function) |
68320
a2ccca4b13a3
(find-definition-noselect, find-variable-noselect): Search variables in
Eli Zaretskii <eliz@gnu.org>
parents:
68066
diff
changeset
|
418 "Find, in another frame, the definition of FUNCTION near point. |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
419 |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
420 See `find-function' for more details." |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
421 (interactive (find-function-read)) |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
422 (find-function-do-it function nil 'switch-to-buffer-other-frame)) |
20183 | 423 |
23659
e221aa952b5b
(find-variable-noselect): Autoload.
Karl Heuer <kwzh@gnu.org>
parents:
23287
diff
changeset
|
424 ;;;###autoload |
40480
5ebd79883369
(find-function-search-for-symbol):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38557
diff
changeset
|
425 (defun find-variable-noselect (variable &optional file) |
68320
a2ccca4b13a3
(find-definition-noselect, find-variable-noselect): Search variables in
Eli Zaretskii <eliz@gnu.org>
parents:
68066
diff
changeset
|
426 "Return a pair `(BUFFER . POINT)' pointing to the definition of VARIABLE. |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
427 |
68320
a2ccca4b13a3
(find-definition-noselect, find-variable-noselect): Search variables in
Eli Zaretskii <eliz@gnu.org>
parents:
68066
diff
changeset
|
428 Finds the library containing the definition of VARIABLE in a buffer and |
a2ccca4b13a3
(find-definition-noselect, find-variable-noselect): Search variables in
Eli Zaretskii <eliz@gnu.org>
parents:
68066
diff
changeset
|
429 the point of the definition. The buffer is not selected. |
71851
fcc45339ef47
(find-function-search-for-symbol):
Richard M. Stallman <rms@gnu.org>
parents:
70013
diff
changeset
|
430 If the variable's definition can't be found in the buffer, return (BUFFER). |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
431 |
40480
5ebd79883369
(find-function-search-for-symbol):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38557
diff
changeset
|
432 The library where VARIABLE is defined is searched for in FILE or |
73648
3dde4ab997f4
(find-function-noselect, find-function, find-variable-noselect, find-variable,
Juanma Barranquero <lekktu@gmail.com>
parents:
73208
diff
changeset
|
433 `find-function-source-path', if non-nil, otherwise in `load-path'." |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
434 (if (not variable) |
68320
a2ccca4b13a3
(find-definition-noselect, find-variable-noselect): Search variables in
Eli Zaretskii <eliz@gnu.org>
parents:
68066
diff
changeset
|
435 (error "You didn't specify a variable") |
a2ccca4b13a3
(find-definition-noselect, find-variable-noselect): Search variables in
Eli Zaretskii <eliz@gnu.org>
parents:
68066
diff
changeset
|
436 (let ((library (or file |
a2ccca4b13a3
(find-definition-noselect, find-variable-noselect): Search variables in
Eli Zaretskii <eliz@gnu.org>
parents:
68066
diff
changeset
|
437 (symbol-file variable 'defvar) |
a2ccca4b13a3
(find-definition-noselect, find-variable-noselect): Search variables in
Eli Zaretskii <eliz@gnu.org>
parents:
68066
diff
changeset
|
438 (help-C-file-name variable 'var)))) |
a2ccca4b13a3
(find-definition-noselect, find-variable-noselect): Search variables in
Eli Zaretskii <eliz@gnu.org>
parents:
68066
diff
changeset
|
439 (find-function-search-for-symbol variable 'defvar library)))) |
20183 | 440 |
20184
c8d4024e07de
(find-function, find-function-other-window, find-function-other-frame,
Dave Love <fx@gnu.org>
parents:
20183
diff
changeset
|
441 ;;;###autoload |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
442 (defun find-variable (variable) |
74515 | 443 "Find the definition of the VARIABLE at or before point. |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
444 |
68320
a2ccca4b13a3
(find-definition-noselect, find-variable-noselect): Search variables in
Eli Zaretskii <eliz@gnu.org>
parents:
68066
diff
changeset
|
445 Finds the library containing the definition of the variable |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
446 near point (selected by `variable-at-point') in a buffer and |
59367 | 447 places point before the definition. |
448 | |
449 Set mark before moving, if the buffer already existed. | |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
450 |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
451 The library where VARIABLE is defined is searched for in |
73648
3dde4ab997f4
(find-function-noselect, find-function, find-variable-noselect, find-variable,
Juanma Barranquero <lekktu@gmail.com>
parents:
73208
diff
changeset
|
452 `find-function-source-path', if non-nil, otherwise in `load-path'. |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
453 See also `find-function-recenter-line' and `find-function-after-hook'." |
59377
b9540957b07c
(find-variable, find-variable-other-window, find-variable-other-frame):
Richard M. Stallman <rms@gnu.org>
parents:
59367
diff
changeset
|
454 (interactive (find-function-read 'defvar)) |
b9540957b07c
(find-variable, find-variable-other-window, find-variable-other-frame):
Richard M. Stallman <rms@gnu.org>
parents:
59367
diff
changeset
|
455 (find-function-do-it variable 'defvar 'switch-to-buffer)) |
20183 | 456 |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
457 ;;;###autoload |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
458 (defun find-variable-other-window (variable) |
24021 | 459 "Find, in another window, the definition of VARIABLE near point. |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
460 |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
461 See `find-variable' for more details." |
59377
b9540957b07c
(find-variable, find-variable-other-window, find-variable-other-frame):
Richard M. Stallman <rms@gnu.org>
parents:
59367
diff
changeset
|
462 (interactive (find-function-read 'defvar)) |
b9540957b07c
(find-variable, find-variable-other-window, find-variable-other-frame):
Richard M. Stallman <rms@gnu.org>
parents:
59367
diff
changeset
|
463 (find-function-do-it variable 'defvar 'switch-to-buffer-other-window)) |
20183 | 464 |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
465 ;;;###autoload |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
466 (defun find-variable-other-frame (variable) |
68320
a2ccca4b13a3
(find-definition-noselect, find-variable-noselect): Search variables in
Eli Zaretskii <eliz@gnu.org>
parents:
68066
diff
changeset
|
467 "Find, in another frame, the definition of VARIABLE near point. |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
468 |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
469 See `find-variable' for more details." |
59377
b9540957b07c
(find-variable, find-variable-other-window, find-variable-other-frame):
Richard M. Stallman <rms@gnu.org>
parents:
59367
diff
changeset
|
470 (interactive (find-function-read 'defvar)) |
b9540957b07c
(find-variable, find-variable-other-window, find-variable-other-frame):
Richard M. Stallman <rms@gnu.org>
parents:
59367
diff
changeset
|
471 (find-function-do-it variable 'defvar 'switch-to-buffer-other-frame)) |
20183 | 472 |
20184
c8d4024e07de
(find-function, find-function-other-window, find-function-other-frame,
Dave Love <fx@gnu.org>
parents:
20183
diff
changeset
|
473 ;;;###autoload |
59367 | 474 (defun find-definition-noselect (symbol type &optional file) |
475 "Return a pair `(BUFFER . POINT)' pointing to the definition of SYMBOL. | |
71851
fcc45339ef47
(find-function-search-for-symbol):
Richard M. Stallman <rms@gnu.org>
parents:
70013
diff
changeset
|
476 If the definition can't be found in the buffer, return (BUFFER). |
68320
a2ccca4b13a3
(find-definition-noselect, find-variable-noselect): Search variables in
Eli Zaretskii <eliz@gnu.org>
parents:
68066
diff
changeset
|
477 TYPE says what type of definition: nil for a function, `defvar' for a |
68623
e3b82cd3b90b
(find-definition-noselect): Minor doc fix.
Luc Teirlinck <teirllm@auburn.edu>
parents:
68320
diff
changeset
|
478 variable, `defface' for a face. This function does not switch to the |
68320
a2ccca4b13a3
(find-definition-noselect, find-variable-noselect): Search variables in
Eli Zaretskii <eliz@gnu.org>
parents:
68066
diff
changeset
|
479 buffer nor display it. |
59367 | 480 |
481 The library where SYMBOL is defined is searched for in FILE or | |
73648
3dde4ab997f4
(find-function-noselect, find-function, find-variable-noselect, find-variable,
Juanma Barranquero <lekktu@gmail.com>
parents:
73208
diff
changeset
|
482 `find-function-source-path', if non-nil, otherwise in `load-path'." |
68320
a2ccca4b13a3
(find-definition-noselect, find-variable-noselect): Search variables in
Eli Zaretskii <eliz@gnu.org>
parents:
68066
diff
changeset
|
483 (cond |
a2ccca4b13a3
(find-definition-noselect, find-variable-noselect): Search variables in
Eli Zaretskii <eliz@gnu.org>
parents:
68066
diff
changeset
|
484 ((not symbol) |
a2ccca4b13a3
(find-definition-noselect, find-variable-noselect): Search variables in
Eli Zaretskii <eliz@gnu.org>
parents:
68066
diff
changeset
|
485 (error "You didn't specify a symbol")) |
a2ccca4b13a3
(find-definition-noselect, find-variable-noselect): Search variables in
Eli Zaretskii <eliz@gnu.org>
parents:
68066
diff
changeset
|
486 ((null type) |
a2ccca4b13a3
(find-definition-noselect, find-variable-noselect): Search variables in
Eli Zaretskii <eliz@gnu.org>
parents:
68066
diff
changeset
|
487 (find-function-noselect symbol)) |
a2ccca4b13a3
(find-definition-noselect, find-variable-noselect): Search variables in
Eli Zaretskii <eliz@gnu.org>
parents:
68066
diff
changeset
|
488 ((eq type 'defvar) |
a2ccca4b13a3
(find-definition-noselect, find-variable-noselect): Search variables in
Eli Zaretskii <eliz@gnu.org>
parents:
68066
diff
changeset
|
489 (find-variable-noselect symbol file)) |
a2ccca4b13a3
(find-definition-noselect, find-variable-noselect): Search variables in
Eli Zaretskii <eliz@gnu.org>
parents:
68066
diff
changeset
|
490 (t |
59367 | 491 (let ((library (or file (symbol-file symbol type)))) |
68320
a2ccca4b13a3
(find-definition-noselect, find-variable-noselect): Search variables in
Eli Zaretskii <eliz@gnu.org>
parents:
68066
diff
changeset
|
492 (find-function-search-for-symbol symbol type library))))) |
59367 | 493 |
59404
f737c7344fc4
(find-face-definition): Renamed from find-face.
Richard M. Stallman <rms@gnu.org>
parents:
59377
diff
changeset
|
494 ;; For symmetry, this should be called find-face; but some programs |
f737c7344fc4
(find-face-definition): Renamed from find-face.
Richard M. Stallman <rms@gnu.org>
parents:
59377
diff
changeset
|
495 ;; assume that, if that name is defined, it means something else. |
59367 | 496 ;;;###autoload |
59404
f737c7344fc4
(find-face-definition): Renamed from find-face.
Richard M. Stallman <rms@gnu.org>
parents:
59377
diff
changeset
|
497 (defun find-face-definition (face) |
59367 | 498 "Find the definition of FACE. FACE defaults to the name near point. |
499 | |
500 Finds the Emacs Lisp library containing the definition of the face | |
501 near point (selected by `variable-at-point') in a buffer and | |
502 places point before the definition. | |
503 | |
504 Set mark before moving, if the buffer already existed. | |
505 | |
506 The library where FACE is defined is searched for in | |
73648
3dde4ab997f4
(find-function-noselect, find-function, find-variable-noselect, find-variable,
Juanma Barranquero <lekktu@gmail.com>
parents:
73208
diff
changeset
|
507 `find-function-source-path', if non-nil, otherwise in `load-path'. |
59367 | 508 See also `find-function-recenter-line' and `find-function-after-hook'." |
509 (interactive (find-function-read 'defface)) | |
510 (find-function-do-it face 'defface 'switch-to-buffer)) | |
511 | |
512 ;;;###autoload | |
20183 | 513 (defun find-function-on-key (key) |
514 "Find the function that KEY invokes. KEY is a string. | |
59367 | 515 Set mark before moving, if the buffer already existed." |
20183 | 516 (interactive "kFind function on key: ") |
51097
37a69a2f1992
(find-function-on-key): Move the call to find-function-other-window
Richard M. Stallman <rms@gnu.org>
parents:
49598
diff
changeset
|
517 (let (defn) |
37a69a2f1992
(find-function-on-key): Move the call to find-function-other-window
Richard M. Stallman <rms@gnu.org>
parents:
49598
diff
changeset
|
518 (save-excursion |
37a69a2f1992
(find-function-on-key): Move the call to find-function-other-window
Richard M. Stallman <rms@gnu.org>
parents:
49598
diff
changeset
|
519 (let* ((event (and (eventp key) (aref key 0))) ; Null event OK below. |
37a69a2f1992
(find-function-on-key): Move the call to find-function-other-window
Richard M. Stallman <rms@gnu.org>
parents:
49598
diff
changeset
|
520 (start (event-start event)) |
37a69a2f1992
(find-function-on-key): Move the call to find-function-other-window
Richard M. Stallman <rms@gnu.org>
parents:
49598
diff
changeset
|
521 (modifiers (event-modifiers event)) |
37a69a2f1992
(find-function-on-key): Move the call to find-function-other-window
Richard M. Stallman <rms@gnu.org>
parents:
49598
diff
changeset
|
522 (window (and (or (memq 'click modifiers) (memq 'down modifiers) |
37a69a2f1992
(find-function-on-key): Move the call to find-function-other-window
Richard M. Stallman <rms@gnu.org>
parents:
49598
diff
changeset
|
523 (memq 'drag modifiers)) |
37a69a2f1992
(find-function-on-key): Move the call to find-function-other-window
Richard M. Stallman <rms@gnu.org>
parents:
49598
diff
changeset
|
524 (posn-window start)))) |
37a69a2f1992
(find-function-on-key): Move the call to find-function-other-window
Richard M. Stallman <rms@gnu.org>
parents:
49598
diff
changeset
|
525 ;; For a mouse button event, go to the button it applies to |
37a69a2f1992
(find-function-on-key): Move the call to find-function-other-window
Richard M. Stallman <rms@gnu.org>
parents:
49598
diff
changeset
|
526 ;; to get the right key bindings. And go to the right place |
37a69a2f1992
(find-function-on-key): Move the call to find-function-other-window
Richard M. Stallman <rms@gnu.org>
parents:
49598
diff
changeset
|
527 ;; in case the keymap depends on where you clicked. |
37a69a2f1992
(find-function-on-key): Move the call to find-function-other-window
Richard M. Stallman <rms@gnu.org>
parents:
49598
diff
changeset
|
528 (when (windowp window) |
37a69a2f1992
(find-function-on-key): Move the call to find-function-other-window
Richard M. Stallman <rms@gnu.org>
parents:
49598
diff
changeset
|
529 (set-buffer (window-buffer window)) |
37a69a2f1992
(find-function-on-key): Move the call to find-function-other-window
Richard M. Stallman <rms@gnu.org>
parents:
49598
diff
changeset
|
530 (goto-char (posn-point start))) |
37a69a2f1992
(find-function-on-key): Move the call to find-function-other-window
Richard M. Stallman <rms@gnu.org>
parents:
49598
diff
changeset
|
531 (setq defn (key-binding key)))) |
37a69a2f1992
(find-function-on-key): Move the call to find-function-other-window
Richard M. Stallman <rms@gnu.org>
parents:
49598
diff
changeset
|
532 (let ((key-desc (key-description key))) |
37a69a2f1992
(find-function-on-key): Move the call to find-function-other-window
Richard M. Stallman <rms@gnu.org>
parents:
49598
diff
changeset
|
533 (if (or (null defn) (integerp defn)) |
37a69a2f1992
(find-function-on-key): Move the call to find-function-other-window
Richard M. Stallman <rms@gnu.org>
parents:
49598
diff
changeset
|
534 (message "%s is unbound" key-desc) |
37a69a2f1992
(find-function-on-key): Move the call to find-function-other-window
Richard M. Stallman <rms@gnu.org>
parents:
49598
diff
changeset
|
535 (if (consp defn) |
37a69a2f1992
(find-function-on-key): Move the call to find-function-other-window
Richard M. Stallman <rms@gnu.org>
parents:
49598
diff
changeset
|
536 (message "%s runs %s" key-desc (prin1-to-string defn)) |
37a69a2f1992
(find-function-on-key): Move the call to find-function-other-window
Richard M. Stallman <rms@gnu.org>
parents:
49598
diff
changeset
|
537 (find-function-other-window defn)))))) |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
538 |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
539 ;;;###autoload |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
540 (defun find-function-at-point () |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
541 "Find directly the function at point in the other window." |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
542 (interactive) |
59377
b9540957b07c
(find-variable, find-variable-other-window, find-variable-other-frame):
Richard M. Stallman <rms@gnu.org>
parents:
59367
diff
changeset
|
543 (let ((symb (function-called-at-point))) |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
544 (when symb |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
545 (find-function-other-window symb)))) |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
546 |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
547 ;;;###autoload |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
548 (defun find-variable-at-point () |
68320
a2ccca4b13a3
(find-definition-noselect, find-variable-noselect): Search variables in
Eli Zaretskii <eliz@gnu.org>
parents:
68066
diff
changeset
|
549 "Find directly the variable at point in the other window." |
22641
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
550 (interactive) |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
551 (let ((symb (variable-at-point))) |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
552 (when (and symb (not (equal symb 0))) |
1c5197790616
Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents:
22487
diff
changeset
|
553 (find-variable-other-window symb)))) |
20183 | 554 |
22759
be3e1a724828
(find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents:
22641
diff
changeset
|
555 ;;;###autoload |
be3e1a724828
(find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents:
22641
diff
changeset
|
556 (defun find-function-setup-keys () |
be3e1a724828
(find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents:
22641
diff
changeset
|
557 "Define some key bindings for the find-function family of functions." |
be3e1a724828
(find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents:
22641
diff
changeset
|
558 (define-key ctl-x-map "F" 'find-function) |
be3e1a724828
(find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents:
22641
diff
changeset
|
559 (define-key ctl-x-4-map "F" 'find-function-other-window) |
be3e1a724828
(find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents:
22641
diff
changeset
|
560 (define-key ctl-x-5-map "F" 'find-function-other-frame) |
be3e1a724828
(find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents:
22641
diff
changeset
|
561 (define-key ctl-x-map "K" 'find-function-on-key) |
be3e1a724828
(find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents:
22641
diff
changeset
|
562 (define-key ctl-x-map "V" 'find-variable) |
be3e1a724828
(find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents:
22641
diff
changeset
|
563 (define-key ctl-x-4-map "V" 'find-variable-other-window) |
be3e1a724828
(find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents:
22641
diff
changeset
|
564 (define-key ctl-x-5-map "V" 'find-variable-other-frame)) |
be3e1a724828
(find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents:
22641
diff
changeset
|
565 |
20183 | 566 (provide 'find-func) |
567 | |
59330
03306a6707b9
(find-variable-regexp): Avoid defface.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59122
diff
changeset
|
568 ;; arch-tag: 43ecd81c-74dc-4d9a-8f63-a61e55670d64 |
20183 | 569 ;;; find-func.el ends here |