about summary refs log tree commit diff
path: root/configs/shared/emacs/.emacs.d/elpa/evil-collection-20180720.526/evil-collection-calendar.el
blob: 09b166186de1c75c5170fff5865505cbc31fcc49 (plain) (blame)
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
;;; evil-collection-calendar.el --- Evil bindings for calendar -*- lexical-binding: t -*-

;; Copyright (C) 2017 Pierre Neidhardt

;; Author: Pierre Neidhardt <ambrevar@gmail.com>
;; Maintainer: James Nguyen <james@jojojames.com>
;; Pierre Neidhardt <ambrevar@gmail.com>
;; URL: https://github.com/emacs-evil/evil-collection
;; Version: 0.0.1
;; Package-Requires: ((emacs "25.1"))
;; Keywords: evil, calendar, tools

;; This file 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, or (at your
;; option) any later version.
;;
;; This file 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.
;;
;; For a full copy of the GNU General Public License
;; see <http://www.gnu.org/licenses/>.

;;; Commentary:
;; Evil bindings for the calendar.

;;; Code:
(require 'calendar)
(require 'evil-collection)

(defconst evil-collection-calendar-maps '(calendar-mode-map))

(defun evil-collection-calendar-setup ()
  "Set up `evil' bindings for `calendar'."
  (evil-set-initial-state 'calendar-mode 'normal)
  (evil-collection-define-key 'normal 'calendar-mode-map
    ;; motion
    "h" 'calendar-backward-day
    "j" 'calendar-forward-week
    "k" 'calendar-backward-week
    "l" 'calendar-forward-day
    "0" 'calendar-beginning-of-week
    "^" 'calendar-beginning-of-week
    "$" 'calendar-end-of-week
    "[" 'calendar-backward-year
    "]" 'calendar-forward-year
    (kbd "M-<") 'calendar-beginning-of-year
    (kbd "M->") 'calendar-end-of-year
    "(" 'calendar-beginning-of-month
    ")" 'calendar-end-of-month
    (kbd "SPC") 'scroll-other-window
    (kbd "S-SPC") 'scroll-other-window-down
    (kbd "<delete>") 'scroll-other-window-down
    "<" 'calendar-scroll-right
    ">" 'calendar-scroll-left
    (kbd "C-b") 'calendar-scroll-right-three-months
    (kbd "C-f") 'calendar-scroll-left-three-months
    "{" 'calendar-backward-month
    "}" 'calendar-forward-month
    (kbd "C-k") 'calendar-backward-month
    (kbd "C-j") 'calendar-forward-month
    "gk" 'calendar-backward-month
    "gj" 'calendar-forward-month

    ;; visual
    "v" 'calendar-set-mark

    ;; goto
    "." 'calendar-goto-today
    "gd" 'calendar-goto-date ; "gd" in evil-org-agenda, "gd" in Emacs.
    ;; "gD" 'calendar-other-month ; Not very useful if we have `calendar-goto-date'.

    ;; diary
    "D" 'diary-view-other-diary-entries
    "d" 'diary-view-entries
    "m" 'diary-mark-entries
    "s" 'diary-show-all-entries

    "u" 'calendar-unmark
    "x" 'calendar-mark-holidays

    ;; show
    "gm" 'calendar-lunar-phases ; "gm" in evil-org-agenda. TODO: Shadows calendar-mayan.
    "gs" 'calendar-sunrise-sunset ; "gs" in evil-org-agenda
    "gh" 'calendar-list-holidays ; "gh" in evil-org-agenda. TODO: Shadows calendar-hebrew.
    "gc" 'org-calendar-goto-agenda ; "gc" in evil-org-agenda. TODO: Shadows calendar-iso.
    "r" 'calendar-cursor-holidays

    ;; refresh
    "gr" 'calendar-redraw

    "g?" 'calendar-goto-info-node
    "?" 'calendar-goto-info-node ; Search is not very useful.
    (kbd "M-=") 'calendar-count-days-region

    ;; quit
    "q" 'calendar-exit
    "ZQ" 'evil-quit
    "ZZ" 'calendar-exit))

(provide 'evil-collection-calendar)
;;; evil-collection-calendar.el ends here