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: Pascal J. Bourguignon
Subject: Re: Help with upcasing words first char
Date: Tue, 25 Aug 2009 01:52:24 +0200
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.3 (darwin)

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))))


-- 
__Pascal Bourguignon__


reply via email to

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