From: pjb@informatimago.com (Pascal J. Bourguignon)
To: help-gnu-emacs@gnu.org
Subject: Re: search for any two consecutive uppercase characters
Date: Thu, 13 Aug 2009 00:38:26 +0200 [thread overview]
Message-ID: <87fxbw3bfh.fsf@galatea.local> (raw)
In-Reply-To: mailman.4480.1250115925.2239.help-gnu-emacs@gnu.org
Horacio Suarez <horaciosuarez@hotmail.com> writes:
> Hello all:
>
> Is there a way to search for any two consecutive uppercase characters? In example "PÉREZ" or
> "GONZÁLEZ"
Yes, this is difficult, because of the accented letters. There is no
[:upper:] in emacs regular expressions. It might be possible to build
a syntax table or something to identify uppercase letters including
accented ones, but AFAIK, there's nothing built in. The simpliest
would be to prepare a regular expression explicitely listing all the
characters you'd want, something like:
"\\<[A-ZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ]+\\>"
but in all generality, you'd miss a lot of other capital letters.
> I was looking in the manuals but I didn´t find it.
>
> I want to make a macro that looks for a word all uppercase, go to the beggining of that word and
> Capitalize it. Unsing the words in the example: "Pérez" or "González".
That's easier to do. Just beware of the triple negation ;-)
(require 'cl)
(defun capitalize-uppercase-words (start end)
(interactive "r")
(goto-char start)
(while (re-search-forward "\\<\\sw*\\>" end t)
(let ((word (match-string 0))
(start (match-beginning 0))
(end (match-end 0)))
(unless (some (lambda (ch) (char/= ch (upcase ch))) word)
(delete-region start end)
(insert (capitalize word))))))
--
__Pascal Bourguignon__
next parent reply other threads:[~2009-08-12 22:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.4480.1250115925.2239.help-gnu-emacs@gnu.org>
2009-08-12 22:38 ` Pascal J. Bourguignon [this message]
2009-08-12 23:11 ` search for any two consecutive uppercase characters A.Politz
2009-08-14 3:50 ` doitian
2009-08-15 12:01 ` Horacio Suarez
2009-08-13 12:23 ` Colin S. Miller
2009-08-13 13:09 ` Pascal J. Bourguignon
2009-08-13 14:13 ` Horacio Suarez
2009-08-13 17:24 ` Peter Dyballa
[not found] ` <mailman.4515.1250173016.2239.help-gnu-emacs@gnu.org>
2009-08-13 21:54 ` Pascal J. Bourguignon
2009-08-12 22:25 Horacio Suarez
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=87fxbw3bfh.fsf@galatea.local \
--to=pjb@informatimago.com \
--cc=help-gnu-emacs@gnu.org \
/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.