#'eldoc--eval-expression-setup)))
(defun eldoc--eval-expression-setup ()
- ;; Setup `eldoc', similar to `emacs-lisp-mode'. FIXME: Call
- ;; `emacs-lisp-mode' itself?
- (cond ((<= emacs-major-version 27)
- (declare-function elisp-eldoc-documentation-function "elisp-mode")
- (with-no-warnings
- (add-function :before-until (local 'eldoc-documentation-function)
- #'elisp-eldoc-documentation-function)))
- (t (add-hook 'eldoc-documentation-functions
- #'elisp-eldoc-var-docstring nil t)
- (add-hook 'eldoc-documentation-functions
- #'elisp-eldoc-funcall nil t)
- (setq-local eldoc-documentation-strategy
- 'eldoc-documentation-default)))
+ (add-hook 'eldoc-documentation-functions #'elisp-eldoc-var-docstring nil t)
+ (add-hook 'eldoc-documentation-functions #'elisp-eldoc-funcall nil t)
+ (setq-local eldoc-documentation-strategy 'eldoc-documentation-default)
(eldoc-mode +1))
;;;###autoload
nil)))
t)
-;; JT@2020-07-10: ElDoc is pre-loaded, so in Emacs < 28 we can't
-;; make the "old" `eldoc-documentation-function' point to the new
-;; `eldoc-documentation-strategy', so we do the reverse. This allows
-;; for ElDoc to be loaded in those older Emacs versions and work with
-;; whomever (major-modes, extensions, user) sets one or the other
-;; 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
+(defcustom eldoc-documentation-strategy #'eldoc-documentation-default
"How to collect and display results of `eldoc-documentation-functions'.
This variable controls how to call the functions in the special hook
(scope
(lambda (type sym len bind)
(if (null bind)
- (put-text-property sym (+ sym len) 'face
- (cl-case type
- (variable 'elisp-free-variable)
- (function 'font-lock-function-call-face)
- (defun 'font-lock-function-name-face)))
+ (when-let ((face (cl-case type
+ (variable 'elisp-free-variable)
+ (function 'font-lock-function-call-face)
+ (defun 'font-lock-function-name-face)
+ (defvar 'font-lock-variable-name-face))))
+ (put-text-property sym (+ sym len) 'face face))
(put-text-property sym (+ sym len) 'face
(if (equal sym bind)
'elisp-binding-variable
(save-excursion
(let ((state (syntax-ppss pos)))
(or (nth 8 state) ; Code inside strings usually isn't evaluated.
- ;; FIXME: The 9th element is undocumented.
(let ((nesting (cons (point) (reverse (nth 9 state))))
res)
(while (and nesting (not res))
or argument string for functions.
2 - `function' if function args, `variable' if variable documentation.")
-(defun elisp--documentation-one-liner ()
- (let* (str
- (callback (lambda (doc &rest plist)
- (when doc
- (setq str
- (format "%s: %s"
- (propertize (prin1-to-string
- (plist-get plist :thing))
- 'face (plist-get plist :face))
- doc))))))
- (or (progn (elisp-eldoc-var-docstring callback) str)
- (progn (elisp-eldoc-funcall callback) str))))
-
-(defalias 'elisp-eldoc-documentation-function #'elisp--documentation-one-liner
- "Return Elisp documentation for the thing at point as one-line string.
-This is meant as a backward compatibility aide to the \"old\"
-Elisp eldoc behavior. Consider variable docstrings and function
-signatures only, in this order. If none applies, returns nil.
-Changes to `eldoc-documentation-functions' and
-`eldoc-documentation-strategy' are _not_ reflected here. As such
-it is preferable to use ElDoc's interfaces directly.")
-
-(make-obsolete 'elisp-eldoc-documentation-function
- "use ElDoc's interfaces instead." "28.1")
-
(defun elisp-eldoc-funcall (callback &rest _ignored)
"Document function call at point by calling CALLBACK.
Intended for `eldoc-documentation-functions' (which see)."
:version "25.1")
(defun python-eldoc-function (&rest _ignored)
- "`eldoc-documentation-function' for Python.
+ "`eldoc-documentation-functions' entry for Python.
For this to work as best as possible you should call
`python-shell-send-buffer' from time to time so context in
inferior Python process is updated properly.
(current-column))))
(^ '(- (1+ (current-indentation))))))
- (with-no-warnings
- ;; suppress warnings about eldoc-documentation-function being obsolete
- (if (null eldoc-documentation-function)
- ;; Emacs<25
- (setq-local eldoc-documentation-function #'python-eldoc-function)
- (if (boundp 'eldoc-documentation-functions)
- (add-hook 'eldoc-documentation-functions #'python-eldoc-function nil t)
- (add-function :before-until (local 'eldoc-documentation-function)
- #'python-eldoc-function))))
+ (add-hook 'eldoc-documentation-functions #'python-eldoc-function nil t)
;; TODO: Use tree-sitter to figure out the block in `python-ts-mode'.
(dolist (mode '(python-mode python-ts-mode))