annotate lisp/emacs-lisp/find-func.el @ 90072:cb67264d6096

Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-2 Merge from emacs--cvs-trunk--0 Patches applied: * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-83 - miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-84 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-3 - miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-4 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-5 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-6 - miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-11 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-12 Remove "-face" suffix from lazy-highlight face name * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-13 - miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-16 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-17 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-18 - miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-21 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-22 <no summary provided> * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-23 - miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-39 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-40 Fix regressions from latest reftex update * miles@gnu.org--gnu-2005/gnus--rel--5.10--base-0 tag of miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-82 * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-1 Merge from emacs--cvs-trunk--0 * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-2 Merge from miles@gnu.org--gnu-2004 * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-3 Merge from emacs--cvs-trunk--0
author Miles Bader <miles@gnu.org>
date Sun, 16 Jan 2005 03:40:12 +0000
parents 95879cc1ed20 f737c7344fc4
children 3ebd9bdb4fe5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
2
59330
03306a6707b9 (find-variable-regexp): Avoid defface.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59122
diff changeset
3 ;; Copyright (C) 1997, 1999, 2001, 2004, 2005 Free Software Foundation, Inc.
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
4
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
5 ;; Author: Jens Petersen <petersen@kurims.kyoto-u.ac.jp>
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
6 ;; Maintainer: petersen@kurims.kyoto-u.ac.jp
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
7 ;; Keywords: emacs-lisp, functions, variables
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
8 ;; Created: 97/07/25
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
9
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
11
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
15 ;; any later version.
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
16
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
20 ;; GNU General Public License for more details.
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
21
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
25 ;; Boston, MA 02111-1307, USA.
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
26
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
27 ;;; Commentary:
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
28 ;;
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
29 ;; The funniest thing about this is that I can't imagine why a package
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
30 ;; so obviously useful as this hasn't been written before!!
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
31 ;; ;;; find-func
22759
be3e1a724828 (find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents: 22641
diff changeset
32 ;; (find-function-setup-keys)
be3e1a724828 (find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents: 22641
diff changeset
33 ;;
be3e1a724828 (find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents: 22641
diff changeset
34 ;; or just:
be3e1a724828 (find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents: 22641
diff changeset
35 ;;
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
36 ;; (load "find-func")
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
37 ;;
22759
be3e1a724828 (find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents: 22641
diff changeset
38 ;; 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
39 ;; 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
40 ;; definition of the function or variable at point.
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
41 ;;
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
42 ;; The code started out from `describe-function', `describe-key'
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
43 ;; ("help.el") and `fff-find-loaded-emacs-lisp-function' (Noah Friedman's
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
44 ;; "fff.el").
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
45
38436
b174db545cfd Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 33198
diff changeset
46 ;;; Code:
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
47
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
48 (require 'loadhist)
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
49
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
50 ;;; User variables:
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
51
20962
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20184
diff changeset
52 (defgroup find-function nil
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
53 "Finds the definition of the Emacs Lisp symbol near point."
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
54 ;; :prefix "find-function"
20962
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20184
diff changeset
55 :group 'lisp)
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
56
45326
892ea515fb3a (find-function-search-for-symbol): Find funs defined with defun-cvs-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45257
diff changeset
57 (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
58
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
59 (defcustom find-function-regexp
24013
2f040734bd5f Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 23862
diff changeset
60 ;; Match things like (defun foo ...), (defmacro foo ...),
2f040734bd5f Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 23862
diff changeset
61 ;; (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
62 ;; (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
63 (concat
892ea515fb3a (find-function-search-for-symbol): Find funs defined with defun-cvs-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45257
diff changeset
64 "^\\s-*(\\(def\\(ine-skeleton\\|ine-generic-mode\\|ine-derived-mode\\|\
58261
212733e53508 (find-function-regexp): Optimize `define-minor-mode'. Add `defun-cvs-mode'.
Juri Linkov <juri@jurta.org>
parents: 55231
diff changeset
65 ine-minor-mode\\|un-cvs-mode\\|foo\\|[^cfgv]\\w+\\*?\\)\
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 \\|easy-mmode-define-global-mode\\)" find-function-space-re
892ea515fb3a (find-function-search-for-symbol): Find funs defined with defun-cvs-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45257
diff changeset
67 "\\('\\|\(quote \\)?%s\\(\\s-\\|$\\|\(\\|\)\\)")
24013
2f040734bd5f Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 23862
diff changeset
68 "The regexp used by `find-function' to search for a function definition.
2f040734bd5f Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 23862
diff changeset
69 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
70 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
71 `defgroup', `defvar', `defface'.
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
72
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
73 Please send improvements and fixes to the maintainer."
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
74 :type 'regexp
22759
be3e1a724828 (find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents: 22641
diff changeset
75 :group 'find-function
26558
2daba92c1033 (find-function-regexp): Use `define-minor-mode' after easy-menu
Dave Love <fx@gnu.org>
parents: 25424
diff changeset
76 :version "21.1")
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
77
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
78 (defcustom find-variable-regexp
59330
03306a6707b9 (find-variable-regexp): Avoid defface.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59122
diff changeset
79 (concat"^\\s-*(def[^fumag]\\(\\w\\|\\s_\\)+\\*?" find-function-space-re "%s\\(\\s-\\|$\\)")
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
80 "The regexp used by `find-variable' to search for a variable definition.
59367
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
81 Note it must contain a `%s' at the place where `format'
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
82 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
83 avoids `defun', `defmacro', `defalias', `defadvice', `defgroup', `defface'.
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
84
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
85 Please send improvements and fixes to the maintainer."
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
86 :type 'regexp
22759
be3e1a724828 (find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents: 22641
diff changeset
87 :group 'find-function
32226
2af46c6c8bde (find-function-regexp): Remove spurion.
Dave Love <fx@gnu.org>
parents: 26593
diff changeset
88 :version "21.1")
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
89
59367
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
90 (defcustom find-face-regexp
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
91 (concat"^\\s-*(defface" find-function-space-re "%s\\(\\s-\\|$\\)")
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
92 "The regexp used by `find-face' to search for a face definition.
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
93 Note it must contain a `%s' at the place where `format'
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
94 should insert the face name.
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
95
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
96 Please send improvements and fixes to the maintainer."
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
97 :type 'regexp
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
98 :group 'find-function
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
99 :version "21.4")
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
100
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
101 (defvar find-function-regexp-alist
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
102 '((nil . find-function-regexp)
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
103 (defvar . find-variable-regexp)
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
104 (defface . find-face-regexp))
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
105 "Alist mapping definition types into regexp variables.
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
106 Each regexp variable's value should actually be a format string
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
107 to be used to substitute the desired symbol name into the regexp.")
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
108 (put 'find-function-regexp-alist 'risky-local-variable t)
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
109
20962
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20184
diff changeset
110 (defcustom find-function-source-path nil
24013
2f040734bd5f Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 23862
diff changeset
111 "The default list of directories where `find-function' searches.
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
112
24013
2f040734bd5f Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 23862
diff changeset
113 If this variable is nil then `find-function' searches `load-path' by
20962
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20184
diff changeset
114 default."
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20184
diff changeset
115 :type '(repeat directory)
54413501e4a9 Customized.
Stephen Eglen <stephen@gnu.org>
parents: 20184
diff changeset
116 :group 'find-function)
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
117
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
118 (defcustom find-function-recenter-line 1
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
119 "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
120 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
121 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
122 :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
123 integer)
22759
be3e1a724828 (find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents: 22641
diff changeset
124 :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
125 :version "20.3")
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
126
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
127 (defcustom find-function-after-hook nil
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
128 "Hook run after finding symbol definition.
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 See the functions `find-function' and `find-variable'."
22759
be3e1a724828 (find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents: 22641
diff changeset
131 :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
132 :version "20.3")
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
133
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
134 ;;; Functions:
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
135
47345
8268e926d8e9 (find-library-suffixes, find-library-name)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47298
diff changeset
136 (defun find-library-suffixes ()
8268e926d8e9 (find-library-suffixes, find-library-name)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47298
diff changeset
137 (let ((suffixes nil))
8268e926d8e9 (find-library-suffixes, find-library-name)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47298
diff changeset
138 (dolist (suffix load-suffixes (nreverse suffixes))
8268e926d8e9 (find-library-suffixes, find-library-name)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47298
diff changeset
139 (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
140
8268e926d8e9 (find-library-suffixes, find-library-name)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47298
diff changeset
141 (defun find-library-name (library)
8268e926d8e9 (find-library-suffixes, find-library-name)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47298
diff changeset
142 "Return the full name of the elisp source of LIBRARY."
8268e926d8e9 (find-library-suffixes, find-library-name)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47298
diff changeset
143 ;; If the library is byte-compiled, try to find a source library by
8268e926d8e9 (find-library-suffixes, find-library-name)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47298
diff changeset
144 ;; the same name.
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
145 (if (string-match "\\.el\\(c\\(\\..*\\)?\\)\\'" library)
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
146 (setq library (replace-match "" t t library)))
47345
8268e926d8e9 (find-library-suffixes, find-library-name)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47298
diff changeset
147 (or (locate-file library
8268e926d8e9 (find-library-suffixes, find-library-name)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47298
diff changeset
148 (or find-function-source-path load-path)
47447
85021da80289 (find-library-name): Typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47446
diff changeset
149 (append (find-library-suffixes) '("")))
47446
8bd5dd6cc381 (find-library-name): Don't forget the empty suffix. Fix stale variable name.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47345
diff changeset
150 (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
151
55231
7fc34677dcb8 (find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
152 (defvar find-function-C-source-directory
7fc34677dcb8 (find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
153 (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
154 (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
155 dir))
7fc34677dcb8 (find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
156 "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
157 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
158 defined in C.")
7fc34677dcb8 (find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
159
59367
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
160 (defun find-function-C-source (fun-or-var file type)
55231
7fc34677dcb8 (find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
161 "Find the source location where SUBR-OR-VAR is defined in FILE.
59367
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
162 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
163 (unless find-function-C-source-directory
7fc34677dcb8 (find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
164 (setq find-function-C-source-directory
7fc34677dcb8 (find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
165 (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
166 (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
167 (unless (file-readable-p file)
7fc34677dcb8 (find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
168 (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
169 (file-name-nondirectory file)))
59367
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
170 (unless type
55231
7fc34677dcb8 (find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
171 (setq fun-or-var (indirect-function fun-or-var)))
7fc34677dcb8 (find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
172 (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
173 (goto-char (point-min))
7fc34677dcb8 (find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
174 (unless (re-search-forward
59367
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
175 (if type
55231
7fc34677dcb8 (find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
176 (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
177 (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
178 "\"")
7fc34677dcb8 (find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
179 (concat "DEFUN[ \t\n]*([ \t\n]*\""
7fc34677dcb8 (find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
180 (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
181 "\""))
7fc34677dcb8 (find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
182 nil t)
7fc34677dcb8 (find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
183 (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
184 (cons (current-buffer) (match-beginning 0))))
7fc34677dcb8 (find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
185
47345
8268e926d8e9 (find-library-suffixes, find-library-name)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47298
diff changeset
186 ;;;###autoload
8268e926d8e9 (find-library-suffixes, find-library-name)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47298
diff changeset
187 (defun find-library (library)
8268e926d8e9 (find-library-suffixes, find-library-name)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47298
diff changeset
188 "Find the elisp source of LIBRARY."
8268e926d8e9 (find-library-suffixes, find-library-name)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47298
diff changeset
189 (interactive
8268e926d8e9 (find-library-suffixes, find-library-name)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47298
diff changeset
190 (list
8268e926d8e9 (find-library-suffixes, find-library-name)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47298
diff changeset
191 (completing-read "Library name: "
8268e926d8e9 (find-library-suffixes, find-library-name)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47298
diff changeset
192 'locate-file-completion
8268e926d8e9 (find-library-suffixes, find-library-name)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47298
diff changeset
193 (cons (or find-function-source-path load-path)
8268e926d8e9 (find-library-suffixes, find-library-name)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47298
diff changeset
194 (find-library-suffixes)))))
8268e926d8e9 (find-library-suffixes, find-library-name)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47298
diff changeset
195 (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
196 (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
197
45190
9c3195b605f7 (find-function-search-for-symbol): Add autoload cookie.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 45150
diff changeset
198 ;;;###autoload
59367
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
199 (defun find-function-search-for-symbol (symbol type library)
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
200 "Search for SYMBOL's definition of type TYPE in LIBRARY.
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
201 If TYPE is nil, look for a function definition.
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
202 Otherwise, TYPE specifies the kind of definition,
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
203 and it is interpreted via `find-function-regexp-alist'.
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
204 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
205 (if (null library)
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
206 (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
207 ;; 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
208 ;; that defines something else.
55231
7fc34677dcb8 (find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
209 (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
210 (setq symbol (get symbol 'definition-name)))
55231
7fc34677dcb8 (find-function-C-source-directory): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
211 (if (string-match "\\`src/\\(.*\\.c\\)\\'" library)
59367
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
212 (find-function-C-source symbol (match-string 1 library) type)
23862
d0e08cc0aa3d (find-function-search-for-symbol):
Dave Love <fx@gnu.org>
parents: 23737
diff changeset
213 (if (string-match "\\.el\\(c\\)\\'" library)
d0e08cc0aa3d (find-function-search-for-symbol):
Dave Love <fx@gnu.org>
parents: 23737
diff changeset
214 (setq library (substring library 0 (match-beginning 1))))
59367
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
215 (let* ((filename (find-library-name library))
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
216 (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
217 (with-current-buffer (find-file-noselect filename)
59367
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
218 (let ((regexp (format (symbol-value regexp-symbol)
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
219 (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
220 (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
221 (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
222 (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
223 (if (or (re-search-forward regexp nil t)
4a2bcce6b13a (find-function-search-for-symbol): Use with-syntax-table.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 45120
diff changeset
224 (re-search-forward
45326
892ea515fb3a (find-function-search-for-symbol): Find funs defined with defun-cvs-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 45257
diff changeset
225 (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
226 (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
227 "\\_>")
45150
4a2bcce6b13a (find-function-search-for-symbol): Use with-syntax-table.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 45120
diff changeset
228 nil t))
4a2bcce6b13a (find-function-search-for-symbol): Use with-syntax-table.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 45120
diff changeset
229 (progn
4a2bcce6b13a (find-function-search-for-symbol): Use with-syntax-table.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 45120
diff changeset
230 (beginning-of-line)
4a2bcce6b13a (find-function-search-for-symbol): Use with-syntax-table.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 45120
diff changeset
231 (cons (current-buffer) (point)))
4a2bcce6b13a (find-function-search-for-symbol): Use with-syntax-table.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 45120
diff changeset
232 (error "Cannot find definition of `%s' in library `%s'"
4a2bcce6b13a (find-function-search-for-symbol): Use with-syntax-table.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 45120
diff changeset
233 symbol library))))))))
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
234
22851
2c2eb47ec8e3 (find-function-noselect): Autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 22759
diff changeset
235 ;;;###autoload
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
236 (defun find-function-noselect (function)
24013
2f040734bd5f Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 23862
diff changeset
237 "Return a pair (BUFFER . POINT) pointing to the definition of FUNCTION.
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
238
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
239 Finds the Emacs Lisp library containing the definition of FUNCTION
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
240 in a buffer and the point of the definition. The buffer is
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
241 not selected.
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
242
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
243 If the file where FUNCTION is defined is not known, then it is
24013
2f040734bd5f Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 23862
diff changeset
244 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
245 in `load-path'."
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
246 (if (not function)
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
247 (error "You didn't specify a function"))
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
248 (and (subrp (symbol-function function))
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
249 (error "%s is a primitive function" function))
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
250 (let ((def (symbol-function function))
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
251 aliases)
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
252 (while (symbolp def)
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
253 (or (eq def function)
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
254 (if aliases
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
255 (setq aliases (concat aliases
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
256 (format ", which is an alias for `%s'"
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
257 (symbol-name def))))
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
258 (setq aliases (format "`%s' an alias for `%s'"
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
259 function (symbol-name def)))))
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
260 (setq function (symbol-function function)
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
261 def (symbol-function function)))
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
262 (if aliases
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
263 (message aliases))
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
264 (let ((library
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
265 (cond ((eq (car-safe def) 'autoload)
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
266 (nth 1 def))
59122
9b98188d56ae (find-function-noselect): Call symbol-file with `defun'.
Richard M. Stallman <rms@gnu.org>
parents: 58261
diff changeset
267 ((symbol-file function 'defun)))))
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
268 (find-function-search-for-symbol function nil library))))
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
269
59367
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
270 (defun find-function-read (&optional type)
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
271 "Read and return an interned symbol, defaulting to the one near point.
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
272
59367
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
273 If TYPE is nil, insist on a symbol with a function definition.
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
274 Otherwise TYPE should be `defvar' or `defface'.
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
275 If TYPE is nil, defaults using `function-called-at-point',
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
276 otherwise uses `variable-at-point'."
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
277 (let ((symb (if (null type)
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
278 (function-called-at-point)
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
279 (if (eq type 'defvar)
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
280 (variable-at-point)
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
281 (variable-at-point t))))
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
282 (predicate (cdr (assq type '((nil . fboundp) (defvar . boundp)
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
283 (defface . facep)))))
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
284 (prompt (cdr (assq type '((nil . "function") (defvar . "variable")
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
285 (defface . "face")))))
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
286 (enable-recursive-minibuffers t)
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
287 val)
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
288 (if (equal symb 0)
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
289 (setq symb nil))
59367
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
290 (setq val (completing-read
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
291 (concat "Find "
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
292 prompt
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
293 (if symb
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
294 (format " (default %s)" symb))
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
295 ": ")
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
296 obarray predicate t nil))
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
297 (list (if (equal val "")
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
298 symb
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
299 (intern val)))))
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
300
59367
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
301 (defun find-function-do-it (symbol type switch-fn)
24013
2f040734bd5f Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 23862
diff changeset
302 "Find Emacs Lisp SYMBOL in a buffer and display it.
59367
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
303 TYPE is nil to search for a function definition,
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
304 or else `defvar' or `defface'.
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
305
59367
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
306 The variable `find-function-recenter-line' controls how
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
307 to recenter the display. SWITCH-FN is the function to call
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
308 to display and select the buffer.
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
309 See also `find-function-after-hook'.
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
310
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
311 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
312 (let* ((orig-point (point))
be3e1a724828 (find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents: 22641
diff changeset
313 (orig-buf (window-buffer))
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
314 (orig-buffers (buffer-list))
22759
be3e1a724828 (find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents: 22641
diff changeset
315 (buffer-point (save-excursion
59367
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
316 (find-definition-noselect symbol type)))
22759
be3e1a724828 (find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents: 22641
diff changeset
317 (new-buf (car buffer-point))
be3e1a724828 (find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents: 22641
diff changeset
318 (new-point (cdr buffer-point)))
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
319 (when buffer-point
22759
be3e1a724828 (find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents: 22641
diff changeset
320 (when (memq new-buf orig-buffers)
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
321 (push-mark orig-point))
22759
be3e1a724828 (find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents: 22641
diff changeset
322 (funcall switch-fn new-buf)
be3e1a724828 (find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents: 22641
diff changeset
323 (goto-char new-point)
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
324 (recenter find-function-recenter-line)
33198
167dad6064bf (find-function-do-it): Quote the hook.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 33155
diff changeset
325 (run-hooks 'find-function-after-hook))))
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
326
20184
c8d4024e07de (find-function, find-function-other-window, find-function-other-frame,
Dave Love <fx@gnu.org>
parents: 20183
diff changeset
327 ;;;###autoload
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
328 (defun find-function (function)
24021
a937ab82e54f More doc fixes.
Dave Love <fx@gnu.org>
parents: 24013
diff changeset
329 "Find the definition of the FUNCTION near point.
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
330
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
331 Finds the Emacs Lisp library 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
332 near point (selected by `function-called-at-point') in a buffer and
59367
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
333 places point before the definition.
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
334 Set mark before moving, if the buffer already existed.
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
335
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
336 The library where FUNCTION is defined is searched for in
24013
2f040734bd5f Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 23862
diff changeset
337 `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
338 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
339 (interactive (find-function-read))
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
340 (find-function-do-it function nil 'switch-to-buffer))
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
341
20184
c8d4024e07de (find-function, find-function-other-window, find-function-other-frame,
Dave Love <fx@gnu.org>
parents: 20183
diff changeset
342 ;;;###autoload
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
343 (defun find-function-other-window (function)
24021
a937ab82e54f More doc fixes.
Dave Love <fx@gnu.org>
parents: 24013
diff changeset
344 "Find, in another window, the definition of FUNCTION near point.
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
345
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
346 See `find-function' for more details."
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
347 (interactive (find-function-read))
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
348 (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
349
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
350 ;;;###autoload
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
351 (defun find-function-other-frame (function)
24021
a937ab82e54f More doc fixes.
Dave Love <fx@gnu.org>
parents: 24013
diff changeset
352 "Find, in ananother frame, the definition of FUNCTION near point.
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
353
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
354 See `find-function' for more details."
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
355 (interactive (find-function-read))
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
356 (find-function-do-it function nil 'switch-to-buffer-other-frame))
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
357
23659
e221aa952b5b (find-variable-noselect): Autoload.
Karl Heuer <kwzh@gnu.org>
parents: 23287
diff changeset
358 ;;;###autoload
40480
5ebd79883369 (find-function-search-for-symbol):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38557
diff changeset
359 (defun find-variable-noselect (variable &optional file)
5ebd79883369 (find-function-search-for-symbol):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38557
diff changeset
360 "Return a pair `(BUFFER . POINT)' pointing to the definition of SYMBOL.
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
361
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
362 Finds the Emacs Lisp library containing the definition of SYMBOL
59367
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
363 in a buffer, and the point of the definition. It does not switch
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
364 to the buffer or display it.
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
365
40480
5ebd79883369 (find-function-search-for-symbol):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38557
diff changeset
366 The library where VARIABLE is defined is searched for in FILE or
24013
2f040734bd5f Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 23862
diff changeset
367 `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
368 (if (not variable)
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
369 (error "You didn't specify a variable"))
59122
9b98188d56ae (find-function-noselect): Call symbol-file with `defun'.
Richard M. Stallman <rms@gnu.org>
parents: 58261
diff changeset
370 (let ((library (or file (symbol-file variable 'defvar))))
59367
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
371 (find-function-search-for-symbol variable 'defvar library)))
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
372
20184
c8d4024e07de (find-function, find-function-other-window, find-function-other-frame,
Dave Love <fx@gnu.org>
parents: 20183
diff changeset
373 ;;;###autoload
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
374 (defun find-variable (variable)
24021
a937ab82e54f More doc fixes.
Dave Love <fx@gnu.org>
parents: 24013
diff changeset
375 "Find the definition of the VARIABLE near point.
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
376
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
377 Finds the Emacs Lisp library containing the definition of the variable
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
378 near point (selected by `variable-at-point') in a buffer and
59367
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
379 places point before the definition.
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
380
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
381 Set mark before moving, if the buffer already existed.
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
382
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
383 The library where VARIABLE is defined is searched for in
24013
2f040734bd5f Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 23862
diff changeset
384 `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
385 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
386 (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
387 (find-function-do-it variable 'defvar 'switch-to-buffer))
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
388
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
389 ;;;###autoload
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
390 (defun find-variable-other-window (variable)
24021
a937ab82e54f More doc fixes.
Dave Love <fx@gnu.org>
parents: 24013
diff changeset
391 "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
392
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
393 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
394 (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
395 (find-function-do-it variable 'defvar 'switch-to-buffer-other-window))
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
396
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
397 ;;;###autoload
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
398 (defun find-variable-other-frame (variable)
24021
a937ab82e54f More doc fixes.
Dave Love <fx@gnu.org>
parents: 24013
diff changeset
399 "Find, in annother frame, the definition of VARIABLE near point.
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
400
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
401 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
402 (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
403 (find-function-do-it variable 'defvar 'switch-to-buffer-other-frame))
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
404
20184
c8d4024e07de (find-function, find-function-other-window, find-function-other-frame,
Dave Love <fx@gnu.org>
parents: 20183
diff changeset
405 ;;;###autoload
59367
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
406 (defun find-definition-noselect (symbol type &optional file)
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
407 "Return a pair `(BUFFER . POINT)' pointing to the definition of SYMBOL.
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
408 TYPE says what type of definition: nil for a function,
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
409 `defvar' or `defface' for a variable or face. This functoin
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
410 does not switch to the buffer or display it.
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
411
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
412 The library where SYMBOL is defined is searched for in FILE or
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
413 `find-function-source-path', if non nil, otherwise in `load-path'."
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
414 (if (not symbol)
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
415 (error "You didn't specify a symbol"))
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
416 (if (null type)
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
417 (find-function-noselect symbol)
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
418 (let ((library (or file (symbol-file symbol type))))
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
419 (find-function-search-for-symbol symbol type library))))
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
420
59404
f737c7344fc4 (find-face-definition): Renamed from find-face.
Richard M. Stallman <rms@gnu.org>
parents: 59377
diff changeset
421 ;; 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
422 ;; assume that, if that name is defined, it means something else.
59367
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
423 ;;;###autoload
59404
f737c7344fc4 (find-face-definition): Renamed from find-face.
Richard M. Stallman <rms@gnu.org>
parents: 59377
diff changeset
424 (defun find-face-definition (face)
59367
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
425 "Find the definition of FACE. FACE defaults to the name near point.
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
426
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
427 Finds the Emacs Lisp library containing the definition of the face
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
428 near point (selected by `variable-at-point') in a buffer and
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
429 places point before the definition.
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
430
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
431 Set mark before moving, if the buffer already existed.
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
432
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
433 The library where FACE is defined is searched for in
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
434 `find-function-source-path', if non nil, otherwise in `load-path'.
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
435 See also `find-function-recenter-line' and `find-function-after-hook'."
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
436 (interactive (find-function-read 'defface))
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
437 (find-function-do-it face 'defface 'switch-to-buffer))
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
438
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
439 ;;;###autoload
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
440 (defun find-function-on-key (key)
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
441 "Find the function that KEY invokes. KEY is a string.
59367
3827f56f03b6 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 59330
diff changeset
442 Set mark before moving, if the buffer already existed."
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
443 (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
444 (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
445 (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
446 (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
447 (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
448 (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
449 (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
450 (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
451 (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
452 ;; 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
453 ;; 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
454 ;; 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
455 (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
456 (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
457 (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
458 (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
459 (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
460 (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
461 (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
462 (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
463 (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
464 (find-function-other-window defn))))))
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
465
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
466 ;;;###autoload
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
467 (defun find-function-at-point ()
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
468 "Find directly the function at point in the other window."
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
469 (interactive)
59377
b9540957b07c (find-variable, find-variable-other-window, find-variable-other-frame):
Richard M. Stallman <rms@gnu.org>
parents: 59367
diff changeset
470 (let ((symb (function-called-at-point)))
22641
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
471 (when symb
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
472 (find-function-other-window symb))))
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
473
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
474 ;;;###autoload
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
475 (defun find-variable-at-point ()
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
476 "Find directly the function at point in the other window."
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
477 (interactive)
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
478 (let ((symb (variable-at-point)))
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
479 (when (and symb (not (equal symb 0)))
1c5197790616 Require `loadhist'. Variable
Richard M. Stallman <rms@gnu.org>
parents: 22487
diff changeset
480 (find-variable-other-window symb))))
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
481
22759
be3e1a724828 (find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents: 22641
diff changeset
482 ;;;###autoload
be3e1a724828 (find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents: 22641
diff changeset
483 (defun find-function-setup-keys ()
be3e1a724828 (find-function-regexp): Added :version 20.3.
Richard M. Stallman <rms@gnu.org>
parents: 22641
diff changeset
484 "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
485 (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
486 (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
487 (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
488 (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
489 (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
490 (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
491 (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
492
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
493 (provide 'find-func)
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
494
59330
03306a6707b9 (find-variable-regexp): Avoid defface.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 59122
diff changeset
495 ;; arch-tag: 43ecd81c-74dc-4d9a-8f63-a61e55670d64
20183
add8b7b3a7da Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
496 ;;; find-func.el ends here