Correctly compose eldoc documentation (issue#62)
* eldoc-box.el (eldoc-box--compose-doc): New function. (eldoc-box--eldoc-display-function): Use eldoc-box--compose-doc.
This commit is contained in:
parent
d7d302989e
commit
39c0379dd0
30
eldoc-box.el
30
eldoc-box.el
@ -525,12 +525,29 @@ Display STR in childframe and ARGS works like `message'."
|
||||
;; this function is added as a ‘:before-while’ advice.
|
||||
single-line-p)))
|
||||
|
||||
(defun eldoc-box--compose-doc (doc)
|
||||
"Compose a doc passed from eldoc.
|
||||
|
||||
DOC has the form of (TEXT :KEY VAL...), and KEY can be ‘:thing’
|
||||
and ‘:face’, among other things. If ‘:thing’ exists, it is put at
|
||||
the start of the doc followed by a colon. If ‘:face’ exists, it
|
||||
is applied to the thing.
|
||||
|
||||
Return the composed string."
|
||||
(let ((thing (plist-get (cdr doc) :thing))
|
||||
(face (plist-get (cdr doc) :face)))
|
||||
(concat (if thing
|
||||
(concat (propertize (format "%s" thing) 'face face) ": ")
|
||||
"")
|
||||
(car doc))))
|
||||
|
||||
(defun eldoc-box--eldoc-display-function (docs interactive)
|
||||
"Display DOCS in childframe.
|
||||
For DOCS and INTERACTIVE see ‘eldoc-display-functions’. Maybe
|
||||
display the docs in echo area depending on
|
||||
‘eldoc-box-only-multi-line’."
|
||||
(let ((doc (string-trim (string-join (mapcar #'car docs)
|
||||
(let ((doc (string-trim (string-join
|
||||
(mapcar #'eldoc-box--compose-doc docs)
|
||||
"\n\n"))))
|
||||
(when (eldoc-box--eldoc-message-function "%s" doc)
|
||||
(eldoc-display-in-echo-area docs interactive))))
|
||||
@ -695,6 +712,17 @@ height."
|
||||
("<" "<")
|
||||
(">" ">"))))))
|
||||
|
||||
;;;; Tab-bar compatibility
|
||||
|
||||
(defun eldoc-box-reset-frame ()
|
||||
"Discard the current childframe and regenerate one.
|
||||
This allows any change in childframe parameter to take effect."
|
||||
(interactive)
|
||||
(setq eldoc-box--frame nil))
|
||||
|
||||
(with-eval-after-load 'tab-bar-mode
|
||||
(add-hook 'tab-bar-mode-hook #'eldoc-box-reset-frame))
|
||||
|
||||
(provide 'eldoc-box)
|
||||
|
||||
;;; eldoc-box.el ends here
|
||||
|
Loading…
Reference in New Issue
Block a user