답변:
실제로 오버레이를 사용하여 해당 동작을 수행합니다. 특히이 'after-string
속성을 사용하여 설명서를 표시합니다 ( 오버레이 속성 참조 ).
함수를 검사하면 company-coq--show-definition-overlay-at-point
(예 : via M-x find-function
) 정확히 어떻게 작성되었는지 확인할 수 있습니다.
(setq company-coq-definition-overlay (make-overlay ins-pos ins-pos))
(overlay-put company-coq-definition-overlay 'after-string ins-str)
오버레이에 대한 참조는 company-coq-definition-overlay
나중에 오버레이를 쉽게 제거 할 수 있도록 유지됩니다 .
(delete-overlay company-coq-definition-overlay)
(setq company-coq-definition-overlay nil)
ins-str
있는을 company-coq--show-definition-overlay-at-point
. 특정면과 스타일은 해당 문자열에 텍스트 속성으로 존재합니다. 텍스트 속성 : 특수 속성 은 해당 속성을 디코딩하는 데 유용한 참조입니다.
(defvar inline-docs-overlay nil)
(defgroup inline-docs nil
"Show inline contextual docs in Emacs."
:group 'docs)
(defcustom inline-docs-border-symbol ?―
"Specify symbol for inline-docs border."
:group 'inline-docs)
(defcustom inline-docs-prefix-symbol ?\s
"Specify symbol for inline-docs prefix."
:group 'inline-docs)
(defcustom inline-docs-indicator-symbol "➜"
"Specify symbol for inline-docs indicator."
:group 'inline-docs)
(defface inline-docs-face
'((t (:inherit italic)))
"Face for `inline-docs-mode'."
:group 'inline-docs)
(defface inline-docs-border-face
'((t (:inherit font-lock-doc-face)))
"Face for inline docs border lines."
:group 'inline-docs)
(defface inline-docs-prefix-face
'((t (:inherit default)))
"Face for inline docs prefix."
:group 'inline-docs)
(defface inline-docs-indicator-face
'((t (:inherit font-lock-doc-face)))
"Face for inline docs indicator."
:group 'inline-docs)
(defun inline-docs--clear-overlay ()
"Clear inline-docs overlays."
(when (overlayp inline-docs-overlay)
(delete-overlay inline-docs-overlay))
(remove-hook 'post-command-hook 'inline-docs--clear-overlay))
(defun inline-docs--string-display-next-line (string apply-face)
"Show STRING contents below point line until next command with APPLY-FACE."
(let* ((border-line (make-string (window-body-width) inline-docs-border-symbol))
(prefix (make-string
(if (= (current-indentation) 0) ; fix (wrong-type-argument wholenump -1) when current indentation is 0 minus 1 will caused wholenump exception.
(current-indentation)
(- (current-indentation) 1))
inline-docs-prefix-symbol))
(str (concat (propertize border-line
'face 'inline-docs-border-face)
"\n"
prefix
(propertize (concat inline-docs-indicator-symbol " ")
'face 'inline-docs-indicator-face)
(copy-sequence string) ; original eldoc string with format.
"\n"
(propertize border-line
'face 'inline-docs-border-face)
"\n"
))
start-pos end-pos)
(unwind-protect
(save-excursion
(inline-docs--clear-overlay)
(forward-line)
(setq start-pos (point))
(end-of-line)
(setq end-pos (point))
(setq inline-docs-overlay (make-overlay start-pos end-pos (current-buffer)))
;; change the face
(if apply-face
(overlay-put inline-docs-overlay 'face 'inline-docs-face))
;; hide full line
;; (overlay-put inline-docs-overlay 'display "")
;; (overlay-put inline-docs-overlay 'display :height 20)
;; pre-pend indentation spaces
;; (overlay-put inline-docs-overlay 'line-prefix prefix)
;; auto delete overlay
(overlay-put inline-docs-overlay 'evaporate t)
;; display message
(overlay-put inline-docs-overlay 'before-string str))
(add-hook 'post-command-hook 'inline-docs--clear-overlay))))
(defun inline-docs-display-docs-momentary (format-string &rest args)
"Display inline docs FORMAT-STRING under point with extra ARGS."
(when format-string
(inline-docs--string-display-next-line
(apply 'format format-string args)
t)))
;;;###autoload
(defalias 'inline-docs 'inline-docs-display-docs-momentary)
https://github.com/stardiviner/inline-docs.el
및 inline-docs.el
eldoc에 사용하는 모듈에 대한 저장소를 만들었습니다 .
https://github.com/stardiviner/eldoc-overlay-mode .
(overlay-put OVERLAY 'after-string STR)
는 스크린 캐스트에서와 같이 fontify를 갖지 않습니다.