* cool stuff with caps-mode.el
@ 2013-10-15 17:32 Emanuel Berg
2013-10-15 17:47 ` Joost Kremers
0 siblings, 1 reply; 3+ messages in thread
From: Emanuel Berg @ 2013-10-15 17:32 UTC (permalink / raw)
To: help-gnu-emacs
I made some changes to the caps-mode.el.
I think the caps lock key is so big and close, it is a
*waste* to use it for caps lock (which I almost never
use).
For acronyms, I use abbrev, so I just type them in
lowercase.
But sometimes, for example in C code, you need (want)
to write constants in all caps (as you are used to
do/read that). Then, the caps key could be
useful. That's why I think caps-mode is *great* because
then you could do "virtual caps" on a per-buffer basis
(if you change buffer, or switch from Emacs to the
shell, you don't have to 1) *remember*, and 2) actually
*do* disable the caps lock).
Anyway, the changes I made:
1. A wrapper to get away with that annoying
confirmation message (that is especially annoying if
you are in the metabuffer because then for a second it
hides what you are typing).
But, even cooler:
2. When you are done typing your C constant, or
whatever, it automatically changes back to
lowercase. Only 1-9, A-Z, a-z, and the underscore (_)
will keep in the the mode.
But in some rare, rare cases, perhaps you do C and you
make function calls which take tons of arguments, all
constants. Then you don't want to revert on "," (for
example). So I made a variable and a function to
disable the "auto revert" change.
(Both that and the enable of the minor mode itself must
be shortcutted, of course, to be useful. I left that
out as all people like their own keys.)
Let me know what you think. If you like the idea, feel
free to implement it any way you like (of course). If
not, I'm happy to have this lass all by myself :)
(defvar *case-auto-revert* t)
(setq *case-auto-revert* t)
(defun char-alphanum-or-underscore (c)
(or (eq c ?_)
(and (>= c ?1) (<= c ?9))
(and (>= c ?A) (<= c ?Z))
(and (>= c ?a) (<= c ?z)) ))
(defun caps-mode-self-insert-command (&optional n)
(interactive "p")
(let ((the-char last-command-char))
(if (and *case-auto-revert*
(not (char-alphanum-or-underscore the-char)) )
(caps-mode 0))
(insert-char (upcase the-char) n) ))
(defun toggle-caps-mode-auto-revert ()
(interactive)
(setq *case-auto-revert* (not *case-auto-revert*) ))
(defun toggle-caps-mode ()
(interactive)
(if caps-mode (caps-mode 0) (caps-mode)) )
(defvar caps-mode-map
(let ((map (make-keymap)))
(substitute-key-definition 'self-insert-command
'caps-mode-self-insert-command
map global-map)
map) )
(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."
:init-value nil
:lighter " Caps")
--
Emanuel Berg, programmer-for-rent. CV, projects, etc at uXu
underground experts united: http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: cool stuff with caps-mode.el
2013-10-15 17:32 cool stuff with caps-mode.el Emanuel Berg
@ 2013-10-15 17:47 ` Joost Kremers
2013-10-15 17:53 ` Emanuel Berg
0 siblings, 1 reply; 3+ messages in thread
From: Joost Kremers @ 2013-10-15 17:47 UTC (permalink / raw)
To: help-gnu-emacs
Emanuel Berg wrote:
> But sometimes, for example in C code, you need (want)
> to write constants in all caps (as you are used to
> do/read that).
I don't write C but do run into the need to write a word in uppercase
from time to time. What I usually do is write it in lower case and then
hit `M-- M-u'. Your mode seems a bit overkill to me. :-)
BTW, `M-- M-c` and `M-- M-l` also come in handy every now and then.
--
Joost Kremers joostkremers@fastmail.fm
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: cool stuff with caps-mode.el
2013-10-15 17:47 ` Joost Kremers
@ 2013-10-15 17:53 ` Emanuel Berg
0 siblings, 0 replies; 3+ messages in thread
From: Emanuel Berg @ 2013-10-15 17:53 UTC (permalink / raw)
To: help-gnu-emacs
Joost Kremers <joost.m.kremers@gmail.com> writes:
> I don't write C but do run into the need to write a
> word in uppercase from time to time. What I usually do
> is write it in lower case and then hit `M-- M-u'. Your
> mode seems a bit overkill to me. :-)
I take that as a compliment!
But - it is not "my" mode, I just made those
changes. The author of the "real" mode is active on this
list, I think.
But I appreciate you told me you had had the same
situation.
--
Emanuel Berg, programmer-for-rent. CV, projects, etc at uXu
underground experts united: http://user.it.uu.se/~embe8573
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-10-15 17:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-15 17:32 cool stuff with caps-mode.el Emanuel Berg
2013-10-15 17:47 ` Joost Kremers
2013-10-15 17:53 ` Emanuel Berg
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.