blob: c80883ad20eb2c91284488a7fc68577c19418008 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
(defvar caps-lock-mode-map
(let ((map (make-sparse-keymap)))
(define-key map [remap self-insert-command] 'upcased-self-insert)
map))
(define-minor-mode caps-lock-mode
"Caps lock minor mode."
nil " CLK" caps-lock-mode-map)
(defun upcased-self-insert (arg)
"Insert an uppercase version of the input, unless in a comment or string"
(interactive "p")
(let* ((syn (syntax-ppss))
(comment-or-string (or (nth 4 syn) (nth 3 syn)))
(last-command-event (if (and (not comment-or-string)
(characterp last-command-event))
(upcase last-command-event)
last-command-event)))
(self-insert-command arg)))
(provide 'caps-lock-mode)
|