From: Nikolaj Schumacher <me@nschum.de>
To: Andreas Politz <politza@fh-trier.de>
Cc: help-gnu-emacs@gnu.org
Subject: Re: elisp exercise: toggle-letter-case
Date: Sat, 18 Oct 2008 03:06:08 +0200 [thread overview]
Message-ID: <m2hc7abtkv.fsf@nschum.de> (raw)
In-Reply-To: <1224286525.260548@arno.fh-trier.de> (Andreas Politz's message of "Sat\, 18 Oct 2008 01\:29\:36 +0200")
Andreas Politz <politza@fh-trier.de> wrote:
> Giving the command a state makes it so much easier, because you
> don't have to look at the text at all.
I think looking at the text is actually less work. It's only three
lines of code.
(defun toggle-region-case (&optional beg end)
(interactive (and transient-mark-mode mark-active
(list (region-beginning)
(region-end))))
(let ((pt (point))
case-fold-search
deactivate-mark)
(if beg
(goto-char beg)
(forward-word)
(setq end (point))
(backward-word))
(cond
((looking-at "[[:upper:]][[:upper:]]") (downcase-region (point) end))
((looking-at "[[:upper:]]") (upcase-region (point) end))
(t (upcase-initials-region (point) end)))
(goto-char pt)))
regards,
Nikolaj Schumacher
next prev parent reply other threads:[~2008-10-18 1:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-17 21:02 elisp exercise: toggle-letter-case Xah
2008-10-17 23:29 ` Andreas Politz
2008-10-18 1:06 ` Nikolaj Schumacher [this message]
[not found] ` <mailman.1411.1224291972.25473.help-gnu-emacs@gnu.org>
2008-10-18 18:53 ` Xah
2008-10-18 20:47 ` Nikolaj Schumacher
2008-10-18 20:50 ` Xah
2008-10-19 15:26 ` Nikolaj Schumacher
[not found] ` <mailman.1506.1224429976.25473.help-gnu-emacs@gnu.org>
2008-10-19 17:46 ` Xah
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2hc7abtkv.fsf@nschum.de \
--to=me@nschum.de \
--cc=help-gnu-emacs@gnu.org \
--cc=politza@fh-trier.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.