Skip to content

Instantly share code, notes, and snippets.

@juergenhoetzel
Created August 9, 2010 22:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juergenhoetzel/516242 to your computer and use it in GitHub Desktop.
Save juergenhoetzel/516242 to your computer and use it in GitHub Desktop.
Fix mistyped upcase characters in Emacs
;;; 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