40 |
;; One useful way to enable this minor mode is to put the following in your |
;; One useful way to enable this minor mode is to put the following in your |
41 |
;; .emacs: |
;; .emacs: |
42 |
;; |
;; |
|
;; (autoload 'turn-on-eldoc-mode "eldoc" nil t) |
|
43 |
;; (add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode) |
;; (add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode) |
44 |
;; (add-hook 'lisp-interaction-mode-hook 'turn-on-eldoc-mode) |
;; (add-hook 'lisp-interaction-mode-hook 'turn-on-eldoc-mode) |
45 |
;; (add-hook 'ielm-mode-hook 'turn-on-eldoc-mode) |
;; (add-hook 'ielm-mode-hook 'turn-on-eldoc-mode) |
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 |
|
|
51 |
;;; Code: |
;;; Code: |
52 |
|
|
53 |
(require 'help-fns) ;For fundoc-usage handling functions. |
(require 'help-fns) ;For fundoc-usage handling functions. |
84 |
|
|
85 |
(defcustom eldoc-echo-area-use-multiline-p 'truncate-sym-name-if-fit |
(defcustom eldoc-echo-area-use-multiline-p 'truncate-sym-name-if-fit |
86 |
"*Allow long eldoc messages to resize echo area display. |
"*Allow long eldoc messages to resize echo area display. |
87 |
If value is `t', never attempt to truncate messages; complete symbol name |
If value is t, never attempt to truncate messages; complete symbol name |
88 |
and function arglist or 1-line variable documentation will be displayed |
and function arglist or 1-line variable documentation will be displayed |
89 |
even if echo area must be resized to fit. |
even if echo area must be resized to fit. |
90 |
|
|
91 |
If value is any non-nil value other than `t', symbol name may be truncated |
If value is any non-nil value other than t, symbol name may be truncated |
92 |
if it will enable the function arglist or documentation string to fit on a |
if it will enable the function arglist or documentation string to fit on a |
93 |
single line without resizing window. Otherwise, behavior is just like |
single line without resizing window. Otherwise, behavior is just like |
94 |
former case. |
former case. |
183 |
|
|
184 |
(defun eldoc-message (&rest args) |
(defun eldoc-message (&rest args) |
185 |
(let ((omessage eldoc-last-message)) |
(let ((omessage eldoc-last-message)) |
186 |
(setq eldoc-last-message |
(setq eldoc-last-message |
187 |
(cond ((eq (car args) eldoc-last-message) eldoc-last-message) |
(cond ((eq (car args) eldoc-last-message) eldoc-last-message) |
188 |
((null (car args)) nil) |
((null (car args)) nil) |
189 |
;; If only one arg, no formatting to do, so put it in |
;; If only one arg, no formatting to do, so put it in |
236 |
(not (eq (selected-window) (minibuffer-window))))) |
(not (eq (selected-window) (minibuffer-window))))) |
237 |
|
|
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 |
|
|
250 |
(defun eldoc-print-current-symbol-info () |
(defun eldoc-print-current-symbol-info () |
251 |
(condition-case err |
(condition-case err |
252 |
(and (eldoc-display-message-p) |
(and (eldoc-display-message-p) |
253 |
(let* ((current-symbol (eldoc-current-symbol)) |
(if eldoc-print-current-symbol-info-function |
254 |
(current-fnsym (eldoc-fnsym-in-current-sexp)) |
(eldoc-message (funcall eldoc-print-current-symbol-info-function)) |
255 |
(doc (cond |
(let* ((current-symbol (eldoc-current-symbol)) |
256 |
((eq current-symbol current-fnsym) |
(current-fnsym (eldoc-fnsym-in-current-sexp)) |
257 |
(or (eldoc-get-fnsym-args-string current-fnsym) |
(doc (cond |
258 |
(eldoc-get-var-docstring current-symbol))) |
((eq current-symbol current-fnsym) |
259 |
(t |
(or (eldoc-get-fnsym-args-string current-fnsym) |
260 |
(or (eldoc-get-var-docstring current-symbol) |
(eldoc-get-var-docstring current-symbol))) |
261 |
(eldoc-get-fnsym-args-string current-fnsym)))))) |
(t |
262 |
(eldoc-message doc))) |
(or (eldoc-get-var-docstring current-symbol) |
263 |
|
(eldoc-get-fnsym-args-string current-fnsym)))))) |
264 |
|
(eldoc-message doc)))) |
265 |
;; This is run from post-command-hook or some idle timer thing, |
;; This is run from post-command-hook or some idle timer thing, |
266 |
;; so we need to be careful that errors aren't ignored. |
;; so we need to be careful that errors aren't ignored. |
267 |
(error (message "eldoc error: %s" err)))) |
(error (message "eldoc error: %s" err)))) |
467 |
|
|
468 |
(provide 'eldoc) |
(provide 'eldoc) |
469 |
|
|
470 |
|
;;; arch-tag: c9a58f9d-2055-46c1-9b82-7248b71a8375 |
471 |
;;; eldoc.el ends here |
;;; eldoc.el ends here |