rename eldoc-overlay-disable-in-org-mode to eldoc-overlay-disable
[eldoc-overlay.git] / eldoc-overlay-mode.el
blob096d321e42ef36681bfc098a74b50cfe8d220257
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.1.0
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 (defun eldoc-overlay-disable ()
33 "Disable `eldoc-overlay-mode' in some modes."
34 (setq-local eldoc-message-function #'eldoc-minibuffer-message))
36 (defun eldoc-overlay-quick-peek (format-string &rest args)
37 (when format-string
38 (quick-peek-show
39 (apply 'format format-string args)
40 (point)
41 1)))
43 ;;;###autoload
44 (define-minor-mode eldoc-overlay-mode
45 "Minor mode for displaying eldoc with contextual documentation overlay."
46 :init-value t
47 :lighter " ElDoc overlay"
48 :keymap eldoc-overlay-mode-map
49 :global t
50 :require 'eldoc-overlay-mode
51 (if eldoc-overlay-mode
52 (progn
53 (setq eldoc-message-function eldoc-overlay-function)
54 (add-hook 'post-command-hook 'quick-peek-hide)
55 (add-hook 'org-mode-hook #'eldoc-overlay-disable))
56 (setq eldoc-message-function #'eldoc-minibuffer-message)
60 ;;; ----------------------------------------------------------------------------
62 (provide 'eldoc-overlay-mode)
64 ;;; eldoc-overlay-mode.el ends here