From ac1a4884d03fc0495c773500d8a13f84b695fa43 Mon Sep 17 00:00:00 2001 From: tslil clingman <> Date: Wed, 11 Sep 2019 19:18:14 -0400 Subject: Init --- emacs/scripts/caps-lock-mode.el | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 emacs/scripts/caps-lock-mode.el (limited to 'emacs/scripts/caps-lock-mode.el') 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) -- cgit v1.2.3