* something like un-camelcase region
@ 2010-07-25 18:13 B. T. Raven
2010-07-25 22:12 ` Tim X
[not found] ` <87y6czqs1r.fsf@fh-trier.de>
0 siblings, 2 replies; 3+ messages in thread
From: B. T. Raven @ 2010-07-25 18:13 UTC (permalink / raw)
To: help-gnu-emacs
I am looking for a regular expression that finds capital letters within
words (i.e. not at beginning of word or line)so that I can downcase
these caps only. I have a couple of non-functional functions that might
illustrate the general problem.
(defun downcase-bigvowel-within-word ()
"Downcase all majuscule vowels not at beginning of words."
(interactive)
(let ((start (point)))
(save-excursion
(query-replace-regexp-eval "[^ ][AEIOU]"
; doesn't cover case of cap at beginning of line
'(cdr (assoc (match-string-no-properties 0)
'(("A" . "a") ("E" . "e") ("I" . "i") ("O" . "o") ("U" . "u")
)))
nil start (point-max))
)))
Do I even need a function to solve this problem? Can more than one
"character set" (in regexp sense) be included in "replace regexp?"
Another function from the wiki (supposedly from friendsnippets.com) is:
(defun un-camelcase-string (s &optional sep start)
"Convert CamelCase string S to lower case with word separator SEP.
Default for SEP is a hyphen \"-\".
If third argument START is non-nil, convert words after that
index in STRING."
(let ((case-fold-search nil))
(while (string-match "[A-Z]" s (or start 1))
(setq s (replace-match (concat (or sep "-")
(downcase (match-string
0 s)))
t nil s)))
(downcase s)))
But this works on string rather than region and puts a hyphen before
downcased letter.
Any help with my correct regexp?
Thanks,
Ed
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: something like un-camelcase region
2010-07-25 18:13 something like un-camelcase region B. T. Raven
@ 2010-07-25 22:12 ` Tim X
[not found] ` <87y6czqs1r.fsf@fh-trier.de>
1 sibling, 0 replies; 3+ messages in thread
From: Tim X @ 2010-07-25 22:12 UTC (permalink / raw)
To: help-gnu-emacs
"B. T. Raven" <nihil@nihilo.net> writes:
> I am looking for a regular expression that finds capital letters within
> words (i.e. not at beginning of word or line)so that I can downcase
> these caps only. I have a couple of non-functional functions that might
> illustrate the general problem.
>
> (defun downcase-bigvowel-within-word ()
> "Downcase all majuscule vowels not at beginning of words."
> (interactive)
> (let ((start (point)))
> (save-excursion
> (query-replace-regexp-eval "[^ ][AEIOU]"
>
> ; doesn't cover case of cap at beginning of line
>
> '(cdr (assoc (match-string-no-properties 0)
> '(("A" . "a") ("E" . "e") ("I" . "i") ("O" . "o") ("U" . "u")
> )))
> nil start (point-max))
> )))
>
>
>
>
> Do I even need a function to solve this problem? Can more than one
> "character set" (in regexp sense) be included in "replace regexp?"
>
> Another function from the wiki (supposedly from friendsnippets.com) is:
>
> (defun un-camelcase-string (s &optional sep start)
> "Convert CamelCase string S to lower case with word separator SEP.
> Default for SEP is a hyphen \"-\".
>
> If third argument START is non-nil, convert words after that
> index in STRING."
> (let ((case-fold-search nil))
> (while (string-match "[A-Z]" s (or start 1))
> (setq s (replace-match (concat (or sep "-")
> (downcase (match-string
> 0 s)))
> t nil s)))
> (downcase s)))
>
> But this works on string rather than region and puts a hyphen before
> downcased letter.
>
> Any help with my correct regexp?
You may find glasses-mode useful
,----[ C-h f glasses-mode RET ]
| glasses-mode is an interactive autoloaded Lisp function in `glasses.el'.
|
| (glasses-mode &optional ARG)
|
| Minor mode for making identifiers likeThis readable.
| When this mode is active, it tries to add virtual separators (like underscores)
| at places they belong to.
|
| [back]
`----
--
tcross (at) rapttech dot com dot au
^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <87y6czqs1r.fsf@fh-trier.de>]
end of thread, other threads:[~2010-07-26 18:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-25 18:13 something like un-camelcase region B. T. Raven
2010-07-25 22:12 ` Tim X
[not found] ` <87y6czqs1r.fsf@fh-trier.de>
[not found] ` <ff-dnR8jKZbxUtDRnZ2dnUVZ_v-dnZ2d@sysmatrix.net>
2010-07-26 18:46 ` Andreas Politz
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).