diff options
| author | condy <condy0919@gmail.com> | 2020-06-16 16:36:45 +0800 |
|---|---|---|
| committer | James N <james@jojojames.com> | 2020-06-18 11:28:43 -0700 |
| commit | a0de3a9cf3d03a460d1880f0e2776ecbaa050ee1 (patch) | |
| tree | c7aa93506a53bac20a1f790388b1b19a4f61dc02 /modes/calendar | |
| parent | 39a38da4e1ef483395a5f05d2580265e07136ec0 (diff) | |
calendar: Bind Org functions in calendar keymap
Diffstat (limited to 'modes/calendar')
| -rw-r--r-- | modes/calendar/evil-collection-calendar.el | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/modes/calendar/evil-collection-calendar.el b/modes/calendar/evil-collection-calendar.el index 58f73c6..155d3cc 100644 --- a/modes/calendar/evil-collection-calendar.el +++ b/modes/calendar/evil-collection-calendar.el @@ -32,6 +32,35 @@ (defconst evil-collection-calendar-maps '(calendar-mode-map)) +(defun evil-collection-calendar-setup-org-bindings () + "Bind Org functions to Calendar keymap." + (require 'org) + (defvar org-calendar-to-agenda-key) + (defvar org-agenda-diary-file) + (defvar org-calendar-insert-diary-entry-key) + + (let ((key (pcase org-calendar-to-agenda-key + ((and key (pred stringp)) key) + ;; The default value of `org-calendar-to-agenda-key' is [?c] in Org 9.1 + ;; We do make a minimal compatibility support for vector of integers. + ((and key (pred vectorp)) (mapconcat (lambda (x) (format "%c" x)) key "")) + ((and (pred symbolp) 'default) "c") + (_ "")))) + (evil-collection-define-key 'normal 'calendar-mode-map + (kbd key) 'org-calendar-goto-agenda)) + + ;; Similar to `org-calendar-to-agenda-key'. + (unless (eq org-agenda-diary-file 'diary-file) + (let ((key (pcase org-calendar-insert-diary-entry-key + ((and key (pred stringp)) key) + ((and key (pred vectorp)) (mapconcat (lambda (x) (format "%c" x)) key "")) + ;; NOTE Consistent behavior with `org-calendar-to-agenda-key' + ;; although it's not supported in Org officially. + ((and (pred symbolp) 'default) "i") + (_ "")))) + (evil-collection-define-key 'normal 'calendar-mode-map + (kbd key) 'org-agenda-diary-entry)))) + ;;;###autoload (defun evil-collection-calendar-setup () "Set up `evil' bindings for `calendar'." @@ -70,8 +99,9 @@ ;; goto "." 'calendar-goto-today + "o" 'calendar-other-month "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'. + "gD" 'calendar-other-month ;; diary "D" 'diary-view-other-diary-entries @@ -79,6 +109,10 @@ "m" 'diary-mark-entries "s" 'diary-show-all-entries + ;; appointment + "Aa" 'appt-add + "Ad" 'appt-delete + "u" 'calendar-unmark "x" 'calendar-mark-holidays @@ -87,6 +121,7 @@ "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. + "a" 'calendar-list-holidays "r" 'calendar-cursor-holidays ;; refresh @@ -99,7 +134,11 @@ ;; quit "q" 'calendar-exit "ZQ" 'evil-quit - "ZZ" 'calendar-exit)) + "ZZ" 'calendar-exit) + + (defvar evil-collection-calendar-want-org-bindings) + (when evil-collection-calendar-want-org-bindings + (evil-collection-calendar-setup-org-bindings))) (provide 'evil-collection-calendar) ;;; evil-collection-calendar.el ends here |
