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: Mon, 24 Aug 2009 17:49:07 -0500
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.96 (gnu/linux)

address@hidden (Pascal J. Bourguignon) writes:

>>
>>    Mark set
>>   unwind-protect: Symbol's value as variable is void: m
>>   Mark set
>
> The error is on the last line, replace m by end:
>
>         (set-marker end nil))))
>
> Sorry about that.
>
>
>> Also I tried it on a larger region consisting of several lines and
>> again it worked but in that case also removed the newlines.
>
> Since the case of newlines has not been specified, I considered them
> as whitespaces...

Your right... I did not specify that and really only thought of it
after having posted the OP.

[...] snipped more nifty tips

> If you want only spaces or tabs, you can use  "[ \t]+" instead.

That works and allows the function to work over mulitple lines.

So with near total plagiarism of your code... I post below what
appears to be working code... I'm assuming there are other lisp
challenged readers who may find use for it.  These tiny changes appear
to allow it to work over multiple lines.

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





reply via email to

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