Add no-easy-keys.

This commit is contained in:
Ivan Malison 2013-09-25 13:09:05 -07:00
parent 3ca39d6424
commit da4ae81c4b
4 changed files with 105 additions and 24 deletions

View File

@ -0,0 +1,18 @@
;;; no-easy-keys-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
;;;### (autoloads nil nil ("no-easy-keys-pkg.el" "no-easy-keys.el")
;;;;;; (21059 16366 939830))
;;;***
(provide 'no-easy-keys-autoloads)
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; no-easy-keys-autoloads.el ends here

View File

@ -0,0 +1 @@
(define-package "no-easy-keys" "1.0.2" "Learn the proper Emacs movement keys" (quote nil))

View File

@ -0,0 +1,77 @@
;;; no-easy-keys.el --- Learn the proper Emacs movement keys
;; Copyright (C) 2009-2012 Dan Amlund Thomsen
;; Author: Dan Amlund Thomsen <dan@danamlund.dk>
;; URL: http://danamlund.dk/emacs/no-easy-keys.html
;; Version: 1.0.2
;; Created: 2009-12-12
;; By: Dan Amlund Thomsen
;; Keywords: training, pinky
;;; Commentary:
;; This mode teaches you to use the proper Emacs movement keys in a
;; rather harsh manner.
;; No-easy-keys disables arrow, end, home and delete keys, as well as
;; their control and meta prefixes. When using any of these keys, you
;; instead get a message informing you of the proper Emacs shortcut
;; you should use instead (e.g. pressing down informs you to use C-n).
;; The easy keys are not disabled in the minibuffer. The minibuffer
;; has different proper keys replacements than regular buffers and
;; depending on various extensions such as icicles, ido, etc.
;; To install, save no-easy-keys.el in your load path and add the
;; following to your .emacs file:
;;
;; (require 'no-easy-keys)
;; (no-easy-keys 1)
;; You can toggle no-easy-keys using 'M-x no-easy-keys'.
;;; Code:
(defvar no-easy-keys-minor-mode-map (make-keymap)
"no-easy-keys-minor-mode keymap.")
(let ((f (lambda (m)
`(lambda () (interactive)
(message (concat "No! use " ,m " instead."))))))
(dolist (l '(("<left>" . "C-b") ("<right>" . "C-f") ("<up>" . "C-p")
("<down>" . "C-n")
("<C-left>" . "M-b") ("<C-right>" . "M-f") ("<C-up>" . "M-{")
("<C-down>" . "M-}")
("<M-left>" . "M-b") ("<M-right>" . "M-f") ("<M-up>" . "M-{")
("<M-down>" . "M-}")
("<delete>" . "C-d") ("<C-delete>" . "M-d")
("<M-delete>" . "M-d") ("<next>" . "C-v") ("<C-next>" . "M-x <")
("<prior>" . "M-v") ("<C-prior>" . "M-x >")
("<home>" . "C-a") ("<C-home>" . "M->")
("<C-home>" . "M-<") ("<end>" . "C-e") ("<C-end>" . "M->")))
(define-key no-easy-keys-minor-mode-map
(read-kbd-macro (car l)) (funcall f (cdr l)))))
(define-minor-mode no-easy-keys-minor-mode
"A minor mode that disables the arrow-keys, pg-up/down, delete
and backspace.
Use 'M-x no-easy-keys' to toggle this mode in all buffers except
the minibuffer.
Add (no-easy-keys 1) to your .emacs to enable no-easy-keys by
default."
nil nil 'no-easy-keys-minor-mode-map)
(defun no-easy-keys-hook ()
(interactive)
(unless (minibufferp)
(no-easy-keys-minor-mode 1)))
(define-globalized-minor-mode no-easy-keys
no-easy-keys-minor-mode no-easy-keys-hook)
(provide 'no-easy-keys)
;;; no-easy-keys.el ends here

33
init.el
View File

@ -52,6 +52,10 @@
(put 'upcase-region 'disabled nil)
(put 'downcase-region 'disabled nil)
;; Don't allow arrow keys
(require 'no-easy-keys)
(no-easy-keys 1)
;; Change the behavior of M-<arrow> so that it stops on underscores.
(defun change-major-mode-hook () (modify-syntax-entry ?_ "_"))
(setq c-subword-mode t)
@ -122,10 +126,10 @@
;; =============================================================================
;; Fast cursor movement in vertical direction with Meta.
(global-set-key (kbd "M-<down>") (lambda () (interactive) (next-line 5)))
(global-set-key (kbd "M-<up>") (lambda () (interactive) (previous-line 5)))
(global-set-key (kbd "ESC <down>") (lambda () (interactive) (next-line 5)))
(global-set-key (kbd "ESC <up>") (lambda () (interactive) (previous-line 5)))
(global-set-key (kbd "M-n") (lambda () (interactive) (next-line 5)))
(global-set-key (kbd "M-p") (lambda () (interactive) (previous-line 5)))
(global-set-key (kbd "ESC n") (lambda () (interactive) (next-line 5)))
(global-set-key (kbd "ESC p") (lambda () (interactive) (previous-line 5)))
;; Macros
(fset 'ipdb "import ipdb; ipdb.set_trace()")
@ -135,8 +139,7 @@
(global-set-key "\C-xw" 'whitespace-mode)
(global-set-key "\C-cw" 'tmux-copy)
(global-set-key "\C-x\C-r" (lambda () (interactive) (revert-buffer t t)))
(global-set-key "\C-x\C-i" 'increase-left-margin)
(global-set-key "\C-x\C-d" 'decrease-left-margin)
(global-set-key "\M-g" 'goto-line)
(global-set-key "\C-c\C-c" 'comment-region)
(global-set-key "\C-ct" 'testify-run-test)
(global-set-key "\C-c\C-o" 'testify-run-case)
@ -240,21 +243,3 @@
;; =============================================================================
;; Customize
;; =============================================================================
<<<<<<< HEAD
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(ansi-color-names-vector ["black" "red" "green" "yellow" "blue" "magenta" "cyan" "yellow"])
'(ansi-term-color-vector ["#3f3f3f" "#cc9393" "#7f9f7f" "#f0dfaf" "#8cd0d3" "#dc8cc3" "#93e0e3" "#dcdccc"])
'(background-color nil)
'(background-mode dark)
'(cursor-color nil)
'(custom-safe-themes (quote ("36a309985a0f9ed1a0c3a69625802f87dee940767c9e200b89cdebdb737e5b29" "fc5fcb6f1f1c1bc01305694c59a1a861b008c534cae8d0e48e4d5e81ad718bc6" default)))
'(fci-rule-color "#383838")
'(foreground-color nil))
=======
>>>>>>> origin/yelp