From b967945f9bbcc9d08dfdf9c0284302273b1fd2f2 Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Fri, 23 Feb 2018 17:51:52 +0100 Subject: [PATCH] Add calc --- evil-collection-calc.el | 172 ++++++++++++++++++++++++++++++++++++++++ evil-collection.el | 1 + 2 files changed, 173 insertions(+) create mode 100644 evil-collection-calc.el diff --git a/evil-collection-calc.el b/evil-collection-calc.el new file mode 100644 index 0000000..25479be --- /dev/null +++ b/evil-collection-calc.el @@ -0,0 +1,172 @@ +;;; evil-collection-calc.el --- Evil bindings for calc -*- lexical-binding: t -*- + +;; Copyright (C) 2018 Pierre Neidhardt + +;; Author: Pierre Neidhardt +;; Maintainer: James Nguyen , Pierre Neidhardt +;; URL: https://github.com/jojojames/evil-collection +;; Version: 0.0.1 +;; Package-Requires: ((emacs "25.1")) +;; Keywords: evil, calc, 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 . + +;;; Commentary: +;; Evil bindings for calc. + +;;; Code: +(require 'evil) +(require 'calc) + +(defun evil-collection-calc-ext-setup () + "Set up `evil' bindings for `calc'. +Since calc bindings are set on-demand when calc-ext is load, we +need to call it in its load hook." + (evil-define-key 'normal calc-mode-map + "0" 'calcDigit-start + "1" 'calcDigit-start + "2" 'calcDigit-start + "3" 'calcDigit-start + "4" 'calcDigit-start + "5" 'calcDigit-start + "6" 'calcDigit-start + "7" 'calcDigit-start + "8" 'calcDigit-start + "9" 'calcDigit-start + + (kbd "") 'calc-roll-down + (kbd "S-") 'calc-over + (kbd "") 'calc-enter + (kbd "SPC") 'calc-enter + + (kbd "C-x C-t") 'calc-transpose-lines + (kbd "C-M-d") 'calc-pop-above + (kbd "C-M-i") 'calc-roll-up + (kbd "M-RET") 'calc-last-args + (kbd "C-M-w") 'kill-ring-save + (kbd "M-%") 'calc-percent + (kbd "M-k") 'calc-copy-as-kill + (kbd "M-w") 'calc-copy-region-as-kill + (kbd "M-DEL") 'calc-pop-above + (kbd "M-m t") 'calc-total-algebraic-mode + (kbd "") 'calc-pop + (kbd "") 'calc-yank + "x" 'calc-pop ; was "C-d". TODO: Conflicts with calc-execute-extended-command. + "d" 'calc-kill ; was "C-k" + "u" 'calc-undo ; was "U" + "X" 'calc-call-last-kbd-macro ; "@" is already used. + "pp" 'calc-yank ; was "C-y" + "pP" 'calc-copy-to-buffer ; was "y" + + (kbd "C-p") 'calc-precision ; was "p" + + "?" 'calc-help + ;; "h" 'calc-help-prefix ; TODO: Rebind? + "i" 'calc-info + + "\"" 'calc-auto-algebraic-entry + "$" 'calc-auto-algebraic-entry ; TODO: No need for this one? + "'" 'calc-algebraic-entry + + "!" 'calc-factorial + "#" 'calcDigit-start + "%" 'calc-mod + "&" 'calc-inv + "(" 'calc-begin-complex + ")" 'calc-end-complex + "*" 'calc-times + "+" 'calc-plus + "," 'calc-comma + "-" 'calc-minus + "." 'calcDigit-start + "/" 'calc-divide + ":" 'calc-fdiv + ";" 'calc-semi ; TODO: Shall we really override `evil-ex'? + "<" 'calc-scroll-left + "=" 'calc-evaluate + ">" 'calc-scroll-right + "@" 'calcDigit-start + "A" 'calc-abs + "B" 'calc-log + "C" 'calc-cos + ;; "D" 'calc-redo ; TODO: What's the purpose of this? Bind to C-r? + "E" 'calc-exp + "F" 'calc-floor + "G" 'calc-argument + "H" 'calc-hyperbolic + "I" 'calc-inverse + "J" 'calc-conj + "K" 'calc-keep-args + "L" 'calc-ln + "M" 'calc-more-recursion-depth + "N" 'calc-eval-num + "O" 'calc-option + "P" 'calc-pi + "Q" 'calc-sqrt + "R" 'calc-round + "S" 'calc-sin + "T" 'calc-tan + "[" 'calc-begin-vector + "]" 'calc-end-vector + "\\" 'calc-idiv + "^" 'calc-power + "_" 'calcDigit-start + "`" 'calc-edit + "e" 'calcDigit-start + "n" 'calc-change-sign + "o" 'calc-realign + "w" 'calc-why + "x" 'calc-execute-extended-command ; TODO: Conflicts with calc-pop. + "|" 'calc-concat + "{" 'calc-scroll-down ; TODO: Not necessary? + "}" 'calc-scroll-up ; TODO: Not necessary? + "~" 'calc-num-prefix + + "V" (lookup-key calc-mode-map (kbd "V")) + "Y" (lookup-key calc-mode-map (kbd "Y")) + "Z" (lookup-key calc-mode-map (kbd "Z")) + "a" (lookup-key calc-mode-map (kbd "a")) + "b" (lookup-key calc-mode-map (kbd "b")) + "c" (lookup-key calc-mode-map (kbd "c")) + "D" (lookup-key calc-mode-map (kbd "d")) + "f" (lookup-key calc-mode-map (kbd "f")) + "g" (lookup-key calc-mode-map (kbd "g")) + "zj" (lookup-key calc-mode-map (kbd "j")) + "zk" (lookup-key calc-mode-map (kbd "k")) + "zl" (lookup-key calc-mode-map (kbd "l")) + "m" (lookup-key calc-mode-map (kbd "m")) + "r" (lookup-key calc-mode-map (kbd "r")) + "s" (lookup-key calc-mode-map (kbd "s")) + "t" (lookup-key calc-mode-map (kbd "t")) + "U" (lookup-key calc-mode-map (kbd "u")) + "v" (lookup-key calc-mode-map (kbd "v")) + "zz" (lookup-key calc-mode-map (kbd "z")) + + ;; quit + ;; "ZQ" 'quit-window ; TODO: Rebind "Z"? + ;; "ZZ" 'quit-window ; TODO: Rebind "Z"? + "q" 'calc-quit) + + (evil-define-key 'visual calc-mode-map + "d" 'calc-kill-region)) + +(defun evil-collection-calc-setup () + "Set up `evil' bindings for `calc'." + (evil-collection-inhibit-insert-state calc-mode-map) + (evil-set-initial-state 'calc-mode 'normal) + (evil-collection-calc-ext-setup) + (add-hook 'calc-ext-load-hook 'evil-collection-calc-ext-setup)) + +(provide 'evil-collection-calc) +;;; evil-collection-calc.el ends here diff --git a/evil-collection.el b/evil-collection.el index bd58693..a629e4a 100644 --- a/evil-collection.el +++ b/evil-collection.el @@ -65,6 +65,7 @@ or evil-collection.") avy bookmark (buff-menu "buff-menu") + calc calendar cider cmake-mode