help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with upcasing words first char


From: Harry Putnam
Subject: Re: Help with upcasing words first char
Date: Tue, 25 Aug 2009 10:34:21 -0500
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.96 (gnu/linux)

pjb@informatimago.com (Pascal J. Bourguignon) writes:

> Harry Putnam <reader@newsguy.com> writes:
>
>> Harry Putnam <reader@newsguy.com> writes:
>>
>>> (defun camelize-region (start end)
>>>   (interactive "r")
>>>   (capitalize-region start end)
>>>   (let ((end (let ((m (make-marker))) (set-marker m end) m)))
>>>     (unwind-protect
>>>          (progn
>>>            (goto-char start)
>>> ;;             (while (re-search-forward "\\s-+" end t)
>>>           (while (re-search-forward "[ \t]+" end t) 
>>>             (delete-region (match-beginning 0) (match-end 0))))
>>>       (set-marker end nil))))
>>
>> Egad... please excuse my foolish blundering above... that code fails to
>> remove the spaces...  Somehow I failed to notice that....
>>
>> Maybe I'll get it right yet if I keep monkeying around with it.
>
>
> It works for me.
>
> (defun camelize-region (start end)
>   (interactive "r")
>   (capitalize-region start end)
>   (let ((end (let ((m (make-marker))) (set-marker m end) m)))
>     (unwind-protect
>          (progn
>            (goto-char start)
>            (while (re-search-forward "[ \t]+" end t) 
>              (delete-region (match-beginning 0) (match-end 0))))
>       (set-marker end nil))))

Yes... and again more blundering here... I tested with a copy that
lacked the `[]' brackets... and in that case it Does the
capitalization but ignores the spaces.

By the time I saw that I'd made that oversite... I figured I'd already
looked dumb enough... and didn't post a correction.

Learning this has been like many new bits of knowledge that come my
way... first I thrash around with it... making every mistake humanly
possible and finally settle down with a new tool that works and that I
understand well enough to get use from it.

Thanks for your patience.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]