Append elisp variable's value to eldoc

This commit is contained in:
Henrik Lissner 2020-05-06 21:01:04 -04:00
parent 9a628c7a12
commit a80ae71b05
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -84,6 +84,24 @@ This marks a foldable marker for `outline-minor-mode' in elisp buffers.")
;; Recenter window after following definition ;; Recenter window after following definition
(advice-add #'elisp-def :after #'doom-recenter-a) (advice-add #'elisp-def :after #'doom-recenter-a)
(defadvice! +emacs-lisp-append-value-to-eldoc-a (orig-fn sym)
"Display variable value next to documentation in eldoc."
:around #'elisp-get-var-docstring
(when-let (ret (funcall orig-fn sym))
(concat ret " "
(let* ((truncated " [...]")
(limit (- (frame-width) (length ret) (length truncated) 1))
(str (symbol-value sym))
(str (prin1-to-string
(if (stringp str)
(replace-regexp-in-string "\n" " " str)
str)))
(str-length (length str))
(short (< str-length limit)))
(concat (substring (propertize str 'face 'warning)
0 (if short str-length limit))
(unless short truncated))))))
(map! :localleader (map! :localleader
:map emacs-lisp-mode-map :map emacs-lisp-mode-map
:desc "Expand macro" "m" #'macrostep-expand :desc "Expand macro" "m" #'macrostep-expand