* window-specific Caps Lock
@ 2009-11-08 8:41 Girish Kulkarni
2009-11-08 11:01 ` Pascal J. Bourguignon
2009-11-08 19:21 ` Andreas Politz
0 siblings, 2 replies; 4+ messages in thread
From: Girish Kulkarni @ 2009-11-08 8:41 UTC (permalink / raw)
To: help-gnu-emacs
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: window-specific Caps Lock
2009-11-08 8:41 window-specific Caps Lock Girish Kulkarni
@ 2009-11-08 11:01 ` Pascal J. Bourguignon
2009-11-13 11:29 ` Girish Kulkarni
2009-11-08 19:21 ` Andreas Politz
1 sibling, 1 reply; 4+ messages in thread
From: Pascal J. Bourguignon @ 2009-11-08 11:01 UTC (permalink / raw)
To: help-gnu-emacs
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__
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: window-specific Caps Lock
2009-11-08 8:41 window-specific Caps Lock Girish Kulkarni
2009-11-08 11:01 ` Pascal J. Bourguignon
@ 2009-11-08 19:21 ` Andreas Politz
1 sibling, 0 replies; 4+ messages in thread
From: Andreas Politz @ 2009-11-08 19:21 UTC (permalink / raw)
To: help-gnu-emacs
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?
>
> 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)))
km))
(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.
-ap
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: window-specific Caps Lock
2009-11-08 11:01 ` Pascal J. Bourguignon
@ 2009-11-13 11:29 ` Girish Kulkarni
0 siblings, 0 replies; 4+ messages in thread
From: Girish Kulkarni @ 2009-11-13 11:29 UTC (permalink / raw)
To: help-gnu-emacs
On Nov 8, 4:01 pm, p...@informatimago.com (Pascal J. Bourguignon)
wrote:
> Use caps-mode:
Thanks for the help!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-11-13 11:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-08 8:41 window-specific Caps Lock Girish Kulkarni
2009-11-08 11:01 ` Pascal J. Bourguignon
2009-11-13 11:29 ` Girish Kulkarni
2009-11-08 19:21 ` Andreas Politz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).