From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tim X Newsgroups: gmane.emacs.help Subject: Re: something like un-camelcase region Date: Mon, 26 Jul 2010 08:12:35 +1000 Organization: Unlimited download news at news.astraweb.com Message-ID: <87aapfqkh8.fsf@puma.rapttech.com.au> References: <88OdnflNLbAk49HRnZ2dnUVZ_r-dnZ2d@sysmatrix.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1291851810 12666 80.91.229.12 (8 Dec 2010 23:43:30 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 8 Dec 2010 23:43:30 +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 00:43: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 1PQTfI-0000yt-2Y for geh-help-gnu-emacs@m.gmane.org; Thu, 09 Dec 2010 00:43:16 +0100 Original-Received: from localhost ([127.0.0.1]:54361 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PQTS9-0002v6-8t for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Dec 2010 18:29:41 -0500 Original-Path: usenet.stanford.edu!news.glorb.com!news2.glorb.com!news.glorb.com!news.astraweb.com!border5.newsrouter.astraweb.com!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:8XZqlt6FzzhQRydW2dJJmmJRROY= Original-Lines: 66 Original-NNTP-Posting-Host: 0441692d.news.astraweb.com Original-X-Trace: DXC=TiIIlj`X6:2CObSL`Ra@h6L?0kYOcDh@:W\:Hm@YlDb:aQdZO8YXiJ89; iI7X3QZd7HYn7WVXSJ8< Original-Xref: usenet.stanford.edu gnu.emacs.help:180061 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 Xref: news.gmane.org gmane.emacs.help:76228 Archived-At: "B. T. Raven" 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