/[emacs]/emacs/lisp/emacs-lisp/find-func.el
ViewVC logotype

Diff of /emacs/lisp/emacs-lisp/find-func.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.35 by monnier, Thu May 16 20:11:23 2002 UTC revision 1.35.2.1 by miles, Fri Apr 4 06:20:16 2003 UTC
# Line 97  default." Line 97  default."
97  (defcustom find-function-recenter-line 1  (defcustom find-function-recenter-line 1
98    "The window line-number from which to start displaying a symbol definition.    "The window line-number from which to start displaying a symbol definition.
99  A value of nil implies center the beginning of the definition.  A value of nil implies center the beginning of the definition.
100  See the function `center-to-window-line' for more information, and  See `find-function' and `find-variable'."
101  `find-function' and `find-variable'."    :type '(choice (const :tag "Center" nil)
102                     integer)
103    :group 'find-function    :group 'find-function
104    :version "20.3")    :version "20.3")
105    
# Line 111  See the functions `find-function' and `f Line 112  See the functions `find-function' and `f
112    
113  ;;; Functions:  ;;; Functions:
114    
115    (defun find-library-suffixes ()
116      (let ((suffixes nil))
117        (dolist (suffix load-suffixes (nreverse suffixes))
118          (unless (string-match "elc" suffix) (push suffix suffixes)))))
119    
120    (defun find-library-name (library)
121      "Return the full name of the elisp source of LIBRARY."
122      ;; If the library is byte-compiled, try to find a source library by
123      ;; the same name.
124      (if (string-match "\\.el\\(c\\(\\..*\\)?\\)\\'" library)
125          (setq library (replace-match "" t t library)))
126      (or (locate-file library
127                       (or find-function-source-path load-path)
128                       (append (find-library-suffixes) '("")))
129          (error "Can't find library %s" library)))
130    
131    ;;;###autoload
132    (defun find-library (library)
133      "Find the elisp source of LIBRARY."
134      (interactive
135       (list
136        (completing-read "Library name: "
137                         'locate-file-completion
138                         (cons (or find-function-source-path load-path)
139                               (find-library-suffixes)))))
140      (let ((buf (find-file-noselect (find-library-name library))))
141        (condition-case nil (switch-to-buffer buf) (error (pop-to-buffer buf)))))
142    
143  ;;;###autoload  ;;;###autoload
144  (defun find-function-search-for-symbol (symbol variable-p library)  (defun find-function-search-for-symbol (symbol variable-p library)
145    "Search for SYMBOL.    "Search for SYMBOL.
146  If VARIABLE-P is nil, `find-function-regexp' is used, otherwise  If VARIABLE-P is nil, `find-function-regexp' is used, otherwise
147  `find-variable-regexp' is used.   The search is done in library LIBRARY."  `find-variable-regexp' is used.  The search is done in library LIBRARY."
148    (if (null library)    (if (null library)
149        (error "Don't know where `%s' is defined" symbol))        (error "Don't know where `%s' is defined" symbol))
150      ;; Some functions are defined as part of the construct
151      ;; that defines something else.
152      (while (get symbol 'definition-name)
153        (setq symbol (get symbol 'definition-name)))
154    (save-match-data    (save-match-data
155      (if (string-match "\\.el\\(c\\)\\'" library)      (if (string-match "\\.el\\(c\\)\\'" library)
156          (setq library (substring library 0 (match-beginning 1))))          (setq library (substring library 0 (match-beginning 1))))
157      (let* ((path find-function-source-path)      (let* ((filename (find-library-name library)))
            (compression (or (rassq 'jka-compr-handler file-name-handler-alist)  
                             (member 'crypt-find-file-hook find-file-hooks)))  
            (filename (progn  
                        ;; use `file-name-sans-extension' here? (if it gets fixed)  
                        (if (string-match "\\(\\.el\\)\\'" library)  
                            (setq library (substring library 0  
                                                     (match-beginning 1))))  
                        (or (locate-library (concat library ".el") t path)  
                            (locate-library library t path)  
                            (if compression  
                                (or (locate-library (concat library ".el.gz")  
                                                    t path)  
                                    (locate-library (concat library ".gz")  
                                                    t path)))))))  
       (if (not filename)  
           (error "The library `%s' is not in the path" library))  
158        (with-current-buffer (find-file-noselect filename)        (with-current-buffer (find-file-noselect filename)
159          (let ((regexp (format (if variable-p          (let ((regexp (format (if variable-p
160                                    find-variable-regexp                                    find-variable-regexp
# Line 295  The library where VARIABLE is defined is Line 312  The library where VARIABLE is defined is
312  `find-function-source-path', if non nil, otherwise in `load-path'."  `find-function-source-path', if non nil, otherwise in `load-path'."
313    (if (not variable)    (if (not variable)
314        (error "You didn't specify a variable"))        (error "You didn't specify a variable"))
315    (let ((library (or file (symbol-file variable))))    ;; Fixme: I think `symbol-file' should be fixed instead.  -- fx
316      (let ((library (or file (symbol-file (cons 'defvar variable)))))
317      (find-function-search-for-symbol variable 'variable library)))      (find-function-search-for-symbol variable 'variable library)))
318    
319  ;;;###autoload  ;;;###autoload

Legend:
Removed from v.1.35  
changed lines
  Added in v.1.35.2.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26