1 ;;; eldoc-overlay-mode.el --- Display eldoc with contextual documentation overlay.
3 ;; Author: stardiviner <numbchild@gmail.com>
4 ;; Keywords: eldoc overlay
5 ;; URL: https://github.com/stardiviner/eldoc-overlay
6 ;; Created: 14th Jan 2017
8 ;; Package-Requires: ((emacs "24.3"))
15 ;;; ----------------------------------------------------------------------------
17 (defvar eldoc-overlay-display-overlay nil
)
19 (defun eldoc-overlay-delete-string-display ()
20 (when (overlayp eldoc-overlay-display-overlay
)
21 (delete-overlay eldoc-overlay-display-overlay
))
22 (remove-hook 'post-command-hook
'eldoc-overlay-delete-string-display
))
24 (defun eldoc-overlay-string-display-next-line (string)
25 "Overwrite contents of next line with STRING until next command."
26 (let ((str (concat (make-string (1+ (current-indentation)) 32)
27 (copy-sequence string
)))
31 (eldoc-overlay-delete-string-display)
33 (setq start-pos
(point))
35 (setq end-pos
(point))
36 (setq eldoc-overlay-display-overlay
(make-overlay start-pos end-pos
))
38 (overlay-put eldoc-overlay-display-overlay
'display
"")
40 (overlay-put eldoc-overlay-display-overlay
'before-string str
))
41 (add-hook 'post-command-hook
'eldoc-overlay-delete-string-display
))))
43 (defun eldoc-overlay-display-message-momentary (format-string &rest args
)
44 "Display eldoc message near point."
46 (eldoc-overlay-string-display-next-line
47 (apply 'format format-string args
))))
49 (defvar eldoc-overlay-mode-map
50 (let ((map (make-sparse-keymap)))
53 (define-minor-mode eldoc-overlay-mode
54 "Minor mode for displaying eldoc with contextual documentation overlay."
56 :lighter
"ElDoc overlay"
57 :keymap eldoc-overlay-mode-map
59 (if eldoc-overlay-mode
60 (setq eldoc-message-function
#'eldoc-overlay-display-message-momentary
)
61 (setq eldoc-message-function
#'eldoc-minibuffer-message
)
65 ;;; ----------------------------------------------------------------------------
67 (provide 'eldoc-overlay-mode
)
69 ;;; eldoc-overlay-mode.el ends here