summaryrefslogtreecommitdiff
path: root/keycast-conf.el
blob: a7bb5c63f07c4d07dab3f1a054d431d77d81333e (plain)
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
;;; keycast-conf.el --- Configuration of keycast mode  -*- lexical-binding: t; -*-

;; Copyright (C) 2022  李俊緯

;; Author: 李俊緯 <mmemmew@gmail.com>
;; Keywords: emulations, help, tools

;; 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:

;; Configuring the mode to my liking.

;;; Code:

;; The original minor mode tries to insert an element to the
;; `mode-line-format'.  But my mode line format consists of one custom
;; element only, so it is not going to work that way.  Rather, I shall
;; define my own minor mode to just skip this part.

(autoload 'use-package "basic")

(use-package "keycast" 'keycast)

(require 'keycast)
(require 'modeline)

(setq keycast-separator-width 0)

(setq keycast-window-predicate #'modeline-active-window-p)

(setq keycast-substitute-alist
      (list (list #'self-insert-command (string #x2e) "Typing...")))

(define-minor-mode durand-keycast-mode
  "Show current command and its key binding in the mode line."
  :global t
  :group 'keycast
  :lighter "K"
  (cond
   (durand-keycast-mode
    (add-hook 'pre-command-hook #'keycast--update t))
   (keycast-log-mode)
   ((remove-hook 'pre-command-hook #'keycast--update))))

(defvar durand-view-map)

(define-key durand-view-map (vector ?k) #'durand-keycast-mode)

(provide 'keycast-conf)
;;; keycast-conf.el ends here