2014-09-04 15:23:37 +00:00
|
|
|
|
;;; eldoc.el --- Show function arglist or variable docstring in echo area -*- lexical-binding:t; -*-
|
1995-11-12 21:04:08 +00:00
|
|
|
|
|
2015-01-01 22:26:41 +00:00
|
|
|
|
;; Copyright (C) 1996-2015 Free Software Foundation, Inc.
|
1995-11-12 21:04:08 +00:00
|
|
|
|
|
1998-09-19 02:15:26 +00:00
|
|
|
|
;; Author: Noah Friedman <friedman@splode.com>
|
|
|
|
|
;; Maintainer: friedman@splode.com
|
1995-11-12 21:04:08 +00:00
|
|
|
|
;; Keywords: extensions
|
|
|
|
|
;; Created: 1995-10-06
|
|
|
|
|
|
1997-02-03 06:13:34 +00:00
|
|
|
|
;; This file is part of GNU Emacs.
|
1995-11-12 21:04:08 +00:00
|
|
|
|
|
2008-05-06 03:21:21 +00:00
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
1995-11-12 21:04:08 +00:00
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 03:21:21 +00:00
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
1997-02-03 06:13:34 +00:00
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
1995-11-12 21:04:08 +00:00
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
1997-02-03 06:13:34 +00:00
|
|
|
|
|
1995-11-12 21:04:08 +00:00
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
2008-05-06 03:21:21 +00:00
|
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
1995-11-12 21:04:08 +00:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
1997-02-03 06:13:34 +00:00
|
|
|
|
;; This program was inspired by the behavior of the "mouse documentation
|
|
|
|
|
;; window" on many Lisp Machine systems; as you type a function's symbol
|
|
|
|
|
;; name as part of a sexp, it will print the argument list for that
|
|
|
|
|
;; function. Behavior is not identical; for example, you need not actually
|
|
|
|
|
;; type the function name, you need only move point around in a sexp that
|
|
|
|
|
;; calls it. Also, if point is over a documented variable, it will print
|
|
|
|
|
;; the one-line documentation for that variable instead, to remind you of
|
|
|
|
|
;; that variable's meaning.
|
1995-11-12 21:04:08 +00:00
|
|
|
|
|
|
|
|
|
;; One useful way to enable this minor mode is to put the following in your
|
|
|
|
|
;; .emacs:
|
|
|
|
|
;;
|
2014-01-30 07:42:57 +00:00
|
|
|
|
;; (add-hook 'emacs-lisp-mode-hook 'eldoc-mode)
|
|
|
|
|
;; (add-hook 'lisp-interaction-mode-hook 'eldoc-mode)
|
|
|
|
|
;; (add-hook 'ielm-mode-hook 'eldoc-mode)
|
2014-01-30 07:54:28 +00:00
|
|
|
|
;; (add-hook 'eval-expression-minibuffer-setup-hook 'eldoc-mode)
|
1995-11-12 21:04:08 +00:00
|
|
|
|
|
2009-01-17 20:01:17 +00:00
|
|
|
|
;; Major modes for other languages may use ElDoc by defining an
|
2003-09-06 17:32:31 +00:00
|
|
|
|
;; appropriate function as the buffer-local value of
|
2005-04-26 11:00:56 +00:00
|
|
|
|
;; `eldoc-documentation-function'.
|
2003-09-06 17:32:31 +00:00
|
|
|
|
|
1995-11-12 21:04:08 +00:00
|
|
|
|
;;; Code:
|
|
|
|
|
|
1997-04-14 07:33:28 +00:00
|
|
|
|
(defgroup eldoc nil
|
|
|
|
|
"Show function arglist or variable docstring in echo area."
|
2000-07-24 00:38:34 +00:00
|
|
|
|
:group 'lisp
|
1997-04-14 07:33:28 +00:00
|
|
|
|
:group 'extensions)
|
|
|
|
|
|
|
|
|
|
(defcustom eldoc-idle-delay 0.50
|
2009-01-16 03:24:54 +00:00
|
|
|
|
"Number of seconds of idle time to wait before printing.
|
1995-11-12 21:04:08 +00:00
|
|
|
|
If user input arrives before this interval of time has elapsed after the
|
|
|
|
|
last input, no documentation will be printed.
|
|
|
|
|
|
1997-04-14 07:33:28 +00:00
|
|
|
|
If this variable is set to 0, no idle time is required."
|
|
|
|
|
:type 'number
|
|
|
|
|
:group 'eldoc)
|
1995-11-12 21:04:08 +00:00
|
|
|
|
|
2014-01-12 04:00:03 +00:00
|
|
|
|
(defcustom eldoc-print-after-edit nil
|
|
|
|
|
"If non-nil eldoc info is only shown when editing.
|
|
|
|
|
Changing the value requires toggling `eldoc-mode'."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:group 'eldoc)
|
|
|
|
|
|
2000-07-24 00:38:34 +00:00
|
|
|
|
;;;###autoload
|
2009-11-11 19:24:20 +00:00
|
|
|
|
(defcustom eldoc-minor-mode-string (purecopy " ElDoc")
|
2009-01-17 20:01:17 +00:00
|
|
|
|
"String to display in mode line when ElDoc Mode is enabled; nil for none."
|
2002-01-08 23:57:49 +00:00
|
|
|
|
:type '(choice string (const :tag "None" nil))
|
1997-04-14 07:33:28 +00:00
|
|
|
|
:group 'eldoc)
|
1997-02-03 06:13:34 +00:00
|
|
|
|
|
2014-08-18 19:28:40 +00:00
|
|
|
|
(defcustom eldoc-argument-case #'identity
|
1995-11-12 21:04:08 +00:00
|
|
|
|
"Case to display argument names of functions, as a symbol.
|
|
|
|
|
This has two preferred values: `upcase' or `downcase'.
|
|
|
|
|
Actually, any name of a function which takes a string as an argument and
|
2009-01-16 03:24:54 +00:00
|
|
|
|
returns another string is acceptable.
|
|
|
|
|
|
2014-12-11 02:56:33 +00:00
|
|
|
|
Note that this variable has no effect, unless
|
|
|
|
|
`eldoc-documentation-function' handles it explicitly."
|
2000-07-24 00:38:34 +00:00
|
|
|
|
:type '(radio (function-item upcase)
|
|
|
|
|
(function-item downcase)
|
|
|
|
|
function)
|
1997-04-14 07:33:28 +00:00
|
|
|
|
:group 'eldoc)
|
2014-09-29 18:14:08 +00:00
|
|
|
|
(make-obsolete-variable 'eldoc-argument-case nil "25.1")
|
1995-11-12 21:04:08 +00:00
|
|
|
|
|
2000-07-24 00:38:34 +00:00
|
|
|
|
(defcustom eldoc-echo-area-use-multiline-p 'truncate-sym-name-if-fit
|
2009-01-16 03:24:54 +00:00
|
|
|
|
"Allow long ElDoc messages to resize echo area display.
|
2003-05-06 17:36:16 +00:00
|
|
|
|
If value is t, never attempt to truncate messages; complete symbol name
|
2000-07-24 00:38:34 +00:00
|
|
|
|
and function arglist or 1-line variable documentation will be displayed
|
|
|
|
|
even if echo area must be resized to fit.
|
|
|
|
|
|
2003-05-06 17:36:16 +00:00
|
|
|
|
If value is any non-nil value other than t, symbol name may be truncated
|
2000-07-24 00:38:34 +00:00
|
|
|
|
if it will enable the function arglist or documentation string to fit on a
|
|
|
|
|
single line without resizing window. Otherwise, behavior is just like
|
|
|
|
|
former case.
|
|
|
|
|
|
|
|
|
|
If value is nil, messages are always truncated to fit in a single line of
|
|
|
|
|
display in the echo area. Function or variable symbol name may be
|
2009-01-16 03:24:54 +00:00
|
|
|
|
truncated to make more of the arglist or documentation string visible.
|
|
|
|
|
|
2014-12-11 02:56:33 +00:00
|
|
|
|
Note that this variable has no effect, unless
|
|
|
|
|
`eldoc-documentation-function' handles it explicitly."
|
2000-07-24 00:38:34 +00:00
|
|
|
|
:type '(radio (const :tag "Always" t)
|
|
|
|
|
(const :tag "Never" nil)
|
|
|
|
|
(const :tag "Yes, but truncate symbol names if it will\
|
|
|
|
|
enable argument list to fit on one line" truncate-sym-name-if-fit))
|
|
|
|
|
:group 'eldoc)
|
|
|
|
|
|
2007-08-24 02:30:59 +00:00
|
|
|
|
(defface eldoc-highlight-function-argument
|
|
|
|
|
'((t (:inherit bold)))
|
2009-01-16 03:24:54 +00:00
|
|
|
|
"Face used for the argument at point in a function's argument list.
|
Introduce global-eldoc-mode. Move Elisp-specific code to elisp-mode.el.
* lisp/emacs-lisp/eldoc.el (global-eldoc-mode): New minor mode.
(eldoc-schedule-timer): Obey it.
(eldoc-documentation-function): Default to nil.
(eldoc-mode): Don't enable if eldoc-documentation-function is not set.
(eldoc-documentation-function-default, eldoc-get-fnsym-args-string)
(eldoc-highlight-function-argument, eldoc-get-var-docstring)
(eldoc-last-data-store, eldoc-docstring-first-line)
(eldoc-docstring-format-sym-doc, eldoc-fnsym-in-current-sexp)
(eldoc-beginning-of-sexp, eldoc-current-symbol)
(eldoc-function-argstring): Move to elisp-mode.el.
(eldoc-symbol-function): Remove, unused.
* lisp/progmodes/elisp-mode.el: New file. Rename all "eldoc-*" to "elisp--*".
(elisp-completion-at-point): Rename from lisp-completion-at-point.
(elisp--preceding-sexp): Rename from preceding-sexp.
* lisp/loadup.el: Load new file progmodes/elisp-mode.
* lisp/ielm.el (inferior-emacs-lisp-mode): Set eldoc-documentation-function.
* lisp/emacs-lisp/lisp.el (lisp--local-variables-1, lisp--local-variables)
(lisp--local-variables-completion-table, lisp--expect-function-p)
(lisp--form-quoted-p, lisp--company-doc-buffer)
(lisp--company-doc-string, lisp--company-location)
(lisp-completion-at-point): Move to elisp-mode.el.
* lisp/emacs-lisp/lisp-mode.el (lisp--mode-syntax-table): New syntax-table,
extracted from emacs-lisp-mode-syntax-table.
(emacs-lisp-mode-abbrev-table, emacs-lisp-mode-syntax-table): Move to
elisp-mode.el.
(lisp-imenu-generic-expression): Add comments to document what comes
from which Lisp dialect.
(emacs-lisp-mode-map, emacs-lisp-byte-compile)
(emacs-lisp-byte-compile-and-load, emacs-lisp-mode-hook)
(emacs-lisp-mode, emacs-list-byte-code-comment-re)
(emacs-lisp-byte-code-comment)
(emacs-lisp-byte-code-syntax-propertize, emacs-lisp-byte-code-mode)
(lisp-interaction-mode-map, lisp-interaction-mode)
(eval-print-last-sexp, last-sexp-setup-props)
(last-sexp-toggle-display, prin1-char, preceding-sexp)
(eval-last-sexp-1, eval-last-sexp-print-value)
(eval-last-sexp-fake-value, eval-sexp-add-defvars, eval-last-sexp)
(eval-defun-1, eval-defun-2, eval-defun): Move to elisp-mode.el.
* src/lisp.mk (lisp): Add elisp-mode.elc.
2014-09-27 03:57:41 +00:00
|
|
|
|
Note that this face has no effect unless the `eldoc-documentation-function'
|
|
|
|
|
handles it explicitly."
|
2007-08-24 02:30:59 +00:00
|
|
|
|
:group 'eldoc)
|
|
|
|
|
|
2000-07-24 00:38:34 +00:00
|
|
|
|
;;; No user options below here.
|
|
|
|
|
|
2005-10-04 21:49:09 +00:00
|
|
|
|
(defvar eldoc-message-commands-table-size 31
|
2009-01-16 03:24:54 +00:00
|
|
|
|
"Used by `eldoc-add-command' to initialize `eldoc-message-commands' obarray.
|
2005-10-04 21:49:09 +00:00
|
|
|
|
It should probably never be necessary to do so, but if you
|
|
|
|
|
choose to increase the number of buckets, you must do so before loading
|
|
|
|
|
this file since the obarray is initialized at load time.
|
|
|
|
|
Remember to keep it a prime number to improve hash performance.")
|
|
|
|
|
|
2014-10-15 17:32:41 +00:00
|
|
|
|
(defvar eldoc-message-commands
|
|
|
|
|
;; Don't define as `defconst' since it would then go to (read-only) purespace.
|
2005-10-04 21:49:09 +00:00
|
|
|
|
(make-vector eldoc-message-commands-table-size 0)
|
|
|
|
|
"Commands after which it is appropriate to print in the echo area.
|
2009-01-17 20:01:17 +00:00
|
|
|
|
ElDoc does not try to print function arglists, etc., after just any command,
|
2005-10-04 21:49:09 +00:00
|
|
|
|
because some commands print their own messages in the echo area and these
|
2007-09-26 11:55:46 +00:00
|
|
|
|
functions would instantly overwrite them. But `self-insert-command' as well
|
2005-10-04 21:49:09 +00:00
|
|
|
|
as most motion commands are good candidates.
|
|
|
|
|
This variable contains an obarray of symbols; do not manipulate it
|
|
|
|
|
directly. Instead, use `eldoc-add-command' and `eldoc-remove-command'.")
|
|
|
|
|
|
2009-01-17 20:01:17 +00:00
|
|
|
|
;; Not a constant.
|
2014-10-15 17:32:41 +00:00
|
|
|
|
(defvar eldoc-last-data (make-vector 3 nil)
|
|
|
|
|
;; Don't define as `defconst' since it would then go to (read-only) purespace.
|
2005-10-04 21:49:09 +00:00
|
|
|
|
"Bookkeeping; elements are as follows:
|
|
|
|
|
0 - contains the last symbol read from the buffer.
|
2007-07-12 01:51:52 +00:00
|
|
|
|
1 - contains the string last displayed in the echo area for variables,
|
|
|
|
|
or argument string for functions.
|
2014-10-15 17:32:41 +00:00
|
|
|
|
2 - `function' if function args, `variable' if variable documentation.")
|
|
|
|
|
(make-obsolete-variable 'eldoc-last-data "use your own instead" "25.1")
|
2009-01-17 20:01:17 +00:00
|
|
|
|
|
1997-02-19 10:24:26 +00:00
|
|
|
|
(defvar eldoc-last-message nil)
|
1995-11-12 21:04:08 +00:00
|
|
|
|
|
2009-01-16 03:24:54 +00:00
|
|
|
|
(defvar eldoc-timer nil "ElDoc's timer object.")
|
1997-02-03 06:13:34 +00:00
|
|
|
|
|
2005-10-04 21:49:09 +00:00
|
|
|
|
(defvar eldoc-current-idle-delay eldoc-idle-delay
|
2007-09-26 11:55:46 +00:00
|
|
|
|
"Idle time delay currently in use by timer.
|
2005-10-04 21:49:09 +00:00
|
|
|
|
This is used to determine if `eldoc-idle-delay' is changed by the user.")
|
1995-11-12 21:04:08 +00:00
|
|
|
|
|
2014-01-21 13:09:55 +00:00
|
|
|
|
(defvar eldoc-message-function #'eldoc-minibuffer-message
|
2013-03-17 15:00:37 +00:00
|
|
|
|
"The function used by `eldoc-message' to display messages.
|
|
|
|
|
It should receive the same arguments as `message'.")
|
|
|
|
|
|
2014-01-12 04:00:03 +00:00
|
|
|
|
(defun eldoc-edit-message-commands ()
|
|
|
|
|
(let ((cmds (make-vector 31 0))
|
|
|
|
|
(re (regexp-opt '("delete" "insert" "edit" "electric" "newline"))))
|
|
|
|
|
(mapatoms (lambda (s)
|
|
|
|
|
(and (commandp s)
|
|
|
|
|
(string-match-p re (symbol-name s))
|
|
|
|
|
(intern (symbol-name s) cmds)))
|
|
|
|
|
obarray)
|
|
|
|
|
cmds))
|
|
|
|
|
|
1995-11-12 21:04:08 +00:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
2001-11-16 23:58:48 +00:00
|
|
|
|
(define-minor-mode eldoc-mode
|
2011-10-20 00:26:14 +00:00
|
|
|
|
"Toggle echo area display of Lisp objects at point (ElDoc mode).
|
|
|
|
|
With a prefix argument ARG, enable ElDoc mode if ARG is positive,
|
|
|
|
|
and disable it otherwise. If called from Lisp, enable ElDoc mode
|
|
|
|
|
if ARG is omitted or nil.
|
|
|
|
|
|
|
|
|
|
ElDoc mode is a buffer-local minor mode. When enabled, 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."
|
2005-04-04 09:11:34 +00:00
|
|
|
|
:group 'eldoc :lighter eldoc-minor-mode-string
|
1997-02-19 10:24:26 +00:00
|
|
|
|
(setq eldoc-last-message nil)
|
Introduce global-eldoc-mode. Move Elisp-specific code to elisp-mode.el.
* lisp/emacs-lisp/eldoc.el (global-eldoc-mode): New minor mode.
(eldoc-schedule-timer): Obey it.
(eldoc-documentation-function): Default to nil.
(eldoc-mode): Don't enable if eldoc-documentation-function is not set.
(eldoc-documentation-function-default, eldoc-get-fnsym-args-string)
(eldoc-highlight-function-argument, eldoc-get-var-docstring)
(eldoc-last-data-store, eldoc-docstring-first-line)
(eldoc-docstring-format-sym-doc, eldoc-fnsym-in-current-sexp)
(eldoc-beginning-of-sexp, eldoc-current-symbol)
(eldoc-function-argstring): Move to elisp-mode.el.
(eldoc-symbol-function): Remove, unused.
* lisp/progmodes/elisp-mode.el: New file. Rename all "eldoc-*" to "elisp--*".
(elisp-completion-at-point): Rename from lisp-completion-at-point.
(elisp--preceding-sexp): Rename from preceding-sexp.
* lisp/loadup.el: Load new file progmodes/elisp-mode.
* lisp/ielm.el (inferior-emacs-lisp-mode): Set eldoc-documentation-function.
* lisp/emacs-lisp/lisp.el (lisp--local-variables-1, lisp--local-variables)
(lisp--local-variables-completion-table, lisp--expect-function-p)
(lisp--form-quoted-p, lisp--company-doc-buffer)
(lisp--company-doc-string, lisp--company-location)
(lisp-completion-at-point): Move to elisp-mode.el.
* lisp/emacs-lisp/lisp-mode.el (lisp--mode-syntax-table): New syntax-table,
extracted from emacs-lisp-mode-syntax-table.
(emacs-lisp-mode-abbrev-table, emacs-lisp-mode-syntax-table): Move to
elisp-mode.el.
(lisp-imenu-generic-expression): Add comments to document what comes
from which Lisp dialect.
(emacs-lisp-mode-map, emacs-lisp-byte-compile)
(emacs-lisp-byte-compile-and-load, emacs-lisp-mode-hook)
(emacs-lisp-mode, emacs-list-byte-code-comment-re)
(emacs-lisp-byte-code-comment)
(emacs-lisp-byte-code-syntax-propertize, emacs-lisp-byte-code-mode)
(lisp-interaction-mode-map, lisp-interaction-mode)
(eval-print-last-sexp, last-sexp-setup-props)
(last-sexp-toggle-display, prin1-char, preceding-sexp)
(eval-last-sexp-1, eval-last-sexp-print-value)
(eval-last-sexp-fake-value, eval-sexp-add-defvars, eval-last-sexp)
(eval-defun-1, eval-defun-2, eval-defun): Move to elisp-mode.el.
* src/lisp.mk (lisp): Add elisp-mode.elc.
2014-09-27 03:57:41 +00:00
|
|
|
|
(cond
|
2014-12-11 02:56:33 +00:00
|
|
|
|
((memq eldoc-documentation-function '(nil ignore))
|
Introduce global-eldoc-mode. Move Elisp-specific code to elisp-mode.el.
* lisp/emacs-lisp/eldoc.el (global-eldoc-mode): New minor mode.
(eldoc-schedule-timer): Obey it.
(eldoc-documentation-function): Default to nil.
(eldoc-mode): Don't enable if eldoc-documentation-function is not set.
(eldoc-documentation-function-default, eldoc-get-fnsym-args-string)
(eldoc-highlight-function-argument, eldoc-get-var-docstring)
(eldoc-last-data-store, eldoc-docstring-first-line)
(eldoc-docstring-format-sym-doc, eldoc-fnsym-in-current-sexp)
(eldoc-beginning-of-sexp, eldoc-current-symbol)
(eldoc-function-argstring): Move to elisp-mode.el.
(eldoc-symbol-function): Remove, unused.
* lisp/progmodes/elisp-mode.el: New file. Rename all "eldoc-*" to "elisp--*".
(elisp-completion-at-point): Rename from lisp-completion-at-point.
(elisp--preceding-sexp): Rename from preceding-sexp.
* lisp/loadup.el: Load new file progmodes/elisp-mode.
* lisp/ielm.el (inferior-emacs-lisp-mode): Set eldoc-documentation-function.
* lisp/emacs-lisp/lisp.el (lisp--local-variables-1, lisp--local-variables)
(lisp--local-variables-completion-table, lisp--expect-function-p)
(lisp--form-quoted-p, lisp--company-doc-buffer)
(lisp--company-doc-string, lisp--company-location)
(lisp-completion-at-point): Move to elisp-mode.el.
* lisp/emacs-lisp/lisp-mode.el (lisp--mode-syntax-table): New syntax-table,
extracted from emacs-lisp-mode-syntax-table.
(emacs-lisp-mode-abbrev-table, emacs-lisp-mode-syntax-table): Move to
elisp-mode.el.
(lisp-imenu-generic-expression): Add comments to document what comes
from which Lisp dialect.
(emacs-lisp-mode-map, emacs-lisp-byte-compile)
(emacs-lisp-byte-compile-and-load, emacs-lisp-mode-hook)
(emacs-lisp-mode, emacs-list-byte-code-comment-re)
(emacs-lisp-byte-code-comment)
(emacs-lisp-byte-code-syntax-propertize, emacs-lisp-byte-code-mode)
(lisp-interaction-mode-map, lisp-interaction-mode)
(eval-print-last-sexp, last-sexp-setup-props)
(last-sexp-toggle-display, prin1-char, preceding-sexp)
(eval-last-sexp-1, eval-last-sexp-print-value)
(eval-last-sexp-fake-value, eval-sexp-add-defvars, eval-last-sexp)
(eval-defun-1, eval-defun-2, eval-defun): Move to elisp-mode.el.
* src/lisp.mk (lisp): Add elisp-mode.elc.
2014-09-27 03:57:41 +00:00
|
|
|
|
(message "There is no ElDoc support in this buffer")
|
|
|
|
|
(setq eldoc-mode nil))
|
|
|
|
|
(eldoc-mode
|
|
|
|
|
(when eldoc-print-after-edit
|
|
|
|
|
(setq-local eldoc-message-commands (eldoc-edit-message-commands)))
|
|
|
|
|
(add-hook 'post-command-hook 'eldoc-schedule-timer nil t)
|
|
|
|
|
(add-hook 'pre-command-hook 'eldoc-pre-command-refresh-echo-area nil t))
|
|
|
|
|
(t
|
|
|
|
|
(kill-local-variable 'eldoc-message-commands)
|
|
|
|
|
(remove-hook 'post-command-hook 'eldoc-schedule-timer t)
|
|
|
|
|
(remove-hook 'pre-command-hook 'eldoc-pre-command-refresh-echo-area t))))
|
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(define-minor-mode global-eldoc-mode
|
|
|
|
|
"Enable `eldoc-mode' in all buffers where it's applicable."
|
|
|
|
|
:group 'eldoc :global t
|
2014-10-15 17:32:41 +00:00
|
|
|
|
:initialize 'custom-initialize-delay
|
|
|
|
|
:init-value t
|
Introduce global-eldoc-mode. Move Elisp-specific code to elisp-mode.el.
* lisp/emacs-lisp/eldoc.el (global-eldoc-mode): New minor mode.
(eldoc-schedule-timer): Obey it.
(eldoc-documentation-function): Default to nil.
(eldoc-mode): Don't enable if eldoc-documentation-function is not set.
(eldoc-documentation-function-default, eldoc-get-fnsym-args-string)
(eldoc-highlight-function-argument, eldoc-get-var-docstring)
(eldoc-last-data-store, eldoc-docstring-first-line)
(eldoc-docstring-format-sym-doc, eldoc-fnsym-in-current-sexp)
(eldoc-beginning-of-sexp, eldoc-current-symbol)
(eldoc-function-argstring): Move to elisp-mode.el.
(eldoc-symbol-function): Remove, unused.
* lisp/progmodes/elisp-mode.el: New file. Rename all "eldoc-*" to "elisp--*".
(elisp-completion-at-point): Rename from lisp-completion-at-point.
(elisp--preceding-sexp): Rename from preceding-sexp.
* lisp/loadup.el: Load new file progmodes/elisp-mode.
* lisp/ielm.el (inferior-emacs-lisp-mode): Set eldoc-documentation-function.
* lisp/emacs-lisp/lisp.el (lisp--local-variables-1, lisp--local-variables)
(lisp--local-variables-completion-table, lisp--expect-function-p)
(lisp--form-quoted-p, lisp--company-doc-buffer)
(lisp--company-doc-string, lisp--company-location)
(lisp-completion-at-point): Move to elisp-mode.el.
* lisp/emacs-lisp/lisp-mode.el (lisp--mode-syntax-table): New syntax-table,
extracted from emacs-lisp-mode-syntax-table.
(emacs-lisp-mode-abbrev-table, emacs-lisp-mode-syntax-table): Move to
elisp-mode.el.
(lisp-imenu-generic-expression): Add comments to document what comes
from which Lisp dialect.
(emacs-lisp-mode-map, emacs-lisp-byte-compile)
(emacs-lisp-byte-compile-and-load, emacs-lisp-mode-hook)
(emacs-lisp-mode, emacs-list-byte-code-comment-re)
(emacs-lisp-byte-code-comment)
(emacs-lisp-byte-code-syntax-propertize, emacs-lisp-byte-code-mode)
(lisp-interaction-mode-map, lisp-interaction-mode)
(eval-print-last-sexp, last-sexp-setup-props)
(last-sexp-toggle-display, prin1-char, preceding-sexp)
(eval-last-sexp-1, eval-last-sexp-print-value)
(eval-last-sexp-fake-value, eval-sexp-add-defvars, eval-last-sexp)
(eval-defun-1, eval-defun-2, eval-defun): Move to elisp-mode.el.
* src/lisp.mk (lisp): Add elisp-mode.elc.
2014-09-27 03:57:41 +00:00
|
|
|
|
(setq eldoc-last-message nil)
|
|
|
|
|
(if global-eldoc-mode
|
2003-02-11 00:11:55 +00:00
|
|
|
|
(progn
|
Introduce global-eldoc-mode. Move Elisp-specific code to elisp-mode.el.
* lisp/emacs-lisp/eldoc.el (global-eldoc-mode): New minor mode.
(eldoc-schedule-timer): Obey it.
(eldoc-documentation-function): Default to nil.
(eldoc-mode): Don't enable if eldoc-documentation-function is not set.
(eldoc-documentation-function-default, eldoc-get-fnsym-args-string)
(eldoc-highlight-function-argument, eldoc-get-var-docstring)
(eldoc-last-data-store, eldoc-docstring-first-line)
(eldoc-docstring-format-sym-doc, eldoc-fnsym-in-current-sexp)
(eldoc-beginning-of-sexp, eldoc-current-symbol)
(eldoc-function-argstring): Move to elisp-mode.el.
(eldoc-symbol-function): Remove, unused.
* lisp/progmodes/elisp-mode.el: New file. Rename all "eldoc-*" to "elisp--*".
(elisp-completion-at-point): Rename from lisp-completion-at-point.
(elisp--preceding-sexp): Rename from preceding-sexp.
* lisp/loadup.el: Load new file progmodes/elisp-mode.
* lisp/ielm.el (inferior-emacs-lisp-mode): Set eldoc-documentation-function.
* lisp/emacs-lisp/lisp.el (lisp--local-variables-1, lisp--local-variables)
(lisp--local-variables-completion-table, lisp--expect-function-p)
(lisp--form-quoted-p, lisp--company-doc-buffer)
(lisp--company-doc-string, lisp--company-location)
(lisp-completion-at-point): Move to elisp-mode.el.
* lisp/emacs-lisp/lisp-mode.el (lisp--mode-syntax-table): New syntax-table,
extracted from emacs-lisp-mode-syntax-table.
(emacs-lisp-mode-abbrev-table, emacs-lisp-mode-syntax-table): Move to
elisp-mode.el.
(lisp-imenu-generic-expression): Add comments to document what comes
from which Lisp dialect.
(emacs-lisp-mode-map, emacs-lisp-byte-compile)
(emacs-lisp-byte-compile-and-load, emacs-lisp-mode-hook)
(emacs-lisp-mode, emacs-list-byte-code-comment-re)
(emacs-lisp-byte-code-comment)
(emacs-lisp-byte-code-syntax-propertize, emacs-lisp-byte-code-mode)
(lisp-interaction-mode-map, lisp-interaction-mode)
(eval-print-last-sexp, last-sexp-setup-props)
(last-sexp-toggle-display, prin1-char, preceding-sexp)
(eval-last-sexp-1, eval-last-sexp-print-value)
(eval-last-sexp-fake-value, eval-sexp-add-defvars, eval-last-sexp)
(eval-defun-1, eval-defun-2, eval-defun): Move to elisp-mode.el.
* src/lisp.mk (lisp): Add elisp-mode.elc.
2014-09-27 03:57:41 +00:00
|
|
|
|
(add-hook 'post-command-hook #'eldoc-schedule-timer)
|
|
|
|
|
(add-hook 'pre-command-hook #'eldoc-pre-command-refresh-echo-area))
|
|
|
|
|
(remove-hook 'post-command-hook #'eldoc-schedule-timer)
|
|
|
|
|
(remove-hook 'pre-command-hook #'eldoc-pre-command-refresh-echo-area)))
|
2013-03-17 15:00:37 +00:00
|
|
|
|
|
1995-11-12 21:04:08 +00:00
|
|
|
|
;;;###autoload
|
2014-01-21 13:09:55 +00:00
|
|
|
|
(define-obsolete-function-alias 'turn-on-eldoc-mode 'eldoc-mode "24.4")
|
1995-11-12 21:04:08 +00:00
|
|
|
|
|
1998-09-19 02:15:26 +00:00
|
|
|
|
|
1997-02-03 06:13:34 +00:00
|
|
|
|
(defun eldoc-schedule-timer ()
|
|
|
|
|
(or (and eldoc-timer
|
Introduce global-eldoc-mode. Move Elisp-specific code to elisp-mode.el.
* lisp/emacs-lisp/eldoc.el (global-eldoc-mode): New minor mode.
(eldoc-schedule-timer): Obey it.
(eldoc-documentation-function): Default to nil.
(eldoc-mode): Don't enable if eldoc-documentation-function is not set.
(eldoc-documentation-function-default, eldoc-get-fnsym-args-string)
(eldoc-highlight-function-argument, eldoc-get-var-docstring)
(eldoc-last-data-store, eldoc-docstring-first-line)
(eldoc-docstring-format-sym-doc, eldoc-fnsym-in-current-sexp)
(eldoc-beginning-of-sexp, eldoc-current-symbol)
(eldoc-function-argstring): Move to elisp-mode.el.
(eldoc-symbol-function): Remove, unused.
* lisp/progmodes/elisp-mode.el: New file. Rename all "eldoc-*" to "elisp--*".
(elisp-completion-at-point): Rename from lisp-completion-at-point.
(elisp--preceding-sexp): Rename from preceding-sexp.
* lisp/loadup.el: Load new file progmodes/elisp-mode.
* lisp/ielm.el (inferior-emacs-lisp-mode): Set eldoc-documentation-function.
* lisp/emacs-lisp/lisp.el (lisp--local-variables-1, lisp--local-variables)
(lisp--local-variables-completion-table, lisp--expect-function-p)
(lisp--form-quoted-p, lisp--company-doc-buffer)
(lisp--company-doc-string, lisp--company-location)
(lisp-completion-at-point): Move to elisp-mode.el.
* lisp/emacs-lisp/lisp-mode.el (lisp--mode-syntax-table): New syntax-table,
extracted from emacs-lisp-mode-syntax-table.
(emacs-lisp-mode-abbrev-table, emacs-lisp-mode-syntax-table): Move to
elisp-mode.el.
(lisp-imenu-generic-expression): Add comments to document what comes
from which Lisp dialect.
(emacs-lisp-mode-map, emacs-lisp-byte-compile)
(emacs-lisp-byte-compile-and-load, emacs-lisp-mode-hook)
(emacs-lisp-mode, emacs-list-byte-code-comment-re)
(emacs-lisp-byte-code-comment)
(emacs-lisp-byte-code-syntax-propertize, emacs-lisp-byte-code-mode)
(lisp-interaction-mode-map, lisp-interaction-mode)
(eval-print-last-sexp, last-sexp-setup-props)
(last-sexp-toggle-display, prin1-char, preceding-sexp)
(eval-last-sexp-1, eval-last-sexp-print-value)
(eval-last-sexp-fake-value, eval-sexp-add-defvars, eval-last-sexp)
(eval-defun-1, eval-defun-2, eval-defun): Move to elisp-mode.el.
* src/lisp.mk (lisp): Add elisp-mode.elc.
2014-09-27 03:57:41 +00:00
|
|
|
|
(memq eldoc-timer timer-idle-list)) ;FIXME: Why?
|
1997-02-03 06:13:34 +00:00
|
|
|
|
(setq eldoc-timer
|
2013-03-18 09:16:15 +00:00
|
|
|
|
(run-with-idle-timer
|
2015-07-21 13:57:58 +00:00
|
|
|
|
eldoc-idle-delay nil
|
Introduce global-eldoc-mode. Move Elisp-specific code to elisp-mode.el.
* lisp/emacs-lisp/eldoc.el (global-eldoc-mode): New minor mode.
(eldoc-schedule-timer): Obey it.
(eldoc-documentation-function): Default to nil.
(eldoc-mode): Don't enable if eldoc-documentation-function is not set.
(eldoc-documentation-function-default, eldoc-get-fnsym-args-string)
(eldoc-highlight-function-argument, eldoc-get-var-docstring)
(eldoc-last-data-store, eldoc-docstring-first-line)
(eldoc-docstring-format-sym-doc, eldoc-fnsym-in-current-sexp)
(eldoc-beginning-of-sexp, eldoc-current-symbol)
(eldoc-function-argstring): Move to elisp-mode.el.
(eldoc-symbol-function): Remove, unused.
* lisp/progmodes/elisp-mode.el: New file. Rename all "eldoc-*" to "elisp--*".
(elisp-completion-at-point): Rename from lisp-completion-at-point.
(elisp--preceding-sexp): Rename from preceding-sexp.
* lisp/loadup.el: Load new file progmodes/elisp-mode.
* lisp/ielm.el (inferior-emacs-lisp-mode): Set eldoc-documentation-function.
* lisp/emacs-lisp/lisp.el (lisp--local-variables-1, lisp--local-variables)
(lisp--local-variables-completion-table, lisp--expect-function-p)
(lisp--form-quoted-p, lisp--company-doc-buffer)
(lisp--company-doc-string, lisp--company-location)
(lisp-completion-at-point): Move to elisp-mode.el.
* lisp/emacs-lisp/lisp-mode.el (lisp--mode-syntax-table): New syntax-table,
extracted from emacs-lisp-mode-syntax-table.
(emacs-lisp-mode-abbrev-table, emacs-lisp-mode-syntax-table): Move to
elisp-mode.el.
(lisp-imenu-generic-expression): Add comments to document what comes
from which Lisp dialect.
(emacs-lisp-mode-map, emacs-lisp-byte-compile)
(emacs-lisp-byte-compile-and-load, emacs-lisp-mode-hook)
(emacs-lisp-mode, emacs-list-byte-code-comment-re)
(emacs-lisp-byte-code-comment)
(emacs-lisp-byte-code-syntax-propertize, emacs-lisp-byte-code-mode)
(lisp-interaction-mode-map, lisp-interaction-mode)
(eval-print-last-sexp, last-sexp-setup-props)
(last-sexp-toggle-display, prin1-char, preceding-sexp)
(eval-last-sexp-1, eval-last-sexp-print-value)
(eval-last-sexp-fake-value, eval-sexp-add-defvars, eval-last-sexp)
(eval-defun-1, eval-defun-2, eval-defun): Move to elisp-mode.el.
* src/lisp.mk (lisp): Add elisp-mode.elc.
2014-09-27 03:57:41 +00:00
|
|
|
|
(lambda ()
|
|
|
|
|
(when (or eldoc-mode
|
2014-12-11 02:56:33 +00:00
|
|
|
|
(and global-eldoc-mode
|
|
|
|
|
(not (memq eldoc-documentation-function
|
|
|
|
|
'(nil ignore)))))
|
Introduce global-eldoc-mode. Move Elisp-specific code to elisp-mode.el.
* lisp/emacs-lisp/eldoc.el (global-eldoc-mode): New minor mode.
(eldoc-schedule-timer): Obey it.
(eldoc-documentation-function): Default to nil.
(eldoc-mode): Don't enable if eldoc-documentation-function is not set.
(eldoc-documentation-function-default, eldoc-get-fnsym-args-string)
(eldoc-highlight-function-argument, eldoc-get-var-docstring)
(eldoc-last-data-store, eldoc-docstring-first-line)
(eldoc-docstring-format-sym-doc, eldoc-fnsym-in-current-sexp)
(eldoc-beginning-of-sexp, eldoc-current-symbol)
(eldoc-function-argstring): Move to elisp-mode.el.
(eldoc-symbol-function): Remove, unused.
* lisp/progmodes/elisp-mode.el: New file. Rename all "eldoc-*" to "elisp--*".
(elisp-completion-at-point): Rename from lisp-completion-at-point.
(elisp--preceding-sexp): Rename from preceding-sexp.
* lisp/loadup.el: Load new file progmodes/elisp-mode.
* lisp/ielm.el (inferior-emacs-lisp-mode): Set eldoc-documentation-function.
* lisp/emacs-lisp/lisp.el (lisp--local-variables-1, lisp--local-variables)
(lisp--local-variables-completion-table, lisp--expect-function-p)
(lisp--form-quoted-p, lisp--company-doc-buffer)
(lisp--company-doc-string, lisp--company-location)
(lisp-completion-at-point): Move to elisp-mode.el.
* lisp/emacs-lisp/lisp-mode.el (lisp--mode-syntax-table): New syntax-table,
extracted from emacs-lisp-mode-syntax-table.
(emacs-lisp-mode-abbrev-table, emacs-lisp-mode-syntax-table): Move to
elisp-mode.el.
(lisp-imenu-generic-expression): Add comments to document what comes
from which Lisp dialect.
(emacs-lisp-mode-map, emacs-lisp-byte-compile)
(emacs-lisp-byte-compile-and-load, emacs-lisp-mode-hook)
(emacs-lisp-mode, emacs-list-byte-code-comment-re)
(emacs-lisp-byte-code-comment)
(emacs-lisp-byte-code-syntax-propertize, emacs-lisp-byte-code-mode)
(lisp-interaction-mode-map, lisp-interaction-mode)
(eval-print-last-sexp, last-sexp-setup-props)
(last-sexp-toggle-display, prin1-char, preceding-sexp)
(eval-last-sexp-1, eval-last-sexp-print-value)
(eval-last-sexp-fake-value, eval-sexp-add-defvars, eval-last-sexp)
(eval-defun-1, eval-defun-2, eval-defun): Move to elisp-mode.el.
* src/lisp.mk (lisp): Add elisp-mode.elc.
2014-09-27 03:57:41 +00:00
|
|
|
|
(eldoc-print-current-symbol-info))))))
|
1997-02-03 06:13:34 +00:00
|
|
|
|
|
|
|
|
|
;; If user has changed the idle delay, update the timer.
|
|
|
|
|
(cond ((not (= eldoc-idle-delay eldoc-current-idle-delay))
|
|
|
|
|
(setq eldoc-current-idle-delay eldoc-idle-delay)
|
|
|
|
|
(timer-set-idle-time eldoc-timer eldoc-idle-delay t))))
|
|
|
|
|
|
2013-03-17 15:00:37 +00:00
|
|
|
|
(defvar eldoc-mode-line-string nil)
|
|
|
|
|
(put 'eldoc-mode-line-string 'risky-local-variable t)
|
|
|
|
|
|
|
|
|
|
(defun eldoc-minibuffer-message (format-string &rest args)
|
|
|
|
|
"Display messages in the mode-line when in the minibuffer.
|
|
|
|
|
Otherwise work like `message'."
|
|
|
|
|
(if (minibufferp)
|
|
|
|
|
(progn
|
2013-12-04 04:42:01 +00:00
|
|
|
|
(add-hook 'minibuffer-exit-hook
|
2014-03-10 05:33:31 +00:00
|
|
|
|
(lambda () (setq eldoc-mode-line-string nil
|
|
|
|
|
;; http://debbugs.gnu.org/16920
|
|
|
|
|
eldoc-last-message nil))
|
2013-12-04 04:42:01 +00:00
|
|
|
|
nil t)
|
2013-03-17 15:00:37 +00:00
|
|
|
|
(with-current-buffer
|
|
|
|
|
(window-buffer
|
|
|
|
|
(or (window-in-direction 'above (minibuffer-window))
|
|
|
|
|
(minibuffer-selected-window)
|
|
|
|
|
(get-largest-window)))
|
|
|
|
|
(unless (and (listp mode-line-format)
|
|
|
|
|
(assq 'eldoc-mode-line-string mode-line-format))
|
|
|
|
|
(setq mode-line-format
|
|
|
|
|
(list "" '(eldoc-mode-line-string
|
|
|
|
|
(" " eldoc-mode-line-string " "))
|
2013-12-04 04:42:01 +00:00
|
|
|
|
mode-line-format)))
|
|
|
|
|
(setq eldoc-mode-line-string
|
|
|
|
|
(when (stringp format-string)
|
|
|
|
|
(apply 'format format-string args)))
|
|
|
|
|
(force-mode-line-update)))
|
2013-03-17 15:00:37 +00:00
|
|
|
|
(apply 'message format-string args)))
|
|
|
|
|
|
1997-02-19 10:24:26 +00:00
|
|
|
|
(defun eldoc-message (&rest args)
|
|
|
|
|
(let ((omessage eldoc-last-message))
|
2003-05-06 17:36:16 +00:00
|
|
|
|
(setq eldoc-last-message
|
2003-02-11 00:11:55 +00:00
|
|
|
|
(cond ((eq (car args) eldoc-last-message) eldoc-last-message)
|
|
|
|
|
((null (car args)) nil)
|
|
|
|
|
;; If only one arg, no formatting to do, so put it in
|
|
|
|
|
;; eldoc-last-message so eq test above might succeed on
|
|
|
|
|
;; subsequent calls.
|
|
|
|
|
((null (cdr args)) (car args))
|
|
|
|
|
(t (apply 'format args))))
|
1997-02-19 10:24:26 +00:00
|
|
|
|
;; In emacs 19.29 and later, and XEmacs 19.13 and later, all messages
|
|
|
|
|
;; are recorded in a log. Do not put eldoc messages in that log since
|
|
|
|
|
;; they are Legion.
|
2003-02-11 00:11:55 +00:00
|
|
|
|
;; Emacs way of preventing log messages.
|
|
|
|
|
(let ((message-log-max nil))
|
2013-03-17 15:00:37 +00:00
|
|
|
|
(cond (eldoc-last-message
|
|
|
|
|
(funcall eldoc-message-function "%s" eldoc-last-message))
|
|
|
|
|
(omessage (funcall eldoc-message-function nil)))))
|
1997-02-19 10:24:26 +00:00
|
|
|
|
eldoc-last-message)
|
|
|
|
|
|
2014-01-21 13:09:55 +00:00
|
|
|
|
(defun eldoc--message-command-p (command)
|
|
|
|
|
(and (symbolp command)
|
|
|
|
|
(intern-soft (symbol-name command) eldoc-message-commands)))
|
|
|
|
|
|
1998-09-19 02:15:26 +00:00
|
|
|
|
;; This function goes on pre-command-hook for XEmacs or when using idle
|
|
|
|
|
;; timers in Emacs. Motion commands clear the echo area for some reason,
|
|
|
|
|
;; which make eldoc messages flicker or disappear just before motion
|
|
|
|
|
;; begins. This function reprints the last eldoc message immediately
|
|
|
|
|
;; before the next command executes, which does away with the flicker.
|
|
|
|
|
;; This doesn't seem to be required for Emacs 19.28 and earlier.
|
|
|
|
|
(defun eldoc-pre-command-refresh-echo-area ()
|
|
|
|
|
(and eldoc-last-message
|
2014-01-21 13:09:55 +00:00
|
|
|
|
(not (minibufferp)) ;We don't use the echo area when in minibuffer.
|
2014-01-12 04:00:03 +00:00
|
|
|
|
(if (and (eldoc-display-message-no-interference-p)
|
2014-01-21 13:09:55 +00:00
|
|
|
|
(eldoc--message-command-p this-command))
|
2014-01-12 04:00:03 +00:00
|
|
|
|
(eldoc-message eldoc-last-message)
|
2014-01-21 13:09:55 +00:00
|
|
|
|
;; No need to call eldoc-message since the echo area will be cleared
|
|
|
|
|
;; for us, but do note that the last-message will be gone.
|
1998-09-19 02:15:26 +00:00
|
|
|
|
(setq eldoc-last-message nil))))
|
1997-02-04 18:21:29 +00:00
|
|
|
|
|
|
|
|
|
;; Decide whether now is a good time to display a message.
|
|
|
|
|
(defun eldoc-display-message-p ()
|
1997-02-19 10:24:26 +00:00
|
|
|
|
(and (eldoc-display-message-no-interference-p)
|
2013-03-18 09:16:15 +00:00
|
|
|
|
;; If this-command is non-nil while running via an idle
|
|
|
|
|
;; timer, we're still in the middle of executing a command,
|
|
|
|
|
;; e.g. a query-replace where it would be annoying to
|
|
|
|
|
;; overwrite the echo area.
|
2014-01-21 13:09:55 +00:00
|
|
|
|
(not this-command)
|
|
|
|
|
(eldoc--message-command-p last-command)))
|
|
|
|
|
|
1995-11-12 21:04:08 +00:00
|
|
|
|
|
2000-07-24 00:38:34 +00:00
|
|
|
|
;; Check various conditions about the current environment that might make
|
|
|
|
|
;; it undesirable to print eldoc messages right this instant.
|
1997-02-19 10:24:26 +00:00
|
|
|
|
(defun eldoc-display-message-no-interference-p ()
|
2014-01-12 04:00:03 +00:00
|
|
|
|
(not (or executing-kbd-macro (bound-and-true-p edebug-active))))
|
1997-02-19 10:24:26 +00:00
|
|
|
|
|
1998-09-19 02:15:26 +00:00
|
|
|
|
|
2005-05-14 11:25:31 +00:00
|
|
|
|
;;;###autoload
|
2014-12-11 02:56:33 +00:00
|
|
|
|
(defvar eldoc-documentation-function #'ignore
|
2014-03-31 01:31:17 +00:00
|
|
|
|
"Function to call to return doc string.
|
2003-09-06 17:32:31 +00:00
|
|
|
|
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.
|
|
|
|
|
|
2009-01-16 03:24:54 +00:00
|
|
|
|
The result is used as is, so the function must explicitly handle
|
|
|
|
|
the variables `eldoc-argument-case' and `eldoc-echo-area-use-multiline-p',
|
|
|
|
|
and the face `eldoc-highlight-function-argument', if they are to have any
|
|
|
|
|
effect.
|
|
|
|
|
|
2014-12-05 18:34:42 +00:00
|
|
|
|
Major modes should modify this variable using `add-function', for example:
|
|
|
|
|
(add-function :before-until (local 'eldoc-documentation-function)
|
|
|
|
|
#'foo-mode-eldoc-function)
|
|
|
|
|
so that the global documentation function (i.e. the default value of the
|
|
|
|
|
variable) is taken into account if the major mode specific function does not
|
|
|
|
|
return any documentation.")
|
2003-09-06 17:32:31 +00:00
|
|
|
|
|
1998-09-19 02:15:26 +00:00
|
|
|
|
(defun eldoc-print-current-symbol-info ()
|
2013-09-12 05:32:57 +00:00
|
|
|
|
;; This is run from post-command-hook or some idle timer thing,
|
|
|
|
|
;; so we need to be careful that errors aren't ignored.
|
|
|
|
|
(with-demoted-errors "eldoc error: %s"
|
2014-01-21 13:09:55 +00:00
|
|
|
|
(and (or (eldoc-display-message-p)
|
|
|
|
|
;; Erase the last message if we won't display a new one.
|
|
|
|
|
(when eldoc-last-message
|
|
|
|
|
(eldoc-message nil)
|
|
|
|
|
nil))
|
2014-03-31 01:31:17 +00:00
|
|
|
|
(eldoc-message (funcall eldoc-documentation-function)))))
|
|
|
|
|
|
2015-05-06 02:18:19 +00:00
|
|
|
|
;; If the entire line cannot fit in the echo area, the symbol name may be
|
|
|
|
|
;; truncated or eliminated entirely from the output to make room for the
|
|
|
|
|
;; description.
|
|
|
|
|
(defun eldoc-docstring-format-sym-doc (prefix doc &optional face)
|
|
|
|
|
(when (symbolp prefix)
|
|
|
|
|
(setq prefix (concat (propertize (symbol-name prefix) 'face face) ": ")))
|
|
|
|
|
(let* ((ea-multi eldoc-echo-area-use-multiline-p)
|
|
|
|
|
;; Subtract 1 from window width since emacs will not write
|
|
|
|
|
;; any chars to the last column, or in later versions, will
|
|
|
|
|
;; cause a wraparound and resize of the echo area.
|
|
|
|
|
(ea-width (1- (window-width (minibuffer-window))))
|
|
|
|
|
(strip (- (+ (length prefix) (length doc)) ea-width)))
|
|
|
|
|
(cond ((or (<= strip 0)
|
|
|
|
|
(eq ea-multi t)
|
|
|
|
|
(and ea-multi (> (length doc) ea-width)))
|
|
|
|
|
(concat prefix doc))
|
|
|
|
|
((> (length doc) ea-width)
|
|
|
|
|
(substring (format "%s" doc) 0 ea-width))
|
|
|
|
|
((>= strip (string-match-p ":? *\\'" prefix))
|
|
|
|
|
doc)
|
|
|
|
|
(t
|
|
|
|
|
;; Show the end of the partial symbol name, rather
|
|
|
|
|
;; than the beginning, since the former is more likely
|
|
|
|
|
;; to be unique given package namespace conventions.
|
|
|
|
|
(concat (substring prefix strip) doc)))))
|
|
|
|
|
|
1997-02-19 10:24:26 +00:00
|
|
|
|
;; When point is in a sexp, the function args are not reprinted in the echo
|
|
|
|
|
;; area after every possible interactive command because some of them print
|
|
|
|
|
;; their own messages in the echo area; the eldoc functions would instantly
|
|
|
|
|
;; overwrite them unless it is more restrained.
|
|
|
|
|
;; These functions do display-command table management.
|
|
|
|
|
|
|
|
|
|
(defun eldoc-add-command (&rest cmds)
|
2005-10-04 21:49:09 +00:00
|
|
|
|
(dolist (name cmds)
|
|
|
|
|
(and (symbolp name)
|
|
|
|
|
(setq name (symbol-name name)))
|
|
|
|
|
(set (intern name eldoc-message-commands) t)))
|
1997-02-19 10:24:26 +00:00
|
|
|
|
|
|
|
|
|
(defun eldoc-add-command-completions (&rest names)
|
2005-10-04 21:49:09 +00:00
|
|
|
|
(dolist (name names)
|
Introduce global-eldoc-mode. Move Elisp-specific code to elisp-mode.el.
* lisp/emacs-lisp/eldoc.el (global-eldoc-mode): New minor mode.
(eldoc-schedule-timer): Obey it.
(eldoc-documentation-function): Default to nil.
(eldoc-mode): Don't enable if eldoc-documentation-function is not set.
(eldoc-documentation-function-default, eldoc-get-fnsym-args-string)
(eldoc-highlight-function-argument, eldoc-get-var-docstring)
(eldoc-last-data-store, eldoc-docstring-first-line)
(eldoc-docstring-format-sym-doc, eldoc-fnsym-in-current-sexp)
(eldoc-beginning-of-sexp, eldoc-current-symbol)
(eldoc-function-argstring): Move to elisp-mode.el.
(eldoc-symbol-function): Remove, unused.
* lisp/progmodes/elisp-mode.el: New file. Rename all "eldoc-*" to "elisp--*".
(elisp-completion-at-point): Rename from lisp-completion-at-point.
(elisp--preceding-sexp): Rename from preceding-sexp.
* lisp/loadup.el: Load new file progmodes/elisp-mode.
* lisp/ielm.el (inferior-emacs-lisp-mode): Set eldoc-documentation-function.
* lisp/emacs-lisp/lisp.el (lisp--local-variables-1, lisp--local-variables)
(lisp--local-variables-completion-table, lisp--expect-function-p)
(lisp--form-quoted-p, lisp--company-doc-buffer)
(lisp--company-doc-string, lisp--company-location)
(lisp-completion-at-point): Move to elisp-mode.el.
* lisp/emacs-lisp/lisp-mode.el (lisp--mode-syntax-table): New syntax-table,
extracted from emacs-lisp-mode-syntax-table.
(emacs-lisp-mode-abbrev-table, emacs-lisp-mode-syntax-table): Move to
elisp-mode.el.
(lisp-imenu-generic-expression): Add comments to document what comes
from which Lisp dialect.
(emacs-lisp-mode-map, emacs-lisp-byte-compile)
(emacs-lisp-byte-compile-and-load, emacs-lisp-mode-hook)
(emacs-lisp-mode, emacs-list-byte-code-comment-re)
(emacs-lisp-byte-code-comment)
(emacs-lisp-byte-code-syntax-propertize, emacs-lisp-byte-code-mode)
(lisp-interaction-mode-map, lisp-interaction-mode)
(eval-print-last-sexp, last-sexp-setup-props)
(last-sexp-toggle-display, prin1-char, preceding-sexp)
(eval-last-sexp-1, eval-last-sexp-print-value)
(eval-last-sexp-fake-value, eval-sexp-add-defvars, eval-last-sexp)
(eval-defun-1, eval-defun-2, eval-defun): Move to elisp-mode.el.
* src/lisp.mk (lisp): Add elisp-mode.elc.
2014-09-27 03:57:41 +00:00
|
|
|
|
(apply #'eldoc-add-command (all-completions name obarray 'commandp))))
|
1997-02-19 10:24:26 +00:00
|
|
|
|
|
|
|
|
|
(defun eldoc-remove-command (&rest cmds)
|
2005-10-04 21:49:09 +00:00
|
|
|
|
(dolist (name cmds)
|
|
|
|
|
(and (symbolp name)
|
|
|
|
|
(setq name (symbol-name name)))
|
|
|
|
|
(unintern name eldoc-message-commands)))
|
1997-02-19 10:24:26 +00:00
|
|
|
|
|
|
|
|
|
(defun eldoc-remove-command-completions (&rest names)
|
2005-10-04 21:49:09 +00:00
|
|
|
|
(dolist (name names)
|
Introduce global-eldoc-mode. Move Elisp-specific code to elisp-mode.el.
* lisp/emacs-lisp/eldoc.el (global-eldoc-mode): New minor mode.
(eldoc-schedule-timer): Obey it.
(eldoc-documentation-function): Default to nil.
(eldoc-mode): Don't enable if eldoc-documentation-function is not set.
(eldoc-documentation-function-default, eldoc-get-fnsym-args-string)
(eldoc-highlight-function-argument, eldoc-get-var-docstring)
(eldoc-last-data-store, eldoc-docstring-first-line)
(eldoc-docstring-format-sym-doc, eldoc-fnsym-in-current-sexp)
(eldoc-beginning-of-sexp, eldoc-current-symbol)
(eldoc-function-argstring): Move to elisp-mode.el.
(eldoc-symbol-function): Remove, unused.
* lisp/progmodes/elisp-mode.el: New file. Rename all "eldoc-*" to "elisp--*".
(elisp-completion-at-point): Rename from lisp-completion-at-point.
(elisp--preceding-sexp): Rename from preceding-sexp.
* lisp/loadup.el: Load new file progmodes/elisp-mode.
* lisp/ielm.el (inferior-emacs-lisp-mode): Set eldoc-documentation-function.
* lisp/emacs-lisp/lisp.el (lisp--local-variables-1, lisp--local-variables)
(lisp--local-variables-completion-table, lisp--expect-function-p)
(lisp--form-quoted-p, lisp--company-doc-buffer)
(lisp--company-doc-string, lisp--company-location)
(lisp-completion-at-point): Move to elisp-mode.el.
* lisp/emacs-lisp/lisp-mode.el (lisp--mode-syntax-table): New syntax-table,
extracted from emacs-lisp-mode-syntax-table.
(emacs-lisp-mode-abbrev-table, emacs-lisp-mode-syntax-table): Move to
elisp-mode.el.
(lisp-imenu-generic-expression): Add comments to document what comes
from which Lisp dialect.
(emacs-lisp-mode-map, emacs-lisp-byte-compile)
(emacs-lisp-byte-compile-and-load, emacs-lisp-mode-hook)
(emacs-lisp-mode, emacs-list-byte-code-comment-re)
(emacs-lisp-byte-code-comment)
(emacs-lisp-byte-code-syntax-propertize, emacs-lisp-byte-code-mode)
(lisp-interaction-mode-map, lisp-interaction-mode)
(eval-print-last-sexp, last-sexp-setup-props)
(last-sexp-toggle-display, prin1-char, preceding-sexp)
(eval-last-sexp-1, eval-last-sexp-print-value)
(eval-last-sexp-fake-value, eval-sexp-add-defvars, eval-last-sexp)
(eval-defun-1, eval-defun-2, eval-defun): Move to elisp-mode.el.
* src/lisp.mk (lisp): Add elisp-mode.elc.
2014-09-27 03:57:41 +00:00
|
|
|
|
(apply #'eldoc-remove-command
|
2005-10-04 21:49:09 +00:00
|
|
|
|
(all-completions name eldoc-message-commands))))
|
1997-02-19 10:24:26 +00:00
|
|
|
|
|
1998-09-19 02:15:26 +00:00
|
|
|
|
|
1997-02-19 10:24:26 +00:00
|
|
|
|
;; Prime the command list.
|
|
|
|
|
(eldoc-add-command-completions
|
2010-06-01 13:47:14 +00:00
|
|
|
|
"backward-" "beginning-of-" "delete-other-windows" "delete-window"
|
|
|
|
|
"down-list" "end-of-" "exchange-point-and-mark" "forward-" "goto-"
|
|
|
|
|
"handle-select-window" "indent-for-tab-command" "left-" "mark-page"
|
|
|
|
|
"mark-paragraph" "mouse-set-point" "move-" "move-beginning-of-"
|
|
|
|
|
"move-end-of-" "next-" "other-window" "pop-global-mark" "previous-"
|
|
|
|
|
"recenter" "right-" "scroll-" "self-insert-command" "split-window-"
|
|
|
|
|
"up-list")
|
1995-11-12 21:04:08 +00:00
|
|
|
|
|
|
|
|
|
(provide 'eldoc)
|
|
|
|
|
|
|
|
|
|
;;; eldoc.el ends here
|