blob: 9e9052bd8dea45e7072407638c325a3e1add6a7b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
;;; -*- lexical-binding: t -*-
(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)
|