From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "B. T. Raven" Newsgroups: gmane.emacs.help Subject: something like un-camelcase region Date: Sun, 25 Jul 2010 13:13:08 -0500 Message-ID: <88OdnflNLbAk49HRnZ2dnUVZ_r-dnZ2d@sysmatrix.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1291856309 30245 80.91.229.12 (9 Dec 2010 00:58:29 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 9 Dec 2010 00:58:29 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Dec 09 01:58:25 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PQUq1-0000kE-33 for geh-help-gnu-emacs@m.gmane.org; Thu, 09 Dec 2010 01:58:25 +0100 Original-Received: from localhost ([127.0.0.1]:39534 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQUq0-0004FD-G4 for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Dec 2010 19:58:24 -0500 Original-Path: usenet.stanford.edu!news.glorb.com!news2.glorb.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.sysmatrix.net!news.sysmatrix.net.POSTED!not-for-mail Original-NNTP-Posting-Date: Sun, 25 Jul 2010 13:13:13 -0500 User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) Original-Newsgroups: gnu.emacs.help X-No-Archive: yes Original-Lines: 51 X-Usenet-Provider: http://www.giganews.com Original-NNTP-Posting-Host: 12.73.128.177 Original-X-Trace: sv3-64tJ2dbpsWgiBmpGjYMdXqxNzlgGLB9piBMkTfJjl01Ikvje6iWnTvLdNEkXOB6b9j1ZM/kdyWMMDB0!ES5kj4yXsIuM6Oo/3RB3DMriXGMvIm14prRC5X+5IBoF7Lg4Sw/i6TBtH2vYHBl1FJ/7ZOwCdzJI!ZWfZ+QVcKw5vI/quYoHTVDHWHNl9/1w= Original-X-Complaints-To: abuse@sysmatrix.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 Original-Xref: usenet.stanford.edu gnu.emacs.help:180051 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org X-Gmane-Expiry: 2010-12-23 Xref: news.gmane.org gmane.emacs.help:76338 Archived-At: 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