all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* 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

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

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.