diff options
author | Leon Rische <leon.rische@me.com> | 2020-07-04 03:44:36 +0200 |
---|---|---|
committer | Leon Rische <leon.rische@me.com> | 2020-07-04 03:44:36 +0200 |
commit | 92b6b8987f9b266304702a50030a456016eb0b17 (patch) | |
tree | 320bd7162796fce67686f6a7dc8ee3fb31b94947 /org-fc-keymap-hint.el | |
parent | 71c066a5d9aa70a1160ad7f10e64ac4599ba427e (diff) |
Move files out of contrib/ folder
Diffstat (limited to 'org-fc-keymap-hint.el')
-rw-r--r-- | org-fc-keymap-hint.el | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/org-fc-keymap-hint.el b/org-fc-keymap-hint.el new file mode 100644 index 0000000..5cb8e7e --- /dev/null +++ b/org-fc-keymap-hint.el @@ -0,0 +1,70 @@ +;;; org-fc-keymap-hint.el --- Key-binding hints for org-fc -*- lexical-binding: t; -*- + +;; Copyright (C) 2020 Leon Rische + +;; Author: Leon Rische <emacs@leonrische.me> +;; Url: https://www.leonrische.me/pages/org_flashcards.html +;; Package-requires: ((emacs "26.3") (org "9.3")) +;; Version: 0.0.1 + +;; 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: +;; +;; Shows a message with a list of key bindings during review, this +;; replicates the look & feel of previous hydra-based review process. +;; +;;; Code: + +(require 'org-fc) +(require 'edmacro) + +(defun org-fc-keymap-hint--symbol-name (name) + "Remove org-fc- prefixes from symbol NAME." + (setq name (symbol-name name)) + (cond + ((string-prefix-p "org-fc-review-" name) + (substring name 14)) + ((string-prefix-p "org-fc-" name) + (substring name 7)) + (t name))) + +(defun org-fc-keymap-hint (keymap) + "Generate key-binding hints string for KEYMAP." + (mapconcat + (lambda (key) + (if (symbolp (cdr key)) + (format + "[%s] %s" + (edmacro-format-keys (list (car key))) + (if (symbolp (cdr key)) + (org-fc-keymap-hint--symbol-name (cdr key)) + (cdr key))))) + (reverse (cdr keymap)) + " ")) + +(add-hook 'org-fc-review-flip-mode-hook + (lambda () (message (org-fc-keymap-hint org-fc-review-flip-mode-map)))) + +(add-hook 'org-fc-review-rate-mode-hook + (lambda () (message (org-fc-keymap-hint org-fc-review-rate-mode-map)))) + +;; Overwrite message when review ends +(add-hook 'org-fc-after-review-hook (lambda () (message ""))) + +;;; Footer + +(provide 'org-fc-keymap-hint) + +;;; org-fc.el ends here |