;;; eldoc.el --- show function arglist or variable docstring in echo area
-;; Copyright (C) 1996, 97, 98, 99, 2000, 2003 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004,
+;; 2005 Free Software Foundation, Inc.
;; Author: Noah Friedman <friedman@splode.com>
;; Maintainer: friedman@splode.com
;; Keywords: extensions
;; Created: 1995-10-06
-;; $Id: eldoc.el,v 1.25 2003/05/06 17:36:16 lektu Exp $
-
;; This file is part of GNU Emacs.
;; GNU Emacs is free software; you can redistribute it and/or modify
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
;;; Commentary:
;; One useful way to enable this minor mode is to put the following in your
;; .emacs:
;;
-;; (autoload 'turn-on-eldoc-mode "eldoc" nil t)
;; (add-hook 'emacs-lisp-mode-hook 'turn-on-eldoc-mode)
;; (add-hook 'lisp-interaction-mode-hook 'turn-on-eldoc-mode)
;; (add-hook 'ielm-mode-hook 'turn-on-eldoc-mode)
+;; Major modes for other languages may use Eldoc by defining an
+;; appropriate function as the buffer-local value of
+;; `eldoc-documentation-function'.
+
;;; Code:
(require 'help-fns) ;For fundoc-usage handling functions.
;;;###autoload
(define-minor-mode eldoc-mode
"Toggle ElDoc mode on or off.
-Show the defined parameters for the elisp function near point.
-
-For the emacs lisp function at the beginning of the sexp which point is
-within, show the defined parameters for the function in the echo area.
-This information is extracted directly from the function or macro if it is
-in pure lisp. If the emacs function is a subr, the parameters are obtained
-from the documentation string if possible.
-
-If point is over a documented variable, print that variable's docstring
-instead.
+In ElDoc mode, the echo area displays information about a
+function or variable in the text where point is. If point is
+on a documented variable, it displays the first line of that
+variable's doc string. Otherwise it displays the argument list
+of the function called in the expression point is on.
With prefix ARG, turn ElDoc mode on if and only if ARG is positive."
- nil eldoc-minor-mode-string nil
+ :group 'eldoc :lighter eldoc-minor-mode-string
(setq eldoc-last-message nil)
(if eldoc-mode
(progn
(eldoc-mode 1))
\f
-;; Idle timers are part of Emacs 19.31 and later.
(defun eldoc-schedule-timer ()
(or (and eldoc-timer
(memq eldoc-timer timer-idle-list))
(not (eq (selected-window) (minibuffer-window)))))
\f
+;;;###autoload
+(defvar eldoc-documentation-function nil
+ "If non-nil, function to call to return doc string.
+The function of no args should return a one-line string for displaying
+doc about a function etc. appropriate to the context around point.
+It should return nil if there's no doc appropriate for the context.
+Typically doc is returned if point is on a function-like name or in its
+arg list.
+
+This variable is expected to be made buffer-local by modes (other than
+Emacs Lisp mode) that support Eldoc.")
+
(defun eldoc-print-current-symbol-info ()
(condition-case err
(and (eldoc-display-message-p)
- (let* ((current-symbol (eldoc-current-symbol))
- (current-fnsym (eldoc-fnsym-in-current-sexp))
- (doc (cond
- ((eq current-symbol current-fnsym)
- (or (eldoc-get-fnsym-args-string current-fnsym)
- (eldoc-get-var-docstring current-symbol)))
- (t
- (or (eldoc-get-var-docstring current-symbol)
- (eldoc-get-fnsym-args-string current-fnsym))))))
- (eldoc-message doc)))
+ (if eldoc-documentation-function
+ (eldoc-message (funcall eldoc-documentation-function))
+ (let* ((current-symbol (eldoc-current-symbol))
+ (current-fnsym (eldoc-fnsym-in-current-sexp))
+ (doc (cond
+ ((eq current-symbol current-fnsym)
+ (or (eldoc-get-fnsym-args-string current-fnsym)
+ (eldoc-get-var-docstring current-symbol)))
+ (t
+ (or (eldoc-get-var-docstring current-symbol)
+ (eldoc-get-fnsym-args-string current-fnsym))))))
+ (eldoc-message doc))))
;; This is run from post-command-hook or some idle timer thing,
;; so we need to be careful that errors aren't ignored.
(error (message "eldoc error: %s" err))))
;; Prime the command list.
(eldoc-add-command-completions
"backward-" "beginning-of-" "delete-other-windows" "delete-window"
- "end-of-" "forward-" "indent-for-tab-command" "goto-" "mouse-set-point"
- "next-" "other-window" "previous-" "recenter" "scroll-"
- "self-insert-command" "split-window-"
- "up-list" "down-list")
+ "end-of-" "exchange-point-and-mark" "forward-"
+ "indent-for-tab-command" "goto-" "mark-page" "mark-paragraph"
+ "mouse-set-point" "move-" "pop-global-mark" "next-" "other-window"
+ "previous-" "recenter" "scroll-" "self-insert-command"
+ "split-window-" "up-list" "down-list")
(provide 'eldoc)