diff options
| author | Dave Love | 2003-09-06 17:32:31 +0000 |
|---|---|---|
| committer | Dave Love | 2003-09-06 17:32:31 +0000 |
| commit | a3d819fcaac6cbb5b7e207dc234f864086c858ff (patch) | |
| tree | 4f8170b87294f8bcf5a7cffef09f6a5455aeda52 | |
| parent | 30955b19cee0345f1bdbee9dad9167e3a534865d (diff) | |
| download | emacs-a3d819fcaac6cbb5b7e207dc234f864086c858ff.tar.gz emacs-a3d819fcaac6cbb5b7e207dc234f864086c858ff.zip | |
(eldoc-print-current-symbol-info-function):
New.
(eldoc-print-current-symbol-info): Use it.
| -rw-r--r-- | lisp/emacs-lisp/eldoc.el | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/lisp/emacs-lisp/eldoc.el b/lisp/emacs-lisp/eldoc.el index b5f37487ac5..650b385ff45 100644 --- a/lisp/emacs-lisp/eldoc.el +++ b/lisp/emacs-lisp/eldoc.el | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | ;; Keywords: extensions | 7 | ;; Keywords: extensions |
| 8 | ;; Created: 1995-10-06 | 8 | ;; Created: 1995-10-06 |
| 9 | 9 | ||
| 10 | ;; $Id: eldoc.el,v 1.25 2003/05/06 17:36:16 lektu Exp $ | 10 | ;; $Id: eldoc.el,v 1.26 2003/09/01 15:45:22 miles Exp $ |
| 11 | 11 | ||
| 12 | ;; This file is part of GNU Emacs. | 12 | ;; This file is part of GNU Emacs. |
| 13 | 13 | ||
| @@ -40,11 +40,14 @@ | |||
| 40 | ;; One useful way to enable this minor mode is to put the following in your | 40 | ;; One useful way to enable this minor mode is to put the following in your |
| 41 | ;; .emacs: | 41 | ;; .emacs: |
| 42 | ;; | 42 | ;; |
| 43 | ;; (autoload 'turn-on-eldoc-mode "eldoc" nil t) | ||
| 44 | ;; (add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode) | 43 | ;; (add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode) |
| 45 | ;; (add-hook 'lisp-interaction-mode-hook 'turn-on-eldoc-mode) | 44 | ;; (add-hook 'lisp-interaction-mode-hook 'turn-on-eldoc-mode) |
| 46 | ;; (add-hook 'ielm-mode-hook 'turn-on-eldoc-mode) | 45 | ;; (add-hook 'ielm-mode-hook 'turn-on-eldoc-mode) |
| 47 | 46 | ||
| 47 | ;; Major modes for other languages may use Eldoc by defining an | ||
| 48 | ;; appropriate function as the buffer-local value of | ||
| 49 | ;; `eldoc-print-current-symbol-info-function'. | ||
| 50 | |||
| 48 | ;;; Code: | 51 | ;;; Code: |
| 49 | 52 | ||
| 50 | (require 'help-fns) ;For fundoc-usage handling functions. | 53 | (require 'help-fns) ;For fundoc-usage handling functions. |
| @@ -233,19 +236,32 @@ With prefix ARG, turn ElDoc mode on if and only if ARG is positive." | |||
| 233 | (not (eq (selected-window) (minibuffer-window))))) | 236 | (not (eq (selected-window) (minibuffer-window))))) |
| 234 | 237 | ||
| 235 | 238 | ||
| 239 | (defvar eldoc-print-current-symbol-info-function nil | ||
| 240 | "If non-nil, function to call to return doc string. | ||
| 241 | The function of no args should return a one-line string for displaying | ||
| 242 | doc about a function etc. appropriate to the context around point. | ||
| 243 | It should return nil if there's no doc appropriate for the context. | ||
| 244 | Typically doc is returned if point is on a function-like name or in its | ||
| 245 | arg list. | ||
| 246 | |||
| 247 | This variable is expected to be made buffer-local by modes (other than | ||
| 248 | Emacs Lisp mode) that support Eldoc.") | ||
| 249 | |||
| 236 | (defun eldoc-print-current-symbol-info () | 250 | (defun eldoc-print-current-symbol-info () |
| 237 | (condition-case err | 251 | (condition-case err |
| 238 | (and (eldoc-display-message-p) | 252 | (and (eldoc-display-message-p) |
| 239 | (let* ((current-symbol (eldoc-current-symbol)) | 253 | (if eldoc-print-current-symbol-info-function |
| 240 | (current-fnsym (eldoc-fnsym-in-current-sexp)) | 254 | (eldoc-message (funcall eldoc-print-current-symbol-info-function)) |
| 241 | (doc (cond | 255 | (let* ((current-symbol (eldoc-current-symbol)) |
| 242 | ((eq current-symbol current-fnsym) | 256 | (current-fnsym (eldoc-fnsym-in-current-sexp)) |
| 243 | (or (eldoc-get-fnsym-args-string current-fnsym) | 257 | (doc (cond |
| 244 | (eldoc-get-var-docstring current-symbol))) | 258 | ((eq current-symbol current-fnsym) |
| 245 | (t | 259 | (or (eldoc-get-fnsym-args-string current-fnsym) |
| 246 | (or (eldoc-get-var-docstring current-symbol) | 260 | (eldoc-get-var-docstring current-symbol))) |
| 247 | (eldoc-get-fnsym-args-string current-fnsym)))))) | 261 | (t |
| 248 | (eldoc-message doc))) | 262 | (or (eldoc-get-var-docstring current-symbol) |
| 263 | (eldoc-get-fnsym-args-string current-fnsym)))))) | ||
| 264 | (eldoc-message doc)))) | ||
| 249 | ;; This is run from post-command-hook or some idle timer thing, | 265 | ;; This is run from post-command-hook or some idle timer thing, |
| 250 | ;; so we need to be careful that errors aren't ignored. | 266 | ;; so we need to be careful that errors aren't ignored. |
| 251 | (error (message "eldoc error: %s" err)))) | 267 | (error (message "eldoc error: %s" err)))) |