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
|
|
|
|
|
2021-01-01 09:13:56 +00:00
|
|
|
|
;; Copyright (C) 1996-2021 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>
|
1995-11-12 21:04:08 +00:00
|
|
|
|
;; Keywords: extensions
|
|
|
|
|
;; Created: 1995-10-06
|
2020-09-06 14:37:02 +00:00
|
|
|
|
;; Version: 1.11.0
|
2020-05-13 10:31:21 +00:00
|
|
|
|
;; Package-Requires: ((emacs "26.3"))
|
|
|
|
|
|
|
|
|
|
;; This is a GNU ELPA :core package. Avoid functionality that is not
|
|
|
|
|
;; compatible with the version of Emacs recorded above.
|
1995-11-12 21:04:08 +00:00
|
|
|
|
|
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
|
2017-09-13 22:52:52 +00:00
|
|
|
|
;; along with GNU Emacs. If not, see <https://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
|
|
|
|
|
2020-03-12 22:21:19 +00:00
|
|
|
|
;; This mode is now enabled by default in all major modes that provide
|
|
|
|
|
;; support for it, such as `emacs-lisp-mode'.
|
|
|
|
|
;; This is controlled by `global-eldoc-mode'.
|
1995-11-12 21:04:08 +00:00
|
|
|
|
|
2020-02-25 22:53:04 +00:00
|
|
|
|
;; Major modes for other languages may use ElDoc by adding an
|
|
|
|
|
;; appropriate function to the buffer-local value of
|
|
|
|
|
;; `eldoc-documentation-functions'.
|
2003-09-06 17:32:31 +00:00
|
|
|
|
|
1995-11-12 21:04:08 +00:00
|
|
|
|
;;; Code:
|
|
|
|
|
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
(eval-when-compile (require 'cl-lib))
|
|
|
|
|
|
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."
|
2020-03-12 22:21:19 +00:00
|
|
|
|
:type 'number)
|
1995-11-12 21:04:08 +00:00
|
|
|
|
|
2014-01-12 04:00:03 +00:00
|
|
|
|
(defcustom eldoc-print-after-edit nil
|
2020-04-21 08:51:45 +00:00
|
|
|
|
"If non-nil, eldoc info is only shown when editing.
|
2014-01-12 04:00:03 +00:00
|
|
|
|
Changing the value requires toggling `eldoc-mode'."
|
2020-03-12 22:21:19 +00:00
|
|
|
|
:type 'boolean)
|
2014-01-12 04:00:03 +00:00
|
|
|
|
|
2020-10-04 11:19:47 +00:00
|
|
|
|
(defcustom eldoc-echo-area-display-truncation-message t
|
2020-09-21 12:15:34 +00:00
|
|
|
|
"If non-nil, provide verbose help when a message has been truncated.
|
|
|
|
|
If nil, truncated messages will just have \"...\" appended."
|
|
|
|
|
:type 'boolean
|
|
|
|
|
:version "28.1")
|
|
|
|
|
|
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."
|
2020-03-12 22:21:19 +00:00
|
|
|
|
:type '(choice string (const :tag "None" nil)))
|
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
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
`eldoc-documentation-strategy' handles it explicitly."
|
2000-07-24 00:38:34 +00:00
|
|
|
|
:type '(radio (function-item upcase)
|
|
|
|
|
(function-item downcase)
|
2020-03-12 22:21:19 +00:00
|
|
|
|
function))
|
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
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
"Allow long ElDoc doc strings to resize echo area display.
|
|
|
|
|
If value is t, never attempt to truncate messages, even if the
|
|
|
|
|
echo area must be resized to fit.
|
|
|
|
|
|
2020-10-04 18:31:02 +00:00
|
|
|
|
If the value is a positive number, it is used to calculate a
|
|
|
|
|
number of logical lines of documentation that ElDoc is allowed to
|
|
|
|
|
put in the echo area. If a positive integer, the number is used
|
|
|
|
|
directly, while a float specifies the number of lines as a
|
Fix typos
* doc/lispref/display.texi (Size of Displayed Text):
* doc/lispref/windows.texi (Buffer Display Action Functions):
* etc/NEWS:
* etc/ORG-NEWS (Org-Attach has been refactored and extended):
* lisp/battery.el (display-battery-mode, battery--upower-subsribe):
* lisp/calendar/parse-time.el:
* lisp/dired-x.el:
* lisp/emacs-lisp/chart.el (chart-sequece, chart-bar-quickie):
* lisp/emacs-lisp/eldoc.el (eldoc-echo-area-use-multiline-p)
(eldoc-documentation-strategy):
* lisp/emacs-lisp/pcase.el (pcase--split-pred, pcase--u1):
* lisp/gnus/gnus-search.el (gnus-search-expandable-keys)
(gnus-search-parse-query, gnus-search-query-return-string)
(gnus-search-imap, gnus-search-imap-search-command)
(gnus-search-transform-expression):
* lisp/gnus/nnselect.el:
* lisp/isearch.el (isearch-lazy-count-format):
* lisp/mh-e/mh-show.el (mh-show-msg):
* lisp/net/dictionary-connection.el (dictionary-connection-open):
* lisp/net/dictionary.el (dictionary-default-popup-strategy)
(dictionary, dictionary-split-string, dictionary-do-select-dictionary)
(dictionary-display-dictionarys, dictionary-search)
(dictionary-tooltip-mode):
* lisp/net/eudcb-macos-contacts.el (eudc-macos-contacts-set-server):
* lisp/net/mailcap.el (mailcap-mime-data):
* lisp/net/tramp-smb.el (tramp-smb-maybe-open-connection):
* lisp/nxml/nxml-mode.el (nxml-mode):
* lisp/progmodes/cc-engine.el:
* lisp/progmodes/cperl-mode.el (cperl-mode)
(cperl-fontify-syntaxically):
* lisp/progmodes/flymake.el (flymake-diagnostic-functions):
* lisp/progmodes/verilog-mode.el (verilog--supressed-warnings)
(verilog-preprocess):
* lisp/simple.el (self-insert-uses-region-functions):
* lisp/textmodes/bibtex.el (bibtex-copy-summary-as-kill):
* lisp/textmodes/texnfo-upd.el (texinfo-insert-master-menu-list):
* src/dispnew.c:
* src/font.c (Ffont_get):
* src/indent.c (compute_motion):
* src/process.c (init_process_emacs):
* src/w32fns.c (deliver_wm_chars):
* test/lisp/jsonrpc-tests.el (deferred-action-complex-tests):
Fix typos in documentation, comments, and internal identifiers.
2021-02-18 15:41:36 +00:00
|
|
|
|
proportion of the echo area frame's height.
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
|
2020-10-04 18:31:02 +00:00
|
|
|
|
If value is the symbol `truncate-sym-name-if-fit' t, the part of
|
|
|
|
|
the doc string that represents a symbol's name may be truncated
|
|
|
|
|
if it will enable the rest of the doc string to fit on a single
|
|
|
|
|
line, without resizing the echo area.
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
|
|
|
|
|
If value is nil, a doc string is always truncated to fit in a
|
2020-10-04 18:31:02 +00:00
|
|
|
|
single line of display in the echo area.
|
|
|
|
|
|
|
|
|
|
Any resizing of the echo area additionally respects
|
|
|
|
|
`max-mini-window-height'."
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
:type '(radio (const :tag "Always" t)
|
|
|
|
|
(float :tag "Fraction of frame height" 0.25)
|
|
|
|
|
(integer :tag "Number of lines" 5)
|
|
|
|
|
(const :tag "Never" nil)
|
|
|
|
|
(const :tag "Yes, but ask major-mode to truncate
|
|
|
|
|
symbol names if it will\ enable argument list to fit on one
|
|
|
|
|
line" truncate-sym-name-if-fit)))
|
|
|
|
|
|
2020-10-03 16:27:05 +00:00
|
|
|
|
(defcustom eldoc-echo-area-prefer-doc-buffer nil
|
2020-07-14 12:49:34 +00:00
|
|
|
|
"Prefer ElDoc's documentation buffer if it is showing in some frame.
|
2020-10-03 16:27:05 +00:00
|
|
|
|
If this variable's value is t, ElDoc will skip showing
|
|
|
|
|
documentation in the echo area if the dedicated documentation
|
|
|
|
|
buffer (given by `eldoc-doc-buffer') is being displayed in some
|
|
|
|
|
window. If the value is the symbol `maybe', then the echo area
|
|
|
|
|
is only skipped if the documentation doesn't fit there."
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
:type 'boolean)
|
2000-07-24 00:38:34 +00:00
|
|
|
|
|
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.
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
Note that this face has no effect unless the `eldoc-documentation-strategy'
|
2020-03-12 22:21:19 +00:00
|
|
|
|
handles it explicitly.")
|
2007-08-24 02:30:59 +00:00
|
|
|
|
|
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
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
"The function used by `eldoc--message' to display messages.
|
2013-03-17 15:00:37 +00:00
|
|
|
|
It should receive the same arguments as `message'.")
|
|
|
|
|
|
2014-01-12 04:00:03 +00:00
|
|
|
|
(defun eldoc-edit-message-commands ()
|
2017-07-22 08:09:36 +00:00
|
|
|
|
"Return an obarray containing common editing commands.
|
|
|
|
|
|
|
|
|
|
When `eldoc-print-after-edit' is non-nil, ElDoc messages are only
|
|
|
|
|
printed after commands contained in this obarray."
|
2014-01-12 04:00:03 +00:00
|
|
|
|
(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).
|
|
|
|
|
|
|
|
|
|
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
|
2020-03-12 22:21:19 +00:00
|
|
|
|
expression point is on." :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
|
2017-05-30 22:29:34 +00:00
|
|
|
|
((not (eldoc--supported-p))
|
2017-05-29 23:55:28 +00:00
|
|
|
|
(when (called-interactively-p 'any)
|
|
|
|
|
(message "There is no ElDoc support in this buffer"))
|
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-mode nil))
|
|
|
|
|
(eldoc-mode
|
|
|
|
|
(when eldoc-print-after-edit
|
|
|
|
|
(setq-local eldoc-message-commands (eldoc-edit-message-commands)))
|
2020-03-12 22:21:19 +00:00
|
|
|
|
(add-hook 'post-command-hook #'eldoc-schedule-timer nil t)
|
|
|
|
|
(add-hook 'pre-command-hook #'eldoc-pre-command-refresh-echo-area nil 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
|
|
|
|
(t
|
|
|
|
|
(kill-local-variable 'eldoc-message-commands)
|
2020-03-12 22:21:19 +00:00
|
|
|
|
(remove-hook 'post-command-hook #'eldoc-schedule-timer t)
|
|
|
|
|
(remove-hook 'pre-command-hook #'eldoc-pre-command-refresh-echo-area t)
|
2016-04-29 20:06:37 +00:00
|
|
|
|
(when eldoc-timer
|
|
|
|
|
(cancel-timer eldoc-timer)
|
|
|
|
|
(setq eldoc-timer 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
|
|
|
|
|
|
|
|
|
;;;###autoload
|
2017-05-29 23:55:28 +00:00
|
|
|
|
(define-globalized-minor-mode global-eldoc-mode eldoc-mode turn-on-eldoc-mode
|
2014-10-15 17:32:41 +00:00
|
|
|
|
:initialize 'custom-initialize-delay
|
2019-08-04 00:19:31 +00:00
|
|
|
|
:init-value t
|
|
|
|
|
;; For `read--expression', the usual global mode mechanism of
|
|
|
|
|
;; `change-major-mode-hook' runs in the minibuffer before
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
;; `eldoc-documentation-strategy' is set, so `turn-on-eldoc-mode'
|
2019-08-04 00:19:31 +00:00
|
|
|
|
;; does nothing. Configure and enable eldoc from
|
|
|
|
|
;; `eval-expression-minibuffer-setup-hook' instead.
|
|
|
|
|
(if global-eldoc-mode
|
|
|
|
|
(add-hook 'eval-expression-minibuffer-setup-hook
|
|
|
|
|
#'eldoc--eval-expression-setup)
|
|
|
|
|
(remove-hook 'eval-expression-minibuffer-setup-hook
|
|
|
|
|
#'eldoc--eval-expression-setup)))
|
|
|
|
|
|
|
|
|
|
(defun eldoc--eval-expression-setup ()
|
|
|
|
|
;; Setup `eldoc', similar to `emacs-lisp-mode'. FIXME: Call
|
|
|
|
|
;; `emacs-lisp-mode' itself?
|
2020-07-27 21:07:38 +00:00
|
|
|
|
(cond ((<= emacs-major-version 27)
|
|
|
|
|
(declare-function elisp-eldoc-documentation-function "elisp-mode")
|
2020-10-30 22:09:36 +00:00
|
|
|
|
(with-no-warnings
|
|
|
|
|
(add-function :before-until (local 'eldoc-documentation-function)
|
|
|
|
|
#'elisp-eldoc-documentation-function)))
|
2020-07-27 21:07:38 +00:00
|
|
|
|
(t (add-hook 'eldoc-documentation-functions
|
|
|
|
|
#'elisp-eldoc-var-docstring nil t)
|
|
|
|
|
(add-hook 'eldoc-documentation-functions
|
|
|
|
|
#'elisp-eldoc-funcall nil t)
|
2021-02-12 21:26:08 +00:00
|
|
|
|
(setq-local eldoc-documentation-strategy
|
|
|
|
|
'eldoc-documentation-default)))
|
2019-08-04 00:19:31 +00:00
|
|
|
|
(eldoc-mode +1))
|
2013-03-17 15:00:37 +00:00
|
|
|
|
|
1995-11-12 21:04:08 +00:00
|
|
|
|
;;;###autoload
|
2017-05-29 23:55:28 +00:00
|
|
|
|
(defun turn-on-eldoc-mode ()
|
2017-07-22 08:09:36 +00:00
|
|
|
|
"Turn on `eldoc-mode' if the buffer has ElDoc support enabled.
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
See `eldoc-documentation-strategy' for more detail."
|
2017-05-30 22:29:34 +00:00
|
|
|
|
(when (eldoc--supported-p)
|
2017-05-29 23:55:28 +00:00
|
|
|
|
(eldoc-mode 1)))
|
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 ()
|
2017-07-22 08:09:36 +00:00
|
|
|
|
"Ensure `eldoc-timer' is running.
|
|
|
|
|
|
|
|
|
|
If the user has changed `eldoc-idle-delay', update the timer to
|
|
|
|
|
reflect the change."
|
1997-02-03 06:13:34 +00:00
|
|
|
|
(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
|
2017-07-22 08:09:36 +00:00
|
|
|
|
(eldoc--supported-p)))
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
;; Don't ignore, but also don't full-on signal errors
|
|
|
|
|
(with-demoted-errors "eldoc error: %s"
|
|
|
|
|
(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
|
2017-09-13 22:52:52 +00:00
|
|
|
|
;; https://debbugs.gnu.org/16920
|
2014-03-10 05:33:31 +00:00
|
|
|
|
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)))
|
2020-04-20 21:30:41 +00:00
|
|
|
|
(when (and mode-line-format
|
|
|
|
|
(not (and (listp mode-line-format)
|
|
|
|
|
(assq 'eldoc-mode-line-string mode-line-format))))
|
2013-03-17 15:00:37 +00:00
|
|
|
|
(setq mode-line-format
|
|
|
|
|
(list "" '(eldoc-mode-line-string
|
|
|
|
|
(" " eldoc-mode-line-string " "))
|
2020-04-20 21:30:41 +00:00
|
|
|
|
mode-line-format)))
|
2013-12-04 04:42:01 +00:00
|
|
|
|
(setq eldoc-mode-line-string
|
|
|
|
|
(when (stringp format-string)
|
More-conservative ‘format’ quote restyling
Instead of restyling curved quotes for every call to ‘format’,
create a new function ‘format-message’ that does the restyling,
and using the new function instead of ‘format’ only in contexts
where this seems appropriate.
Problem reported by Dmitry Gutov and Andreas Schwab in:
http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00826.html
http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00827.html
* doc/lispref/commands.texi (Using Interactive):
* doc/lispref/control.texi (Signaling Errors, Signaling Errors):
* doc/lispref/display.texi (Displaying Messages, Progress):
* doc/lispref/elisp.texi:
* doc/lispref/help.texi (Keys in Documentation):
* doc/lispref/minibuf.texi (Minibuffer Misc):
* doc/lispref/strings.texi (Formatting Strings):
* etc/NEWS:
Document the changes.
* lisp/abbrev.el (expand-region-abbrevs):
* lisp/apropos.el (apropos-library):
* lisp/calc/calc-ext.el (calc-record-message)
(calc-user-function-list):
* lisp/calc/calc-help.el (calc-describe-key, calc-full-help):
* lisp/calc/calc-lang.el (math-read-big-balance):
* lisp/calc/calc-store.el (calc-edit-variable):
* lisp/calc/calc-units.el (math-build-units-table-buffer):
* lisp/calc/calc-yank.el (calc-edit-mode):
* lisp/calendar/icalendar.el (icalendar-export-region)
(icalendar--add-diary-entry):
* lisp/cedet/mode-local.el (mode-local-print-binding)
(mode-local-describe-bindings-2):
* lisp/cedet/semantic/complete.el (semantic-completion-message):
* lisp/cedet/semantic/edit.el (semantic-parse-changes-failed):
* lisp/cedet/semantic/wisent/comp.el (wisent-log):
* lisp/cedet/srecode/insert.el (srecode-insert-show-error-report):
* lisp/descr-text.el (describe-text-properties-1, describe-char):
* lisp/dframe.el (dframe-message):
* lisp/dired-aux.el (dired-query):
* lisp/emacs-lisp/byte-opt.el (byte-compile-log-lap-1):
* lisp/emacs-lisp/bytecomp.el (byte-compile-log)
(byte-compile-log-file, byte-compile-warn, byte-compile-form):
* lisp/emacs-lisp/cconv.el (cconv-convert, cconv--analyze-use)
(cconv-analyze-form):
* lisp/emacs-lisp/check-declare.el (check-declare-warn):
* lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine):
* lisp/emacs-lisp/cl-macs.el (cl-symbol-macrolet):
* lisp/emacs-lisp/edebug.el (edebug-format):
* lisp/emacs-lisp/eieio-core.el (eieio-oref):
* lisp/emacs-lisp/eldoc.el (eldoc-minibuffer-message)
(eldoc-message):
* lisp/emacs-lisp/elint.el (elint-file, elint-log):
* lisp/emacs-lisp/find-func.el (find-function-library):
* lisp/emacs-lisp/macroexp.el (macroexp--obsolete-warning):
* lisp/emacs-lisp/map-ynp.el (map-y-or-n-p):
* lisp/emacs-lisp/nadvice.el (advice--make-docstring):
* lisp/emacs-lisp/package.el (package-compute-transaction)
(package-install-button-action, package-delete-button-action)
(package-menu--list-to-prompt):
* lisp/emacs-lisp/timer.el (timer-event-handler):
* lisp/emacs-lisp/warnings.el (lwarn, warn):
* lisp/emulation/viper-cmd.el:
(viper-toggle-parse-sexp-ignore-comments)
(viper-kill-buffer, viper-brac-function):
* lisp/emulation/viper-macs.el (viper-record-kbd-macro):
* lisp/facemenu.el (facemenu-add-new-face):
* lisp/faces.el (face-documentation, read-face-name)
(face-read-string, read-face-font, describe-face):
* lisp/files.el (find-alternate-file, hack-local-variables)
(hack-one-local-variable--obsolete, write-file)
(basic-save-buffer, delete-directory):
* lisp/format.el (format-write-file, format-find-file)
(format-insert-file):
* lisp/help-fns.el (help-fns--key-bindings)
(help-fns--compiler-macro, help-fns--obsolete)
(help-fns--interactive-only, describe-function-1)
(describe-variable):
* lisp/help.el (describe-mode):
* lisp/info-xref.el (info-xref-output):
* lisp/info.el (Info-virtual-index-find-node)
(Info-virtual-index, info-apropos):
* lisp/international/kkc.el (kkc-error):
* lisp/international/mule-cmds.el:
(select-safe-coding-system-interactively)
(select-safe-coding-system, describe-input-method):
* lisp/international/mule-conf.el (code-offset):
* lisp/international/mule-diag.el (describe-character-set)
(list-input-methods-1):
* lisp/international/quail.el (quail-error):
* lisp/minibuffer.el (minibuffer-message):
* lisp/mpc.el (mpc--debug):
* lisp/msb.el (msb--choose-menu):
* lisp/net/ange-ftp.el (ange-ftp-message):
* lisp/net/gnutls.el (gnutls-message-maybe):
* lisp/net/newst-backend.el (newsticker--sentinel-work):
* lisp/net/newst-treeview.el (newsticker--treeview-load):
* lisp/net/nsm.el (nsm-query-user):
* lisp/net/rlogin.el (rlogin):
* lisp/net/soap-client.el (soap-warning):
* lisp/net/tramp.el (tramp-debug-message):
* lisp/nxml/nxml-outln.el (nxml-report-outline-error):
* lisp/nxml/nxml-parse.el (nxml-parse-error):
* lisp/nxml/rng-cmpct.el (rng-c-error):
* lisp/nxml/rng-match.el (rng-compile-error):
* lisp/nxml/rng-uri.el (rng-uri-error):
* lisp/obsolete/iswitchb.el (iswitchb-possible-new-buffer):
* lisp/org/org-ctags.el:
(org-ctags-ask-rebuild-tags-file-then-find-tag):
* lisp/proced.el (proced-log):
* lisp/progmodes/ebnf2ps.el (ebnf-log):
* lisp/progmodes/flymake.el (flymake-log):
* lisp/progmodes/vhdl-mode.el (vhdl-warning-when-idle):
* lisp/replace.el (occur-1):
* lisp/simple.el (execute-extended-command)
(undo-outer-limit-truncate, define-alternatives):
* lisp/startup.el (command-line):
* lisp/subr.el (error, user-error, add-to-list):
* lisp/tutorial.el (tutorial--describe-nonstandard-key)
(tutorial--find-changed-keys):
* src/callint.c (Fcall_interactively):
* src/editfns.c (Fmessage, Fmessage_box):
Restyle the quotes of format strings intended for use as a
diagnostic, when restyling seems appropriate.
* lisp/subr.el (format-message): New function.
* src/doc.c (Finternal__text_restyle): New function.
(syms_of_doc): Define it.
2015-08-24 05:38:02 +00:00
|
|
|
|
(apply #'format-message format-string args)))
|
2013-12-04 04:42:01 +00:00
|
|
|
|
(force-mode-line-update)))
|
2020-03-12 22:21:19 +00:00
|
|
|
|
(apply #'message format-string args)))
|
2013-03-17 15:00:37 +00:00
|
|
|
|
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
(make-obsolete
|
2020-07-07 12:37:16 +00:00
|
|
|
|
'eldoc-message "use `eldoc-documentation-functions' instead." "eldoc-1.1.0")
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
(defun eldoc-message (&optional string) (eldoc--message string))
|
|
|
|
|
(defun eldoc--message (&optional string)
|
2017-08-20 21:26:45 +00:00
|
|
|
|
"Display STRING as an ElDoc message if it's non-nil.
|
2017-07-22 08:09:36 +00:00
|
|
|
|
|
2017-08-20 21:26:45 +00:00
|
|
|
|
Also store it in `eldoc-last-message' and return that value."
|
1997-02-19 10:24:26 +00:00
|
|
|
|
(let ((omessage eldoc-last-message))
|
2017-08-20 21:26:45 +00:00
|
|
|
|
(setq eldoc-last-message string)
|
2020-03-12 22:21:19 +00:00
|
|
|
|
;; Do not put eldoc messages in the 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)
|
2017-07-22 08:09:36 +00:00
|
|
|
|
"Return non-nil if COMMAND is in `eldoc-message-commands'."
|
2014-01-21 13:09:55 +00:00
|
|
|
|
(and (symbolp command)
|
|
|
|
|
(intern-soft (symbol-name command) eldoc-message-commands)))
|
|
|
|
|
|
2020-03-12 22:21:19 +00:00
|
|
|
|
;; This function goes on pre-command-hook.
|
|
|
|
|
;; Motion commands clear the echo area for some reason,
|
1998-09-19 02:15:26 +00:00
|
|
|
|
;; 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.
|
2020-03-12 22:21:19 +00:00
|
|
|
|
;; FIXME: The above comment suggests we don't really understand why
|
|
|
|
|
;; this is needed. Maybe it's not needed any more, but if it is
|
|
|
|
|
;; we should figure out why.
|
1998-09-19 02:15:26 +00:00
|
|
|
|
(defun eldoc-pre-command-refresh-echo-area ()
|
2017-07-22 08:09:36 +00:00
|
|
|
|
"Reprint `eldoc-last-message' in the echo area."
|
1998-09-19 02:15:26 +00:00
|
|
|
|
(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))
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
(eldoc--message eldoc-last-message)
|
|
|
|
|
;; No need to call eldoc--message since the echo area will be cleared
|
2014-01-21 13:09:55 +00:00
|
|
|
|
;; 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
|
|
|
|
|
2020-09-06 14:37:02 +00:00
|
|
|
|
;; The point of `eldoc--request-state' is not to over-request, which
|
|
|
|
|
;; can happen if the idle timer is restarted on execution of command
|
|
|
|
|
;; which is guaranteed not to change the conditions that warrant a new
|
|
|
|
|
;; request for documentation.
|
|
|
|
|
(defvar eldoc--last-request-state nil
|
2020-07-18 23:48:43 +00:00
|
|
|
|
"Tuple containing information about last ElDoc request.")
|
|
|
|
|
(defun eldoc--request-state ()
|
|
|
|
|
"Compute information to store in `eldoc--last-request-state'."
|
|
|
|
|
(list (current-buffer) (buffer-modified-tick) (point)))
|
|
|
|
|
|
2020-07-27 15:26:33 +00:00
|
|
|
|
(defun eldoc-display-message-p ()
|
2020-09-06 14:37:02 +00:00
|
|
|
|
"Tell if ElDoc can use the echo area."
|
|
|
|
|
(and (eldoc-display-message-no-interference-p)
|
|
|
|
|
(not this-command)
|
|
|
|
|
(eldoc--message-command-p last-command)))
|
|
|
|
|
|
2020-07-27 15:26:33 +00:00
|
|
|
|
(make-obsolete 'eldoc-display-message-p
|
|
|
|
|
"Use `eldoc-documentation-functions' instead."
|
|
|
|
|
"eldoc-1.6.0")
|
|
|
|
|
|
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 ()
|
2017-07-22 08:09:36 +00:00
|
|
|
|
"Return nil if displaying a message would cause interference."
|
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
|
|
|
|
|
2020-02-25 22:53:04 +00:00
|
|
|
|
(defvar eldoc-documentation-functions nil
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
"Hook of functions that produce doc strings.
|
|
|
|
|
|
|
|
|
|
A doc string is typically relevant if point is on a function-like
|
|
|
|
|
name, inside its arg list, or on any object with some associated
|
|
|
|
|
information.
|
|
|
|
|
|
2020-07-05 11:55:27 +00:00
|
|
|
|
Each hook function is called with at least one argument CALLBACK,
|
2020-04-21 08:51:45 +00:00
|
|
|
|
a function, and decides whether to display a short doc string
|
2020-07-05 11:55:27 +00:00
|
|
|
|
about the context around point.
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
|
|
|
|
|
- If that decision can be taken quickly, the hook function may
|
2020-04-21 08:51:45 +00:00
|
|
|
|
call CALLBACK immediately, following the protocol described
|
|
|
|
|
below. Alternatively, it may ignore CALLBACK entirely and
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
return either the doc string, or nil if there's no doc
|
|
|
|
|
appropriate for the context.
|
|
|
|
|
|
|
|
|
|
- If the computation of said doc string (or the decision whether
|
|
|
|
|
there is one at all) is expensive or can't be performed
|
|
|
|
|
directly, the hook function should return a non-nil, non-string
|
|
|
|
|
value and arrange for CALLBACK to be called at a later time,
|
|
|
|
|
using asynchronous processes or other asynchronous mechanisms.
|
|
|
|
|
|
2020-07-05 11:55:27 +00:00
|
|
|
|
To call the CALLBACK function, the hook function must pass it an
|
|
|
|
|
obligatory argument DOCSTRING, a string containing the
|
2020-09-06 14:37:02 +00:00
|
|
|
|
documentation, followed by an optional list of arbitrary
|
|
|
|
|
keyword-value pairs of the form (:KEY VALUE :KEY2 VALUE2...).
|
|
|
|
|
The information contained in these pairs is understood by members
|
|
|
|
|
of `eldoc-display-functions', allowing the
|
|
|
|
|
documentation-producing backend to cooperate with specific
|
|
|
|
|
documentation-displaying frontends. For example, KEY can be:
|
|
|
|
|
|
|
|
|
|
* `:thing', VALUE being a short string or symbol designating what
|
|
|
|
|
is being reported on. It can, for example be the name of the
|
|
|
|
|
function whose signature is being documented, or the name of
|
|
|
|
|
the variable whose docstring is being documented.
|
|
|
|
|
`eldoc-display-in-echo-area', a member of
|
|
|
|
|
`eldoc-display-functions', sometimes omits this information
|
|
|
|
|
depending on space constraints;
|
|
|
|
|
|
|
|
|
|
* `:face', VALUE being a symbol designating a face which both
|
|
|
|
|
`eldoc-display-in-echo-area' and `eldoc-display-in-buffer' will
|
|
|
|
|
use when displaying `:thing''s value.
|
|
|
|
|
|
|
|
|
|
Finally, major modes should modify this hook locally, for
|
|
|
|
|
example:
|
2020-02-25 22:53:04 +00:00
|
|
|
|
(add-hook \\='eldoc-documentation-functions #\\='foo-mode-eldoc nil t)
|
|
|
|
|
so that the global value (i.e. the default value of the hook) is
|
|
|
|
|
taken into account if the major mode specific function does not
|
|
|
|
|
return any documentation.")
|
|
|
|
|
|
2020-09-06 14:37:02 +00:00
|
|
|
|
(defvar eldoc-display-functions
|
|
|
|
|
'(eldoc-display-in-echo-area eldoc-display-in-buffer)
|
|
|
|
|
"Hook of functions tasked with displaying ElDoc results.
|
|
|
|
|
Each function is passed two arguments: DOCS and INTERACTIVE. DOCS
|
|
|
|
|
is a list (DOC ...) where DOC looks like (STRING :KEY VALUE :KEY2
|
|
|
|
|
VALUE2 ...). STRING is a string containing the documentation's
|
|
|
|
|
text and the remainder of DOC is an optional list of
|
|
|
|
|
keyword-value pairs denoting additional properties of that
|
|
|
|
|
documentation. For commonly recognized properties, see
|
|
|
|
|
`eldoc-documentation-functions'.
|
|
|
|
|
|
|
|
|
|
INTERACTIVE says if the request to display doc strings came
|
|
|
|
|
directly from the user or from ElDoc's automatic mechanisms'.")
|
|
|
|
|
|
2020-07-18 23:48:43 +00:00
|
|
|
|
(defvar eldoc--doc-buffer nil "Buffer displaying latest ElDoc-produced docs.")
|
|
|
|
|
|
2020-09-06 14:37:02 +00:00
|
|
|
|
(defvar eldoc--doc-buffer-docs nil "Documentation items in `eldoc--doc-buffer'.")
|
|
|
|
|
|
2020-10-30 21:47:44 +00:00
|
|
|
|
(defun eldoc-doc-buffer ()
|
2020-09-06 14:37:02 +00:00
|
|
|
|
"Display ElDoc documentation buffer.
|
2020-10-30 21:47:44 +00:00
|
|
|
|
|
2020-09-06 14:37:02 +00:00
|
|
|
|
This holds the results of the last documentation request."
|
2020-10-30 21:47:44 +00:00
|
|
|
|
(interactive)
|
2020-09-06 14:37:02 +00:00
|
|
|
|
(unless (buffer-live-p eldoc--doc-buffer)
|
2020-10-30 21:47:44 +00:00
|
|
|
|
(user-error (format
|
|
|
|
|
"ElDoc buffer doesn't exist, maybe `%s' to produce one."
|
|
|
|
|
(substitute-command-keys "\\[eldoc]"))))
|
|
|
|
|
(with-current-buffer eldoc--doc-buffer
|
|
|
|
|
(rename-buffer (replace-regexp-in-string "^ *" ""
|
|
|
|
|
(buffer-name)))
|
|
|
|
|
(display-buffer (current-buffer))))
|
2020-09-06 14:37:02 +00:00
|
|
|
|
|
|
|
|
|
(defun eldoc--format-doc-buffer (docs)
|
|
|
|
|
"Ensure DOCS are displayed in an *eldoc* buffer."
|
2020-10-30 21:47:44 +00:00
|
|
|
|
(with-current-buffer (if (buffer-live-p eldoc--doc-buffer)
|
|
|
|
|
eldoc--doc-buffer
|
|
|
|
|
(setq eldoc--doc-buffer
|
|
|
|
|
(get-buffer-create " *eldoc*")))
|
2020-09-06 14:37:02 +00:00
|
|
|
|
(unless (eq docs eldoc--doc-buffer-docs)
|
|
|
|
|
(setq-local eldoc--doc-buffer-docs docs)
|
|
|
|
|
(let ((inhibit-read-only t)
|
|
|
|
|
(things-reported-on))
|
|
|
|
|
(erase-buffer) (setq buffer-read-only t)
|
|
|
|
|
(local-set-key "q" 'quit-window)
|
|
|
|
|
(cl-loop for (docs . rest) on docs
|
|
|
|
|
for (this-doc . plist) = docs
|
|
|
|
|
for thing = (plist-get plist :thing)
|
|
|
|
|
when thing do
|
|
|
|
|
(cl-pushnew thing things-reported-on)
|
|
|
|
|
(setq this-doc
|
|
|
|
|
(concat
|
|
|
|
|
(propertize (format "%s" thing)
|
|
|
|
|
'face (plist-get plist :face))
|
|
|
|
|
": "
|
|
|
|
|
this-doc))
|
|
|
|
|
do (insert this-doc)
|
2020-10-30 21:47:44 +00:00
|
|
|
|
when rest do (insert "\n")
|
|
|
|
|
finally (goto-char (point-min)))
|
|
|
|
|
;; Rename the buffer, taking into account whether it was
|
|
|
|
|
;; hidden or not
|
|
|
|
|
(rename-buffer (format "%s*eldoc%s*"
|
|
|
|
|
(if (string-match "^ " (buffer-name)) " " "")
|
|
|
|
|
(if things-reported-on
|
|
|
|
|
(format " for %s"
|
|
|
|
|
(mapconcat
|
|
|
|
|
(lambda (s) (format "%s" s))
|
|
|
|
|
things-reported-on
|
|
|
|
|
", "))
|
|
|
|
|
""))))))
|
2020-09-06 14:37:02 +00:00
|
|
|
|
eldoc--doc-buffer)
|
|
|
|
|
|
2020-10-04 18:31:02 +00:00
|
|
|
|
(defun eldoc--echo-area-substring (available)
|
|
|
|
|
"Given AVAILABLE lines, get buffer substring to display in echo area.
|
|
|
|
|
Helper for `eldoc-display-in-echo-area'."
|
|
|
|
|
(let ((start (prog1 (progn
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(skip-chars-forward " \t\n")
|
|
|
|
|
(point))
|
|
|
|
|
(goto-char (line-end-position available))
|
|
|
|
|
(skip-chars-backward " \t\n")))
|
|
|
|
|
(truncated (save-excursion
|
|
|
|
|
(skip-chars-forward " \t\n")
|
|
|
|
|
(not (eobp)))))
|
|
|
|
|
(cond ((eldoc--echo-area-prefer-doc-buffer-p truncated)
|
|
|
|
|
nil)
|
|
|
|
|
((and truncated
|
|
|
|
|
(> available 1)
|
|
|
|
|
eldoc-echo-area-display-truncation-message)
|
|
|
|
|
(goto-char (line-end-position 0))
|
|
|
|
|
(concat (buffer-substring start (point))
|
|
|
|
|
(format
|
|
|
|
|
"\n(Documentation truncated. Use `%s' to see rest)"
|
|
|
|
|
(substitute-command-keys "\\[eldoc-doc-buffer]"))))
|
|
|
|
|
(t
|
|
|
|
|
(buffer-substring start (point))))))
|
|
|
|
|
|
|
|
|
|
(defun eldoc--echo-area-prefer-doc-buffer-p (truncatedp)
|
|
|
|
|
"Tell if display in the echo area should be skipped.
|
|
|
|
|
Helper for `eldoc-display-in-echo-area'. If TRUNCATEDP the
|
|
|
|
|
documentation to potentially appear in the echo are is truncated."
|
|
|
|
|
(and (or (eq eldoc-echo-area-prefer-doc-buffer t)
|
|
|
|
|
(and truncatedp
|
|
|
|
|
(eq eldoc-echo-area-prefer-doc-buffer
|
|
|
|
|
'maybe)))
|
|
|
|
|
(get-buffer-window eldoc--doc-buffer)))
|
|
|
|
|
|
2020-09-06 14:37:02 +00:00
|
|
|
|
(defun eldoc-display-in-echo-area (docs _interactive)
|
|
|
|
|
"Display DOCS in echo area.
|
|
|
|
|
Honor `eldoc-echo-area-use-multiline-p' and
|
2020-10-03 16:27:05 +00:00
|
|
|
|
`eldoc-echo-area-prefer-doc-buffer'."
|
2020-09-06 14:37:02 +00:00
|
|
|
|
(cond
|
|
|
|
|
(;; Check if he wave permission to mess with echo area at all. For
|
|
|
|
|
;; example, 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.
|
|
|
|
|
(or
|
|
|
|
|
(not (eldoc-display-message-no-interference-p))
|
|
|
|
|
this-command
|
|
|
|
|
(not (eldoc--message-command-p last-command))))
|
|
|
|
|
(;; If we do but nothing to report, clear the echo area.
|
|
|
|
|
(null docs)
|
|
|
|
|
(eldoc--message nil))
|
|
|
|
|
(t
|
|
|
|
|
;; Otherwise, establish some parameters.
|
2020-07-05 11:55:27 +00:00
|
|
|
|
(let*
|
|
|
|
|
((width (1- (window-width (minibuffer-window))))
|
|
|
|
|
(val (if (and (symbolp eldoc-echo-area-use-multiline-p)
|
|
|
|
|
eldoc-echo-area-use-multiline-p)
|
|
|
|
|
max-mini-window-height
|
|
|
|
|
eldoc-echo-area-use-multiline-p))
|
|
|
|
|
(available (cl-typecase val
|
|
|
|
|
(float (truncate (* (frame-height) val)))
|
|
|
|
|
(integer val)
|
2020-10-04 18:31:02 +00:00
|
|
|
|
(t 'just-one-line)))
|
|
|
|
|
single-doc single-doc-sym)
|
2020-07-10 20:23:06 +00:00
|
|
|
|
(let ((echo-area-message
|
|
|
|
|
(cond
|
2020-10-04 18:31:02 +00:00
|
|
|
|
(;; To output to the echo area, we handle the
|
2020-09-06 14:37:02 +00:00
|
|
|
|
;; `truncate-sym-name-if-fit' special case first, by
|
2020-10-04 18:31:02 +00:00
|
|
|
|
;; checking for a lot of special conditions.
|
2020-07-18 22:15:28 +00:00
|
|
|
|
(and
|
2020-07-10 20:23:06 +00:00
|
|
|
|
(eq 'truncate-sym-name-if-fit eldoc-echo-area-use-multiline-p)
|
|
|
|
|
(null (cdr docs))
|
2020-07-18 22:15:28 +00:00
|
|
|
|
(setq single-doc (caar docs))
|
|
|
|
|
(setq single-doc-sym
|
2020-07-10 20:23:06 +00:00
|
|
|
|
(format "%s" (plist-get (cdar docs) :thing)))
|
2020-07-18 22:15:28 +00:00
|
|
|
|
(< (length single-doc) width)
|
|
|
|
|
(not (string-match "\n" single-doc))
|
|
|
|
|
(> (+ (length single-doc) (length single-doc-sym) 2) width))
|
|
|
|
|
single-doc)
|
2020-10-04 18:31:02 +00:00
|
|
|
|
((and (numberp available)
|
|
|
|
|
(cl-plusp available))
|
|
|
|
|
;; Else, given a positive number of logical lines, we
|
|
|
|
|
;; format the *eldoc* buffer, using as most of its
|
|
|
|
|
;; contents as we know will fit.
|
2020-09-06 14:37:02 +00:00
|
|
|
|
(with-current-buffer (eldoc--format-doc-buffer docs)
|
2020-11-26 10:24:20 +00:00
|
|
|
|
(save-excursion
|
|
|
|
|
(eldoc--echo-area-substring available))))
|
2020-10-04 18:31:02 +00:00
|
|
|
|
(t ;; this is the "truncate brutally" situation
|
2020-10-03 16:27:05 +00:00
|
|
|
|
(let ((string
|
|
|
|
|
(with-current-buffer (eldoc--format-doc-buffer docs)
|
|
|
|
|
(buffer-substring (goto-char (point-min))
|
|
|
|
|
(line-end-position 1)))))
|
|
|
|
|
(if (> (length string) width) ; truncation to happen
|
2020-10-04 18:31:02 +00:00
|
|
|
|
(unless (eldoc--echo-area-prefer-doc-buffer-p t)
|
2020-10-03 16:27:05 +00:00
|
|
|
|
(truncate-string-to-width string width))
|
2020-10-04 18:31:02 +00:00
|
|
|
|
(unless (eldoc--echo-area-prefer-doc-buffer-p nil)
|
2020-10-03 16:27:05 +00:00
|
|
|
|
string)))))))
|
2020-07-10 20:23:06 +00:00
|
|
|
|
(when echo-area-message
|
2020-09-06 14:37:02 +00:00
|
|
|
|
(eldoc--message echo-area-message)))))))
|
|
|
|
|
|
|
|
|
|
(defun eldoc-display-in-buffer (docs interactive)
|
|
|
|
|
"Display DOCS in a dedicated buffer.
|
|
|
|
|
If INTERACTIVE is t, also display the buffer."
|
2020-10-30 21:47:44 +00:00
|
|
|
|
(eldoc--format-doc-buffer docs)
|
|
|
|
|
(when interactive
|
|
|
|
|
(eldoc-doc-buffer)))
|
2020-07-05 11:55:27 +00:00
|
|
|
|
|
2020-02-25 22:53:04 +00:00
|
|
|
|
(defun eldoc-documentation-default ()
|
|
|
|
|
"Show first doc string for item at point.
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
Default value for `eldoc-documentation-strategy'."
|
|
|
|
|
(run-hook-with-args-until-success 'eldoc-documentation-functions
|
2020-07-05 11:55:27 +00:00
|
|
|
|
(eldoc--make-callback :patient)))
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
|
2020-07-05 11:55:27 +00:00
|
|
|
|
(defun eldoc--documentation-compose-1 (eagerlyp)
|
|
|
|
|
"Helper function for composing multiple doc strings.
|
|
|
|
|
If EAGERLYP is non-nil show documentation as soon as possible,
|
|
|
|
|
else wait for all doc strings."
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
(run-hook-wrapped 'eldoc-documentation-functions
|
|
|
|
|
(lambda (f)
|
|
|
|
|
(let* ((callback (eldoc--make-callback
|
|
|
|
|
(if eagerlyp :eager :patient)))
|
|
|
|
|
(str (funcall f callback)))
|
|
|
|
|
(if (or (null str) (stringp str)) (funcall callback str))
|
|
|
|
|
nil)))
|
|
|
|
|
t)
|
|
|
|
|
|
2020-07-05 11:55:27 +00:00
|
|
|
|
(defun eldoc-documentation-compose ()
|
|
|
|
|
"Show multiple doc strings at once after waiting for all.
|
|
|
|
|
Meant as a value for `eldoc-documentation-strategy'."
|
|
|
|
|
(eldoc--documentation-compose-1 nil))
|
|
|
|
|
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
(defun eldoc-documentation-compose-eagerly ()
|
|
|
|
|
"Show multiple doc strings at once as soon as possible.
|
|
|
|
|
Meant as a value for `eldoc-documentation-strategy'."
|
2020-07-05 11:55:27 +00:00
|
|
|
|
(eldoc--documentation-compose-1 t))
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
|
|
|
|
|
(defun eldoc-documentation-enthusiast ()
|
|
|
|
|
"Show most important doc string produced so far.
|
|
|
|
|
Meant as a value for `eldoc-documentation-strategy'."
|
|
|
|
|
(run-hook-wrapped 'eldoc-documentation-functions
|
|
|
|
|
(lambda (f)
|
|
|
|
|
(let* ((callback (eldoc--make-callback :enthusiast))
|
|
|
|
|
(str (funcall f callback)))
|
|
|
|
|
(if (stringp str) (funcall callback str))
|
2020-08-29 13:28:54 +00:00
|
|
|
|
nil)))
|
|
|
|
|
t)
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
|
2020-07-14 12:49:34 +00:00
|
|
|
|
;; JT@2020-07-10: ElDoc is pre-loaded, so in Emacs < 28 we can't
|
2020-07-10 19:49:54 +00:00
|
|
|
|
;; make the "old" `eldoc-documentation-function' point to the new
|
|
|
|
|
;; `eldoc-documentation-strategy', so we do the reverse. This allows
|
2020-07-14 12:49:34 +00:00
|
|
|
|
;; for ElDoc to be loaded in those older Emacs versions and work with
|
|
|
|
|
;; whomever (major-modes, extensions, user) sets one or the other
|
2020-07-10 19:49:54 +00:00
|
|
|
|
;; variable.
|
|
|
|
|
(defmacro eldoc--documentation-strategy-defcustom
|
|
|
|
|
(main secondary value docstring &rest more)
|
|
|
|
|
"Defcustom helper macro for sorting `eldoc-documentation-strategy'."
|
|
|
|
|
(declare (indent 2))
|
|
|
|
|
`(if (< emacs-major-version 28)
|
|
|
|
|
(progn
|
|
|
|
|
(defcustom ,secondary ,value ,docstring ,@more)
|
|
|
|
|
(define-obsolete-variable-alias ',main ',secondary "eldoc-1.1.0"))
|
|
|
|
|
(progn
|
|
|
|
|
(defcustom ,main ,value ,docstring ,@more)
|
|
|
|
|
(defvaralias ',secondary ',main ,docstring))))
|
|
|
|
|
|
|
|
|
|
(eldoc--documentation-strategy-defcustom eldoc-documentation-strategy
|
|
|
|
|
eldoc-documentation-function
|
|
|
|
|
#'eldoc-documentation-default
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
"How to collect and organize results of `eldoc-documentation-functions'.
|
|
|
|
|
|
|
|
|
|
This variable controls how `eldoc-documentation-functions', which
|
|
|
|
|
specifies the sources of documentation, is queried and how its
|
|
|
|
|
results are organized before being displayed to the user. The
|
|
|
|
|
following values are allowed:
|
|
|
|
|
|
2020-07-05 11:55:27 +00:00
|
|
|
|
- `eldoc-documentation-default': calls functions in the special
|
|
|
|
|
hook in order until one is found that produces a doc string
|
|
|
|
|
value. Display only that value;
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
|
2020-07-05 11:55:27 +00:00
|
|
|
|
- `eldoc-documentation-compose': calls all functions in the
|
|
|
|
|
special hook and displays all of the resulting doc strings
|
|
|
|
|
together. Wait for all strings to be ready, and preserve their
|
2020-04-21 08:51:45 +00:00
|
|
|
|
relative order as specified by the order of functions in the hook;
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
|
2020-07-05 11:55:27 +00:00
|
|
|
|
- `eldoc-documentation-compose-eagerly': calls all functions in
|
2020-04-21 08:51:45 +00:00
|
|
|
|
the special hook and displays as many of the resulting doc
|
|
|
|
|
strings as possible, as soon as possible. Preserves the
|
2020-07-05 11:55:27 +00:00
|
|
|
|
relative order of doc strings;
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
|
2020-07-05 11:55:27 +00:00
|
|
|
|
- `eldoc-documentation-enthusiast': calls all functions in the
|
|
|
|
|
special hook and displays only the most important resulting
|
|
|
|
|
docstring one at any given time. A function appearing first in
|
|
|
|
|
the special hook is considered more important.
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
|
|
|
|
|
This variable can also be set to a function of no args that
|
2020-07-08 10:19:19 +00:00
|
|
|
|
returns something other than a string or nil and allows for some
|
|
|
|
|
or all of the special hook `eldoc-documentation-functions' to be
|
|
|
|
|
run. In that case, the strategy function should follow that
|
|
|
|
|
other variable's protocol closely and endeavor to display the
|
|
|
|
|
resulting doc strings itself.
|
|
|
|
|
|
|
|
|
|
For backward compatibility to the \"old\" protocol, this variable
|
|
|
|
|
can also be set to a function that returns nil or a doc string,
|
|
|
|
|
depending whether or not there is documentation to display at
|
|
|
|
|
all."
|
2020-02-25 22:53:04 +00:00
|
|
|
|
:link '(info-link "(emacs) Lisp Doc")
|
|
|
|
|
:type '(radio (function-item eldoc-documentation-default)
|
|
|
|
|
(function-item eldoc-documentation-compose)
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
(function-item eldoc-documentation-compose-eagerly)
|
|
|
|
|
(function-item eldoc-documentation-enthusiast)
|
2020-02-27 03:47:32 +00:00
|
|
|
|
(function :tag "Other function"))
|
2020-03-12 22:21:19 +00:00
|
|
|
|
:version "28.1")
|
2003-09-06 17:32:31 +00:00
|
|
|
|
|
2020-02-27 03:47:32 +00:00
|
|
|
|
(defun eldoc--supported-p ()
|
|
|
|
|
"Non-nil if an ElDoc function is set for this buffer."
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
(and (not (memq eldoc-documentation-strategy '(nil ignore)))
|
2020-03-12 15:18:07 +00:00
|
|
|
|
(or eldoc-documentation-functions
|
|
|
|
|
;; The old API had major modes set `eldoc-documentation-function'
|
|
|
|
|
;; to provide eldoc support. It's impossible now to determine
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
;; reliably whether the `eldoc-documentation-strategy' provides
|
2020-03-12 15:18:07 +00:00
|
|
|
|
;; eldoc support (as in the old API) or whether it just provides
|
|
|
|
|
;; a way to combine the results of the
|
|
|
|
|
;; `eldoc-documentation-functions' (as in the new API).
|
|
|
|
|
;; But at least if it's set buffer-locally it's a good hint that
|
|
|
|
|
;; there's some eldoc support in the current buffer.
|
Better handle asynchronous Eldoc sources
This is a backward compatible redesign of significant parts of the
eldoc.el library.
Previously, Eldoc clients (major/minor modes setting its documentation
gathering variables) needed to directly call eldoc-message, an
internal function, to display the docstring to the user. When more
asynchronous sources are involved, this is hard to do or even breaks
down.
Now, an Eldoc backend may return any non-nil, non-string value and
call a callback afterwards. This restores power to Eldoc over how
(and crucially also when) to display the docstrings to the user.
Among other things, this fixes so called "doc blinking", or the very
short-lived display of a lower priority Eldoc message. This would
happen if a particular producer of documentation finishes shortly
before a higher priority one, like in the LSP engine Eglot as reported
by Andrii Kolomoiets <andreyk.mad@gmail.com> and Dmitry Gutov
<dgutov@yandex.ru>.
Gathering docstrings is now delegated to the variable
eldoc-documentation-strategy, which is the new name for the
now-obsolete eldoc-documentation-function, and still accepts the
so-called "old protocol". Examples of the new strategies enabled are
codified in functions such as eldoc-documentation-enthusiast,
eldoc-documentation-compose-eagerly, along with the existing
eldoc-documentation-compose and eldoc-documentation-default.
The work of displaying and formatting docstrings is shifted almost
fully to Eldoc itself and is delegated to the internal function
eldoc--handle-docs. Among other improvements, it handles most of
eldoc-echo-area-use-multiline-p and outputs documentation to a
temporary *eldoc* buffer.
The manual and NEWS are updated to mention the new Eldoc features.
* lisp/emacs-lisp/eldoc.el (eldoc-documentation-functions):
Overhaul docstring.
(eldoc-documentation-compose, eldoc-documentation-default): Handle
non-nil, non-string values of elements of
eldoc-documentation-functions. Use eldoc--handle-multiline.
(eldoc-print-current-symbol-info): Honour non-nil, non-string
values returned by eldoc-documentation-callback.
(eldoc--make-callback): Now also a function.
(eldoc-documentation-default, eldoc-documentation-compose): Tweak docstring.
(eldoc-documentation-enthusiast, eldoc-documentation-compose-eagerly):
New functions.
(eldoc-echo-area-use-multiline-p): Add new semantics.
(eldoc--handle-docs): Handle some of eldoc-echo-area-use-multiline-p.
(eldoc-doc-buffer): New command.
(eldoc-prefer-doc-buffer): New defcustom.
(eldoc--enthusiasm-curbing-timer): New variable.
(eldoc-documentation-strategy): Rename from eldoc-documentation-function.
(eldoc--supported-p): Use eldoc-documentation-strategy
(eldoc-highlight-function-argument)
(eldoc-argument-case, global-eldoc-mode)
(turn-on-eldoc-mode): Mention eldoc-documentation-strategy.
(eldoc-message-function): Mention eldoc--message.
(eldoc-message): Made obsolete.
(eldoc--message): New helper.
* lisp/hexl.el (hexl-print-current-point-info): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/cfengine.el (cfengine3-documentation-function):
Adjust to new eldoc-documentation-functions protocol.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-documentation-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/octave.el (octave-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
* lisp/progmodes/python.el (python-eldoc-function): Adjust to new
eldoc-documentation-functions protocol.
(eldoc-print-current-symbol-info): Rework with cl-labels.
* doc/emacs/programs.texi (Lisp Doc): Mention
eldoc-documentation-strategy.
* doc/lispref/modes.texi (Major Mode Conventions): Mention
eldoc-documentation-functions.
* etc/NEWS: Mention eldoc-documentation-strategy.
2020-05-25 15:39:40 +00:00
|
|
|
|
(local-variable-p 'eldoc-documentation-strategy))))
|
|
|
|
|
|
|
|
|
|
(defvar eldoc--enthusiasm-curbing-timer nil
|
2020-07-05 11:55:27 +00:00
|
|
|
|
"Timer used by the `eldoc-documentation-enthusiast' strategy.
|
|
|
|
|
When a doc string is encountered, it must endure a certain amount
|
|
|
|
|
of time unchallenged until it is displayed to the user. This
|
|
|
|
|
prevents blinking if a lower priority docstring comes in shortly
|
|
|
|
|
before a higher priority one.")
|
2020-02-27 03:47:32 +00:00
|
|
|
|
|
2020-06-15 12:55:37 +00:00
|
|
|
|
(defalias 'eldoc #'eldoc-print-current-symbol-info)
|
|
|
|
|
|
2020-07-08 10:19:19 +00:00
|
|
|
|
;; This variable should be unbound, but that confuses
|
|
|
|
|
;; `describe-symbol' for some reason.
|
|
|
|
|
(defvar eldoc--make-callback nil "Helper for function `eldoc--make-callback'.")
|
|
|
|
|
|
|
|
|
|
;; JT@2020-07-08: the below docstring for the internal function
|
|
|
|
|
;; `eldoc--invoke-strategy' could be moved to
|
|
|
|
|
;; `eldoc-documentation-strategy' or thereabouts if/when we decide to
|
|
|
|
|
;; extend or publish the `make-callback' protocol.
|
|
|
|
|
(defun eldoc--make-callback (method)
|
|
|
|
|
"Make callback suitable for `eldoc-documentation-functions'.
|
|
|
|
|
The return value is a function FN whose lambda list is (STRING
|
|
|
|
|
&rest PLIST) and can be called by those functions. Its
|
|
|
|
|
responsibility is always to register the docstring STRING along
|
|
|
|
|
with options specified in PLIST as the documentation to display
|
|
|
|
|
for each particular situation.
|
|
|
|
|
|
|
|
|
|
METHOD specifies how the callback behaves relative to other
|
|
|
|
|
competing elements in `eldoc-documentation-functions'. It can
|
|
|
|
|
have the following values:
|
|
|
|
|
|
|
|
|
|
- `:enthusiast' says to display STRING as soon as possible if
|
|
|
|
|
there's no higher priority doc string;
|
|
|
|
|
|
|
|
|
|
- `:patient' says to display STRING along with all other
|
|
|
|
|
competing strings but only when all of all
|
|
|
|
|
`eldoc-documentation-functions' have been collected;
|
|
|
|
|
|
|
|
|
|
- `:eager' says to display STRING along with all other competing
|
|
|
|
|
strings so far, as soon as possible."
|
|
|
|
|
(funcall eldoc--make-callback method))
|
|
|
|
|
|
2020-09-06 14:37:02 +00:00
|
|
|
|
(defun eldoc--invoke-strategy (interactive)
|
2020-07-08 10:19:19 +00:00
|
|
|
|
"Invoke `eldoc-documentation-strategy' function.
|
|
|
|
|
|
2020-09-06 14:37:02 +00:00
|
|
|
|
If INTERACTIVE is non-nil, the request came directly from a user
|
|
|
|
|
command, otherwise it came from ElDoc's idle
|
|
|
|
|
timer, `eldoc-timer'.
|
|
|
|
|
|
2020-07-08 10:19:19 +00:00
|
|
|
|
That function's job is to run the `eldoc-documentation-functions'
|
2020-07-18 22:50:00 +00:00
|
|
|
|
special hook, using the `run-hook' family of functions. ElDoc's
|
|
|
|
|
built-in strategy functions play along with the
|
2020-09-06 14:37:02 +00:00
|
|
|
|
`eldoc--make-callback' protocol, using it to produce a callback
|
|
|
|
|
argument to feed the functions that the user places in
|
|
|
|
|
`eldoc-documentation-functions'. Whenever the strategy
|
|
|
|
|
determines it has information to display to the user, this
|
|
|
|
|
function passes responsibility to the functions in
|
|
|
|
|
`eldoc-display-functions'.
|
|
|
|
|
|
|
|
|
|
Other third-party values of `eldoc-documentation-strategy' should
|
|
|
|
|
not use `eldoc--make-callback'. They must find some alternate
|
|
|
|
|
way to produce callbacks to feed to
|
2020-04-21 08:51:45 +00:00
|
|
|
|
`eldoc-documentation-functions' and should endeavour to display
|
2020-09-06 14:37:02 +00:00
|
|
|
|
the docstrings eventually produced, using
|
|
|
|
|
`eldoc-display-functions'."
|
2020-07-18 22:50:00 +00:00
|
|
|
|
(let* (;; How many callbacks have been created by the strategy
|
2020-09-21 11:29:10 +00:00
|
|
|
|
;; function and passed to elements of
|
2020-07-18 22:50:00 +00:00
|
|
|
|
;; `eldoc-documentation-functions'.
|
2020-07-08 10:19:19 +00:00
|
|
|
|
(howmany 0)
|
2020-07-18 22:50:00 +00:00
|
|
|
|
;; How many calls to callbacks we're still waiting on. Used
|
|
|
|
|
;; by `:patient'.
|
2020-07-08 10:19:19 +00:00
|
|
|
|
(want 0)
|
2020-07-18 22:50:00 +00:00
|
|
|
|
;; The doc strings and corresponding options registered so
|
|
|
|
|
;; far.
|
2020-07-08 10:19:19 +00:00
|
|
|
|
(docs-registered '()))
|
2020-07-18 22:50:00 +00:00
|
|
|
|
(cl-labels
|
|
|
|
|
((register-doc
|
|
|
|
|
(pos string plist)
|
|
|
|
|
(when (and string (> (length string) 0))
|
|
|
|
|
(push (cons pos (cons string plist)) docs-registered)))
|
|
|
|
|
(display-doc
|
|
|
|
|
()
|
2020-09-06 14:37:02 +00:00
|
|
|
|
(run-hook-with-args
|
|
|
|
|
'eldoc-display-functions (mapcar #'cdr
|
|
|
|
|
(setq docs-registered
|
|
|
|
|
(sort docs-registered
|
|
|
|
|
(lambda (a b) (< (car a) (car b))))))
|
|
|
|
|
interactive))
|
2020-07-18 22:50:00 +00:00
|
|
|
|
(make-callback
|
|
|
|
|
(method)
|
|
|
|
|
(let ((pos (prog1 howmany (cl-incf howmany))))
|
|
|
|
|
(cl-ecase method
|
|
|
|
|
(:enthusiast
|
|
|
|
|
(lambda (string &rest plist)
|
|
|
|
|
(when (and string (cl-loop for (p) in docs-registered
|
|
|
|
|
never (< p pos)))
|
|
|
|
|
(setq docs-registered '())
|
2020-09-03 21:17:29 +00:00
|
|
|
|
(register-doc pos string plist))
|
|
|
|
|
(when (and (timerp eldoc--enthusiasm-curbing-timer)
|
|
|
|
|
(memq eldoc--enthusiasm-curbing-timer
|
|
|
|
|
timer-list))
|
|
|
|
|
(cancel-timer eldoc--enthusiasm-curbing-timer))
|
|
|
|
|
(setq eldoc--enthusiasm-curbing-timer
|
|
|
|
|
(run-at-time (unless (zerop pos) 0.3)
|
|
|
|
|
nil #'display-doc))
|
2020-07-18 22:50:00 +00:00
|
|
|
|
t))
|
|
|
|
|
(:patient
|
|
|
|
|
(cl-incf want)
|
|
|
|
|
(lambda (string &rest plist)
|
|
|
|
|
(register-doc pos string plist)
|
|
|
|
|
(when (zerop (cl-decf want)) (display-doc))
|
|
|
|
|
t))
|
|
|
|
|
(:eager
|
|
|
|
|
(lambda (string &rest plist)
|
|
|
|
|
(register-doc pos string plist)
|
|
|
|
|
(display-doc)
|
|
|
|
|
t))))))
|
|
|
|
|
(let* ((eldoc--make-callback #'make-callback)
|
|
|
|
|
(res (funcall eldoc-documentation-strategy)))
|
|
|
|
|
;; Observe the old and the new protocol:
|
|
|
|
|
(cond (;; Old protocol: got string, output immediately;
|
|
|
|
|
(stringp res) (register-doc 0 res nil) (display-doc))
|
|
|
|
|
(;; Old protocol: got nil, clear the echo area;
|
|
|
|
|
(null res) (eldoc--message nil))
|
|
|
|
|
(;; New protocol: trust callback will be called;
|
|
|
|
|
t))))))
|
2020-07-08 10:19:19 +00:00
|
|
|
|
|
2020-07-09 12:12:34 +00:00
|
|
|
|
(defun eldoc-print-current-symbol-info (&optional interactive)
|
2020-07-08 10:19:19 +00:00
|
|
|
|
"Document thing at point."
|
2020-07-09 12:12:34 +00:00
|
|
|
|
(interactive '(t))
|
2020-09-06 14:37:02 +00:00
|
|
|
|
(let (token)
|
2020-07-18 23:48:43 +00:00
|
|
|
|
(cond (interactive
|
2020-09-06 14:37:02 +00:00
|
|
|
|
(eldoc--invoke-strategy t))
|
|
|
|
|
((not (equal (setq token (eldoc--request-state))
|
|
|
|
|
eldoc--last-request-state))
|
2020-07-09 12:12:34 +00:00
|
|
|
|
(let ((non-essential t))
|
2020-07-18 23:48:43 +00:00
|
|
|
|
(setq eldoc--last-request-state token)
|
2020-12-13 23:08:42 +00:00
|
|
|
|
(eldoc--invoke-strategy nil))))))
|
2014-03-31 01:31:17 +00:00
|
|
|
|
|
2020-09-06 14:37:02 +00:00
|
|
|
|
|
|
|
|
|
;; This section only affects ElDoc output to the echo area, as in
|
|
|
|
|
;; `eldoc-display-in-echo-area'.
|
|
|
|
|
;;
|
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)
|
2017-07-22 08:09:36 +00:00
|
|
|
|
"Add each of CMDS to the obarray `eldoc-message-commands'."
|
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)
|
2017-07-22 08:09:36 +00:00
|
|
|
|
"Pass every prefix completion of NAMES to `eldoc-add-command'."
|
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)
|
2017-07-22 08:09:36 +00:00
|
|
|
|
"Remove each of CMDS from the obarray `eldoc-message-commands'."
|
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)
|
2017-07-22 08:09:36 +00:00
|
|
|
|
"Pass every prefix completion of NAMES to `eldoc-remove-command'."
|
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
|
|
|
|
|
|
|
|
|
;; Prime the command list.
|
|
|
|
|
(eldoc-add-command-completions
|
2015-10-17 15:49:36 +00:00
|
|
|
|
"back-to-indentation"
|
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-"
|
2017-07-22 08:09:36 +00:00
|
|
|
|
"move-end-of-" "newline" "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
|