-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcompany-quickhelp-terminal.el
88 lines (69 loc) · 3.52 KB
/
company-quickhelp-terminal.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
;;; company-quickhelp-terminal.el --- Terminal support for `company-quickhelp' -*- lexical-binding: t; -*-
;; Copyright (C) 2019-2024 Shen, Jen-Chieh
;; Created date 2019-12-09 23:06:42
;; Author: Shen, Jen-Chieh <[email protected]>
;; URL: https://github.com/jcs-elpa/company-quickhelp-terminal
;; Version: 0.1.1
;; Package-Requires: ((emacs "24.4") (company-quickhelp "2.2.0") (popup "0.5.3"))
;; Keywords: convenience terminal extends support tip help
;; This file is NOT part of GNU Emacs.
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;;
;; Terminal support for `company-quickhelp'.
;;
;;; Code:
(require 'company-quickhelp)
(require 'popup)
(defgroup company-quickhelp-terminal nil
"Terminal support for `company-quickhelp'."
:prefix "company-quickhelp-terminal-"
:group 'tools
:link '(url-link :tag "Repository" "https://github.com/jcs-elpa/company-quickhelp-terminal"))
;;; Core
(defun company-quickhelp-terminal--pos-tip-show-no-propertize
(string &optional _tip-color _pos _window _timeout pixel-width pixel-height _frame-coordinates _dx _dy)
"Override `pos-tip-show-no-propertize' function from `pos-tip'."
(popup-tip string :point (overlay-start company-pseudo-tooltip-overlay)
:width pixel-width :height pixel-height :nostrip nil))
(defun company-quickhelp-terminal--pos-tip-show
(string &optional _tip-color _pos _window _timeout width _frame-coordinates _dx _dy)
"Override `pos-tip-show' function from `pos-tip'."
(popup-tip string :point (overlay-start company-pseudo-tooltip-overlay)
:width width :nostrip t))
(defun company-quickhelp-terminal--pos-tip-available-p ()
"Override `company-quickhelp-pos-tip-available-p' function from `company-quickhelp'."
(and
(fboundp 'x-hide-tip)
(fboundp 'x-show-tip)))
;;; Entry
(defun company-quickhelp-terminal--enable ()
"Enable `company-quickhelp-terminal'."
(advice-add 'pos-tip-show :override #'company-quickhelp-terminal--pos-tip-show)
(advice-add 'pos-tip-show-no-propertize :override #'company-quickhelp-terminal--pos-tip-show-no-propertize)
(advice-add 'company-quickhelp-pos-tip-available-p :override #'company-quickhelp-terminal--pos-tip-available-p))
(defun company-quickhelp-terminal--disable ()
"Disable `company-quickhelp-terminalw'."
(advice-remove 'pos-tip-show #'company-quickhelp-terminal--pos-tip-show)
(advice-remove 'pos-tip-show-no-propertize #'company-quickhelp-terminal--pos-tip-show-no-propertize)
(advice-remove 'company-quickhelp-pos-tip-available-p #'company-quickhelp-terminal--pos-tip-available-p))
;;;###autoload
(define-minor-mode company-quickhelp-terminal-mode
"Minor mode 'company-quickhelp-terminal-mode'."
:global t
:require 'company-quickhelp-terminal
:group 'company-quickhelp-terminal
(if company-quickhelp-terminal-mode
(company-quickhelp-terminal--enable)
(company-quickhelp-terminal--disable)))
(provide 'company-quickhelp-terminal)
;;; company-quickhelp-terminal.el ends here