diff options
| author | tslil clingman <> | 2019-09-11 19:18:14 -0400 |
|---|---|---|
| committer | tslil clingman <> | 2019-09-11 19:18:14 -0400 |
| commit | ac1a4884d03fc0495c773500d8a13f84b695fa43 (patch) | |
| tree | 29e5ec49e0ce957d80d8f11a155b47840c74f488 /emacs/scripts/caps-lock-mode.el | |
Init
Diffstat (limited to 'emacs/scripts/caps-lock-mode.el')
| -rw-r--r-- | emacs/scripts/caps-lock-mode.el | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/emacs/scripts/caps-lock-mode.el b/emacs/scripts/caps-lock-mode.el new file mode 100644 index 0000000..c80883a --- /dev/null +++ b/emacs/scripts/caps-lock-mode.el @@ -0,0 +1,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) |
