• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10.1/emacs-93/emacs/lisp/emacs-lisp/

Lines Matching +refs:eldoc +refs:documentation +refs:function

0 ;;; eldoc.el --- show function arglist or variable docstring in echo area
30 ;; This program was inspired by the behavior of the "mouse documentation
31 ;; window" on many Lisp Machine systems; as you type a function's symbol
33 ;; function. Behavior is not identical; for example, you need not actually
34 ;; type the function name, you need only move point around in a sexp that
36 ;; the one-line documentation for that variable instead, to remind you of
42 ;; (add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
43 ;; (add-hook 'lisp-interaction-mode-hook 'turn-on-eldoc-mode)
44 ;; (add-hook 'ielm-mode-hook 'turn-on-eldoc-mode)
47 ;; appropriate function as the buffer-local value of
48 ;; `eldoc-documentation-function'.
54 (defgroup eldoc nil
55 "Show function arglist or variable docstring in echo area."
59 (defcustom eldoc-idle-delay 0.50
62 last input, no documentation will be printed.
66 :group 'eldoc)
69 (defcustom eldoc-minor-mode-string " ElDoc"
72 :group 'eldoc)
74 (defcustom eldoc-argument-case 'upcase
77 Actually, any name of a function which takes a string as an argument and
79 :type '(radio (function-item upcase)
80 (function-item downcase)
81 function)
82 :group 'eldoc)
84 (defcustom eldoc-echo-area-use-multiline-p 'truncate-sym-name-if-fit
85 "*Allow long eldoc messages to resize echo area display.
87 and function arglist or 1-line variable documentation will be displayed
91 if it will enable the function arglist or documentation string to fit on a
97 truncated to make more of the arglist or documentation string visible."
102 :group 'eldoc)
106 (defvar eldoc-message-commands-table-size 31
107 "This is used by eldoc-add-command to initialize eldoc-message-commands
114 (defconst eldoc-message-commands
115 (make-vector eldoc-message-commands-table-size 0)
117 Eldoc does not try to print function arglists, etc. after just any command,
122 directly. Instead, use `eldoc-add-command' and `eldoc-remove-command'.")
124 (defconst eldoc-last-data (make-vector 3 nil)
129 2 - 'function if function args, 'variable if variable documentation.")
130 (defvar eldoc-last-message nil)
132 (defvar eldoc-timer nil "eldoc's timer object.")
134 (defvar eldoc-current-idle-delay eldoc-idle-delay
136 This is used to determine if `eldoc-idle-delay' is changed by the user.")
141 (define-minor-mode eldoc-mode
144 function or variable in the text where point is. If point is
147 of the function called in the expression point is on.
150 :group 'eldoc :lighter eldoc-minor-mode-string
151 (setq eldoc-last-message nil)
152 (if eldoc-mode
154 (add-hook 'post-command-hook 'eldoc-schedule-timer nil t)
155 (add-hook 'pre-command-hook 'eldoc-pre-command-refresh-echo-area t))
156 (remove-hook 'post-command-hook 'eldoc-schedule-timer)
157 (remove-hook 'pre-command-hook 'eldoc-pre-command-refresh-echo-area)))
160 (defun turn-on-eldoc-mode ()
161 "Unequivocally turn on ElDoc mode (see command `eldoc-mode')."
163 (eldoc-mode 1))
167 (defun eldoc-schedule-timer ()
168 (or (and eldoc-timer
169 (memq eldoc-timer timer-idle-list))
170 (setq eldoc-timer
171 (run-with-idle-timer eldoc-idle-delay t
172 'eldoc-print-current-symbol-info)))
175 (cond ((not (= eldoc-idle-delay eldoc-current-idle-delay))
176 (setq eldoc-current-idle-delay eldoc-idle-delay)
177 (timer-set-idle-time eldoc-timer eldoc-idle-delay t))))
179 (defun eldoc-message (&rest args)
180 (let ((omessage eldoc-last-message))
181 (setq eldoc-last-message
182 (cond ((eq (car args) eldoc-last-message) eldoc-last-message)
185 ;; eldoc-last-message so eq test above might succeed on
190 ;; are recorded in a log. Do not put eldoc messages in that log since
194 (cond (eldoc-last-message (message "%s" eldoc-last-message))
196 eldoc-last-message)
198 ;; This function goes on pre-command-hook for XEmacs or when using idle
200 ;; which make eldoc messages flicker or disappear just before motion
201 ;; begins. This function reprints the last eldoc message immediately
204 (defun eldoc-pre-command-refresh-echo-area ()
205 (and eldoc-last-message
206 (if (eldoc-display-message-no-interference-p)
207 (eldoc-message eldoc-last-message)
208 (setq eldoc-last-message nil))))
211 (defun eldoc-display-message-p ()
212 (and (eldoc-display-message-no-interference-p)
220 eldoc-message-commands))))
223 ;; it undesirable to print eldoc messages right this instant.
224 (defun eldoc-display-message-no-interference-p ()
225 (and eldoc-mode
236 (defvar eldoc-documentation-function nil
237 "If non-nil, function to call to return doc string.
238 The function of no args should return a one-line string for displaying
239 doc about a function etc. appropriate to the context around point.
241 Typically doc is returned if point is on a function-like name or in its
247 (defun eldoc-print-current-symbol-info ()
249 (and (eldoc-display-message-p)
250 (if eldoc-documentation-function
251 (eldoc-message (funcall eldoc-documentation-function))
252 (let* ((current-symbol (eldoc-current-symbol))
253 (current-fnsym (eldoc-fnsym-in-current-sexp))
256 (or (eldoc-get-fnsym-args-string current-fnsym)
257 (eldoc-get-var-docstring current-symbol)))
259 (or (eldoc-get-var-docstring current-symbol)
260 (eldoc-get-fnsym-args-string current-fnsym))))))
261 (eldoc-message doc))))
264 (error (message "eldoc error: %s" err))))
266 ;; Return a string containing the function parameter list, or 1-line
267 ;; docstring if function is a subr and no arglist is obtainable from the
269 (defun eldoc-get-fnsym-args-string (sym)
273 ((and (eq sym (aref eldoc-last-data 0))
274 (eq 'function (aref eldoc-last-data 2)))
275 (setq doc (aref eldoc-last-data 1)))
276 ((setq doc (help-split-fundoc (documentation sym t) sym))
281 (setq args (eldoc-function-argstring sym))))
283 (setq doc (eldoc-docstring-format-sym-doc sym args))
284 (eldoc-last-data-store sym doc 'function)))
287 ;; Return a string containing a brief (one-line) documentation string for
289 (defun eldoc-get-var-docstring (sym)
291 (cond ((and (eq sym (aref eldoc-last-data 0))
292 (eq 'variable (aref eldoc-last-data 2)))
293 (aref eldoc-last-data 1))
295 (let ((doc (documentation-property sym 'variable-documentation t)))
297 (setq doc (eldoc-docstring-format-sym-doc
298 sym (eldoc-docstring-first-line doc)))
299 (eldoc-last-data-store sym doc 'variable)))
302 (defun eldoc-last-data-store (symbol doc type)
303 (aset eldoc-last-data 0 symbol)
304 (aset eldoc-last-data 1 doc)
305 (aset eldoc-last-data 2 type))
309 (defun eldoc-docstring-first-line (doc)
322 (defun eldoc-docstring-format-sym-doc (sym doc)
325 (ea-multi eldoc-echo-area-use-multiline-p)
348 (defun eldoc-fnsym-in-current-sexp ()
350 (eldoc-beginning-of-sexp)
355 (eldoc-current-symbol))
358 (defun eldoc-beginning-of-sexp ()
368 (defun eldoc-current-symbol ()
374 ;; Do indirect function resolution if possible.
375 (defun eldoc-symbol-function (fsym)
377 (symbol-function fsym))))
380 (setq defn (indirect-function fsym))
384 (defun eldoc-function-argstring (fn)
385 (eldoc-function-argstring-format (help-function-arglist fn)))
387 (defun eldoc-function-argstring-format (arglist)
392 (mapcar (function (lambda (s)
395 (funcall eldoc-argument-case
400 (mapcar (function (lambda (s)
403 (funcall eldoc-argument-case s))))
409 ;; When point is in a sexp, the function args are not reprinted in the echo
411 ;; their own messages in the echo area; the eldoc functions would instantly
415 (defun eldoc-add-command (&rest cmds)
419 (set (intern name eldoc-message-commands) t)))
421 (defun eldoc-add-command-completions (&rest names)
423 (apply 'eldoc-add-command (all-completions name obarray 'commandp))))
425 (defun eldoc-remove-command (&rest cmds)
429 (unintern name eldoc-message-commands)))
431 (defun eldoc-remove-command-completions (&rest names)
433 (apply 'eldoc-remove-command
434 (all-completions name eldoc-message-commands))))
439 (eldoc-add-command-completions
448 (provide 'eldoc)
451 ;;; eldoc.el ends here