[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: search for any two consecutive uppercase characters
From: |
Pascal J. Bourguignon |
Subject: |
Re: search for any two consecutive uppercase characters |
Date: |
Thu, 13 Aug 2009 00:38:26 +0200 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/22.3 (darwin) |
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__