Created
August 9, 2010 22:27
-
-
Save juergenhoetzel/516242 to your computer and use it in GitHub Desktop.
Fix mistyped upcase characters in Emacs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; hanging-shift-mode.el --- | |
;; Author: Jürgen Hötzel <juergen@archlinux.org> | |
;; http://stackoverflow.com/questions/3431911/emacs-should-set-the-second-character-of-a-word-in-lower-case | |
(require 'cl) | |
(defun hanging-shift-sanitise-word () | |
(interactive) | |
(let ((word (current-word t t))) | |
;; check if the word entered so far is capitalized | |
(if (and word (string= (capitalize word) word)) | |
(insert (downcase last-command-event)) | |
(insert last-command-event)))) | |
(defvar hanging-shift-mode-keymap (make-sparse-keymap) | |
"The keymap of hanging-shift-mode.") | |
(dotimes (c (- ?Z ?A)) | |
(define-key hanging-shift-mode-keymap | |
(char-to-string (+ ?A c)) 'hanging-shift-sanitise-word)) | |
(define-minor-mode hanging-shift-mode | |
"Be lazy about shift key while you type" | |
;; The initial value. | |
nil | |
;; The indicator for the mode line. | |
" hanging-shift" | |
hanging-shift-mode-keymap) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment