help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: window-specific Caps Lock


From: Pascal J. Bourguignon
Subject: Re: window-specific Caps Lock
Date: Sun, 08 Nov 2009 12:01:39 +0100
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.3 (darwin)

Girish Kulkarni <geeree@gmail.com> writes:

> Hi,
>
> I spend much time programming in Fortran 90 on my system, which is
> Debian 5.0 with GNOME.  I type the code in GNU Emacs and I prefer
> typing Fortran 90 ALL CAPS.
>
> This usually means that I need to toggle the `Caps Lock' switch on my
> keyboard every time I switch from the Emacs window to the terminal
> (which for me is Xterm).
>
> Is there a way I can set things up so that while I'm typing Fortran
> 90, text will automatically be entered ALL CAPS in the Emacs buffer,
> but not in any other windows?  Maybe by telling Emacs?

Use caps-mode:

(defun caps-mode-self-insert-command (&optional n)
  "Like `self-insert-command', but uppercase the the typed character."
  (interactive "p")
  (insert-char (upcase last-command-char) n))

(defvar caps-mode-map nil)

(when (fboundp 'define-minor-mode)
  (define-minor-mode caps-mode
      "Toggle caps mode.
With no argument, this command toggles the mode.
Non-null prefix argument turns on the mode.
Null prefix argument turns off the mode.

When caps mode is enabled, all letters are inserted in their
capitalized form."
    :init-value nil
    :lighter " Caps"
    (setq caps-mode-map
          (let ((map (make-sparse-keymap)))
            (substitute-key-definition 'self-insert-command
                                       'caps-mode-self-insert-command
                                       map global-map)
            map))
    (if caps-mode
        (add-to-list 'minor-mode-map-alist (cons 'caps-mode caps-mode-map))
        (setq minor-mode-map-alist
              (delete (assoc 'caps-mode minor-mode-map-alist)
                      minor-mode-map-alist)))))


-- 
__Pascal Bourguignon__


reply via email to

[Prev in Thread] Current Thread [Next in Thread]