[Top][All Lists]

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

Re: window-specific Caps Lock

From: Andreas Politz
Subject: Re: window-specific Caps Lock
Date: Sun, 08 Nov 2009 20:21:16 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Girish Kulkarni <address@hidden> 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?
> Thanks,
> Girish.

How about inverting the meaning of shift ? In case you need other
non-ascii characters you'll have to extend this.

(defvar inverse-case-mode-map
  (let ((km (make-sparse-keymap))
        (ch ?A))
    (while (<= ch ?z)
      (define-key km (vector ch) 'self-insert-inverse-case-command)
      (setq ch (1+ ch))
      (if (eq ch ?Z)
          (setq ch ?a)))

(defun self-insert-inverse-case-command (arg)
  (interactive "p")
  (let ((last-command-event
         (+ last-command-event
            (if (equal (downcase (string last-command-event))
                       (string last-command-event))
                (- ?A ?a)
              (- ?a ?A)))))
    (call-interactively 'self-insert-command)))

(define-minor-mode inverse-case-mode
  nil nil " InvCase")


(add-hook 'fortran-mode #'(lambda nil (inverse-case-mode 1)))
...or whatever.


reply via email to

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