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 08:59:21 -0500
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.96 (gnu/linux)

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

> Now you are ready to write an emacs lisp command doing the same:
>
> (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)
>              (delete-region (match-beginning 0) (match-end 0))))
>       (set-marker m nil))))

That works nicely but does throw an error when it finishes.  My
non-existent lisp skills were not able to determine what is causing
it.

  (From *Messages* Buffer)

   Mark set
  unwind-protect: Symbol's value as variable is void: m
  Mark set

Also I tried it on a larger region consisting of several lines and
again it worked but in that case also removed the newlines.

I don't really understand what the regex you used (\s-+) means.  I
understand `\s' to mean any single occurrence of any whitespace.

And also understand the `+' operator to mean `at least one plus any
number of matches to preceding regex.  But again ... not sure what the
`-' operator does.

But I wondered if that `\s' could be changed to something a little more
exclusive.... like maybe tabs and spaces only.. and if that would
allow the function to work on more than one line?





reply via email to

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