diff options
| author | Richard M. Stallman | 1998-07-14 23:42:21 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-07-14 23:42:21 +0000 |
| commit | 86f281250c79bd9bb9fb8e89a273969a767e2292 (patch) | |
| tree | d53e2771818de1d2e11597bd83b9f85db74e779e | |
| parent | 7aa5f6cf266802d4552932001b5b066f3f811c05 (diff) | |
| download | emacs-86f281250c79bd9bb9fb8e89a273969a767e2292.tar.gz emacs-86f281250c79bd9bb9fb8e89a273969a767e2292.zip | |
(find-function-regexp): Added :version 20.3.
(find-variable-regexp, find-function-after-hook): Likewise.
(find-function-recenter-line): Likewise.
(find-function-recenter-line): Remove autoload cookie.
(find-function-do-it): Made more solid. `save-excursion' around
call to `find-function-noselect'. `find-function-other-window'
and `find-function-other-frame' point behaviour should be correct
now when function in a current buffer.
(find-function-setup-keys): New function to set up keybindings.
| -rw-r--r-- | lisp/emacs-lisp/find-func.el | 54 |
1 files changed, 36 insertions, 18 deletions
diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el index c4f57bbdc19..fe5667df60e 100644 --- a/lisp/emacs-lisp/find-func.el +++ b/lisp/emacs-lisp/find-func.el | |||
| @@ -33,10 +33,13 @@ | |||
| 33 | ;; following code in your init file: | 33 | ;; following code in your init file: |
| 34 | ;; | 34 | ;; |
| 35 | ;; ;;; find-func | 35 | ;; ;;; find-func |
| 36 | ;; (find-function-setup-keys) | ||
| 37 | ;; | ||
| 38 | ;; or just: | ||
| 39 | ;; | ||
| 36 | ;; (load "find-func") | 40 | ;; (load "find-func") |
| 37 | ;; | 41 | ;; |
| 38 | ;; and away you go! The default given keybindings as the ones | 42 | ;; if you don't like the given keybindings and away you go! It does |
| 39 | ;; protected by autoload cookies at the bottom of this file. It does | ||
| 40 | ;; pretty much what you would expect, putting the cursor at the | 43 | ;; pretty much what you would expect, putting the cursor at the |
| 41 | ;; definition of the function or variable at point. | 44 | ;; definition of the function or variable at point. |
| 42 | ;; | 45 | ;; |
| @@ -64,7 +67,8 @@ should insert the function name. The default value avoids `defconst', | |||
| 64 | 67 | ||
| 65 | Please send improvements and fixes to the maintainer." | 68 | Please send improvements and fixes to the maintainer." |
| 66 | :type 'regexp | 69 | :type 'regexp |
| 67 | :group 'find-function) | 70 | :group 'find-function |
| 71 | :version 20.3) | ||
| 68 | 72 | ||
| 69 | (defcustom find-variable-regexp | 73 | (defcustom find-variable-regexp |
| 70 | "^\\s-*(def[^uma\W]\\w+\\*?\\s-+%s\\(\\s-\\|$\\)" | 74 | "^\\s-*(def[^uma\W]\\w+\\*?\\s-+%s\\(\\s-\\|$\\)" |
| @@ -74,7 +78,8 @@ avoids `defun', `defmacro', `defalias', `defadvice'. | |||
| 74 | 78 | ||
| 75 | Please send improvements and fixes to the maintainer." | 79 | Please send improvements and fixes to the maintainer." |
| 76 | :type 'regexp | 80 | :type 'regexp |
| 77 | :group 'find-function) | 81 | :group 'find-function |
| 82 | :version 20.3) | ||
| 78 | 83 | ||
| 79 | (defcustom find-function-source-path nil | 84 | (defcustom find-function-source-path nil |
| 80 | "The default list of directories where find-function searches. | 85 | "The default list of directories where find-function searches. |
| @@ -84,22 +89,20 @@ default." | |||
| 84 | :type '(repeat directory) | 89 | :type '(repeat directory) |
| 85 | :group 'find-function) | 90 | :group 'find-function) |
| 86 | 91 | ||
| 87 | |||
| 88 | ;;; Functions: | ||
| 89 | |||
| 90 | ;;;###autoload | ||
| 91 | (defcustom find-function-recenter-line 1 | 92 | (defcustom find-function-recenter-line 1 |
| 92 | "The window line-number from which to start displaying a symbol definition. | 93 | "The window line-number from which to start displaying a symbol definition. |
| 93 | A value of nil implies center the beginning of the definition. | 94 | A value of nil implies center the beginning of the definition. |
| 94 | See the function `center-to-window-line' for more information, and | 95 | See the function `center-to-window-line' for more information, and |
| 95 | `find-function' and `find-variable'." | 96 | `find-function' and `find-variable'." |
| 96 | :group 'find-function) | 97 | :group 'find-function |
| 98 | :version 20.3) | ||
| 97 | 99 | ||
| 98 | (defcustom find-function-after-hook nil | 100 | (defcustom find-function-after-hook nil |
| 99 | "Hook run after finding symbol definition. | 101 | "Hook run after finding symbol definition. |
| 100 | 102 | ||
| 101 | See the functions `find-function' and `find-variable'." | 103 | See the functions `find-function' and `find-variable'." |
| 102 | :group 'find-function) | 104 | :group 'find-function |
| 105 | :version 20.3) | ||
| 103 | 106 | ||
| 104 | ;;; Functions: | 107 | ;;; Functions: |
| 105 | 108 | ||
| @@ -240,17 +243,21 @@ centered according to the variable `find-function-recenter-line'. | |||
| 240 | See also `find-function-after-hook'. | 243 | See also `find-function-after-hook'. |
| 241 | 244 | ||
| 242 | Point is saved in the buffer if it is one of the current buffers." | 245 | Point is saved in the buffer if it is one of the current buffers." |
| 243 | (let ((orig-point (point)) | 246 | (let* ((orig-point (point)) |
| 247 | (orig-buf (window-buffer)) | ||
| 244 | (orig-buffers (buffer-list)) | 248 | (orig-buffers (buffer-list)) |
| 245 | (buffer-point (funcall (if variable-p | 249 | (buffer-point (save-excursion |
| 246 | 'find-variable-noselect | 250 | (funcall (if variable-p |
| 247 | 'find-function-noselect) | 251 | 'find-variable-noselect |
| 248 | symbol))) | 252 | 'find-function-noselect) |
| 253 | symbol))) | ||
| 254 | (new-buf (car buffer-point)) | ||
| 255 | (new-point (cdr buffer-point))) | ||
| 249 | (when buffer-point | 256 | (when buffer-point |
| 250 | (funcall switch-fn (car buffer-point)) | 257 | (when (memq new-buf orig-buffers) |
| 251 | (when (memq (car buffer-point) orig-buffers) | ||
| 252 | (push-mark orig-point)) | 258 | (push-mark orig-point)) |
| 253 | (goto-char (cdr buffer-point)) | 259 | (funcall switch-fn new-buf) |
| 260 | (goto-char new-point) | ||
| 254 | (recenter find-function-recenter-line) | 261 | (recenter find-function-recenter-line) |
| 255 | (run-hooks find-function-after-hook)))) | 262 | (run-hooks find-function-after-hook)))) |
| 256 | 263 | ||
| @@ -359,6 +366,17 @@ Point is saved if FUNCTION is in the current buffer." | |||
| 359 | (when (and symb (not (equal symb 0))) | 366 | (when (and symb (not (equal symb 0))) |
| 360 | (find-variable-other-window symb)))) | 367 | (find-variable-other-window symb)))) |
| 361 | 368 | ||
| 369 | ;;;###autoload | ||
| 370 | (defun find-function-setup-keys () | ||
| 371 | "Define some key bindings for the find-function family of functions." | ||
| 372 | (define-key ctl-x-map "F" 'find-function) | ||
| 373 | (define-key ctl-x-4-map "F" 'find-function-other-window) | ||
| 374 | (define-key ctl-x-5-map "F" 'find-function-other-frame) | ||
| 375 | (define-key ctl-x-map "K" 'find-function-on-key) | ||
| 376 | (define-key ctl-x-map "V" 'find-variable) | ||
| 377 | (define-key ctl-x-4-map "V" 'find-variable-other-window) | ||
| 378 | (define-key ctl-x-5-map "V" 'find-variable-other-frame)) | ||
| 379 | |||
| 362 | (provide 'find-func) | 380 | (provide 'find-func) |
| 363 | 381 | ||
| 364 | ;;; find-func.el ends here | 382 | ;;; find-func.el ends here |