* search for any two consecutive uppercase characters
@ 2009-08-12 22:25 Horacio Suarez
0 siblings, 0 replies; 10+ messages in thread
From: Horacio Suarez @ 2009-08-12 22:25 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 616 bytes --]
Hello all:
Is there a way to search for any two consecutive uppercase characters? In example "PÉREZ" or "GONZÁLEZ"
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".
Thankyou in advance.
--------------------
Horacio Suarez
_________________________________________________________________
Show them the way! Add maps and directions to your party invites.
http://www.microsoft.com/windows/windowslive/products/events.aspx
[-- Attachment #2: Type: text/html, Size: 792 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: search for any two consecutive uppercase characters
[not found] <mailman.4480.1250115925.2239.help-gnu-emacs@gnu.org>
@ 2009-08-12 22:38 ` Pascal J. Bourguignon
2009-08-12 23:11 ` A.Politz
2009-08-13 12:23 ` Colin S. Miller
0 siblings, 2 replies; 10+ messages in thread
From: Pascal J. Bourguignon @ 2009-08-12 22:38 UTC (permalink / raw)
To: help-gnu-emacs
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__
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: search for any two consecutive uppercase characters
2009-08-12 22:38 ` search for any two consecutive uppercase characters Pascal J. Bourguignon
@ 2009-08-12 23:11 ` A.Politz
2009-08-14 3:50 ` doitian
2009-08-13 12:23 ` Colin S. Miller
1 sibling, 1 reply; 10+ messages in thread
From: A.Politz @ 2009-08-12 23:11 UTC (permalink / raw)
To: help-gnu-emacs
On Aug 13, 12:38 am, p...@informatimago.com (Pascal J. Bourguignon)
wrote:
> There is no
> [:upper:] in emacs regular expressions.
That' actually not true, as described here
(info "(elisp)Char Classes")
-ap
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: search for any two consecutive uppercase characters
2009-08-12 22:38 ` search for any two consecutive uppercase characters Pascal J. Bourguignon
2009-08-12 23:11 ` A.Politz
@ 2009-08-13 12:23 ` Colin S. Miller
2009-08-13 13:09 ` Pascal J. Bourguignon
1 sibling, 1 reply; 10+ messages in thread
From: Colin S. Miller @ 2009-08-13 12:23 UTC (permalink / raw)
To: help-gnu-emacs
Pascal J. Bourguignon wrote:
> 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ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ]+\\>"
>
Isn't
C-u C-s (aka isearch-forward-regexp)
[A-ZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ]\{2,\}
better?
here \{2,\}
means two (or more) of the preceding expression.
HTH,
Colin S. Miller
--
Replace the obvious in my email address with the first three letters of the hostname to reply.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: search for any two consecutive uppercase characters
2009-08-13 12:23 ` Colin S. Miller
@ 2009-08-13 13:09 ` Pascal J. Bourguignon
2009-08-13 14:13 ` Horacio Suarez
[not found] ` <mailman.4515.1250173016.2239.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 10+ messages in thread
From: Pascal J. Bourguignon @ 2009-08-13 13:09 UTC (permalink / raw)
To: help-gnu-emacs
"Colin S. Miller" <no-spam-thank-you@csmiller.demon.co.uk> writes:
> Pascal J. Bourguignon wrote:
>> 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ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ]+\\>"
>>
> Isn't
> C-u C-s (aka isearch-forward-regexp)
> [A-ZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ]\{2,\}
> better?
FSVO "better".
> here \{2,\}
> means two (or more) of the preceding expression.
They don't mean the same.
My expression means: words containing only uppercase letters.
Your expression means: any occurence of two or more consecutive uppercase letters.
Is 0x42AB a word? (I'd say no, it's a number in C syntax for hexadecimal).
Is NeXTstep a word? (Yes, but it's not all uppercase).
--
__Pascal Bourguignon__
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: search for any two consecutive uppercase characters
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>
1 sibling, 1 reply; 10+ messages in thread
From: Horacio Suarez @ 2009-08-13 14:13 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 2158 bytes --]
Hello:
Thankyou very much for yours answers.
Please excuse my ignorance but I dont know exactly how tu use the code.
I paste it in my .emacs file. To use I type M-x "capitalize-uppercase-words"
then appears a mesage: "The mark is not set now, so there is no region".
What shoul I do?
Thanks again
--------------------
Horacio Suarez
> From: pjb@informatimago.com
> Date: Thu, 13 Aug 2009 15:09:31 +0200
> To: help-gnu-emacs@gnu.org
> Subject: Re: search for any two consecutive uppercase characters
>
> "Colin S. Miller" <no-spam-thank-you@csmiller.demon.co.uk> writes:
>
> > Pascal J. Bourguignon wrote:
> >> 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ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ]+\\>"
> >>
> > Isn't
> > C-u C-s (aka isearch-forward-regexp)
> > [A-ZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ]\{2,\}
> > better?
>
> FSVO "better".
>
> > here \{2,\}
> > means two (or more) of the preceding expression.
>
> They don't mean the same.
> My expression means: words containing only uppercase letters.
> Your expression means: any occurence of two or more consecutive uppercase letters.
>
> Is 0x42AB a word? (I'd say no, it's a number in C syntax for hexadecimal).
> Is NeXTstep a word? (Yes, but it's not all uppercase).
>
>
> --
> __Pascal Bourguignon__
_________________________________________________________________
With Windows Live, you can organize, edit, and share your photos.
http://www.microsoft.com/middleeast/windows/windowslive/products/photo-gallery-edit.aspx
[-- Attachment #2: Type: text/html, Size: 2727 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: search for any two consecutive uppercase characters
2009-08-13 14:13 ` Horacio Suarez
@ 2009-08-13 17:24 ` Peter Dyballa
0 siblings, 0 replies; 10+ messages in thread
From: Peter Dyballa @ 2009-08-13 17:24 UTC (permalink / raw)
To: Horacio Suarez; +Cc: help-gnu-emacs
Am 13.08.2009 um 16:13 schrieb Horacio Suarez:
> The mark is not set now, so there is no region
Mark the area in which you want to change the case of letters!
--
Greetings
Pete
Upgraded, adj.:
Didn't work the first time.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: search for any two consecutive uppercase characters
[not found] ` <mailman.4515.1250173016.2239.help-gnu-emacs@gnu.org>
@ 2009-08-13 21:54 ` Pascal J. Bourguignon
0 siblings, 0 replies; 10+ messages in thread
From: Pascal J. Bourguignon @ 2009-08-13 21:54 UTC (permalink / raw)
To: help-gnu-emacs
Horacio Suarez <horaciosuarez@hotmail.com> writes:
> Thankyou very much for yours answers.
>
> Please excuse my ignorance but I dont know exactly how tu use the code.
>
> I paste it in my .emacs file. To use I type M-x "capitalize-uppercase-words"
>
> then appears a mesage: "The mark is not set now, so there is no region".
>
> What shoul I do?
Depends on what you want. You could modify the command so that it can
work without a region selected, or you could select a region to be
processed by capitalize-uppercase-words.
--
__Pascal Bourguignon__
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: search for any two consecutive uppercase characters
2009-08-12 23:11 ` A.Politz
@ 2009-08-14 3:50 ` doitian
2009-08-15 12:01 ` Horacio Suarez
0 siblings, 1 reply; 10+ messages in thread
From: doitian @ 2009-08-14 3:50 UTC (permalink / raw)
To: help-gnu-emacs
On Aug 13, 7:11 am, "A.Politz" <poli...@googlemail.com> wrote:
> On Aug 13, 12:38 am, p...@informatimago.com (Pascal J. Bourguignon)
> wrote:
>
> > There is no
> > [:upper:] in emacs regular expressions.
>
> That' actually not true, as described here
> (info "(elisp)Char Classes")
>
> -ap
Yes, [:upper:] is available. A common error is using it directly.
Indeed, it must be put in a char class like [[:upper:]].
The problem can be solved using query-replace-regexp
Search Pattern: \<[[:upper:]]\{2,\}\>
Replace: \,(capitalize \&)
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: search for any two consecutive uppercase characters
2009-08-14 3:50 ` doitian
@ 2009-08-15 12:01 ` Horacio Suarez
0 siblings, 0 replies; 10+ messages in thread
From: Horacio Suarez @ 2009-08-15 12:01 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1028 bytes --]
Thankyou very much.
--------------------
Horacio Suarez
> From: doit.ian@gmail.com
> Date: Thu, 13 Aug 2009 20:50:08 -0700
> To: help-gnu-emacs@gnu.org
> Subject: Re: search for any two consecutive uppercase characters
>
> On Aug 13, 7:11 am, "A.Politz" <poli...@googlemail.com> wrote:
> > On Aug 13, 12:38 am, p...@informatimago.com (Pascal J. Bourguignon)
> > wrote:
> >
> > > There is no
> > > [:upper:] in emacs regular expressions.
> >
> > That' actually not true, as described here
> > (info "(elisp)Char Classes")
> >
> > -ap
>
> Yes, [:upper:] is available. A common error is using it directly.
> Indeed, it must be put in a char class like [[:upper:]].
>
> The problem can be solved using query-replace-regexp
>
> Search Pattern: \<[[:upper:]]\{2,\}\>
> Replace: \,(capitalize \&)
_________________________________________________________________
Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.
http://www.microsoft.com/windows/windowslive/products/photos.aspx
[-- Attachment #2: Type: text/html, Size: 1365 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2009-08-15 12:01 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.4480.1250115925.2239.help-gnu-emacs@gnu.org>
2009-08-12 22:38 ` search for any two consecutive uppercase characters Pascal J. Bourguignon
2009-08-12 23:11 ` 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
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).