switch display function library from inline-docs to quick-peek.
[eldoc-overlay.git] / eldoc-overlay-mode.el
blob909df0a18730f94ced4351b4e65ded63be813c59
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-mode
6 ;; Created: 14th Jan 2017
7 ;; Version: 0.0.1
8 ;; Package-Requires: ((emacs "24.3") (inline-docs "1.0.1") (quick-peek "1.0"))
10 ;;; Commentary:
14 ;;; Code:
15 ;;; ----------------------------------------------------------------------------
17 (defvar eldoc-overlay-mode-map
18 (let ((map (make-sparse-keymap)))
19 map))
21 (defcustom eldoc-overlay-library #'quick-peek
22 "Specify the library for displaying eldoc.
23 Two libraries currently supported: `inline-docs', and `quick-peek'.")
25 (defvar eldoc-overlay-function (pcase eldoc-overlay-library
26 (`inline-docs 'inline-docs)
27 (`quick-peek 'eldoc-overlay-quick-peek))
28 "Specify the function for displaying eldoc.
29 Two functions currently supported: `inline-docs', and `quick-peek'.")
31 (defun eldoc-overlay-disable-in-org-mode ()
32 (setq-local eldoc-message-function #'eldoc-minibuffer-message))
34 (defun eldoc-overlay-quick-peek (format-string &rest args)
35 (when format-string
36 (quick-peek-show
37 (apply 'format format-string args)
38 (point)
39 1)))
41 ;;;###autoload
42 (define-minor-mode eldoc-overlay-mode
43 "Minor mode for displaying eldoc with contextual documentation overlay."
44 :init-value t
45 :lighter " ElDoc overlay"
46 :keymap eldoc-overlay-mode-map
47 :global t
48 (if eldoc-overlay-mode
49 (progn
50 (setq eldoc-message-function eldoc-overlay-function)
51 (add-hook 'post-command-hook 'quick-peek-hide)
52 (add-hook 'org-mode-hook #'eldoc-overlay-disable-in-org-mode))
53 (setq eldoc-message-function #'eldoc-minibuffer-message)
57 ;;; ----------------------------------------------------------------------------
59 (provide 'eldoc-overlay-mode)
61 ;;; eldoc-overlay-mode.el ends here