From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-1?Q?Andreas_R=F6hler?= Newsgroups: gmane.emacs.help Subject: Re: Change function name style Date: Fri, 30 Jul 2010 08:36:50 +0200 Message-ID: <4C527302.4090105@easy-emacs.de> References: <4C51D76F.1000908@easy-emacs.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1280471913 23547 80.91.229.12 (30 Jul 2010 06:38:33 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 30 Jul 2010 06:38:33 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jul 30 08:38:30 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 1OejEk-00060c-7Y for geh-help-gnu-emacs@m.gmane.org; Fri, 30 Jul 2010 08:38:30 +0200 Original-Received: from localhost ([127.0.0.1]:42772 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oej9T-0004lu-CB for geh-help-gnu-emacs@m.gmane.org; Fri, 30 Jul 2010 02:33:03 -0400 Original-Received: from [140.186.70.92] (port=35898 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oej8t-0004kS-4A for help-gnu-emacs@gnu.org; Fri, 30 Jul 2010 02:32:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Oej8r-0001gJ-IE for help-gnu-emacs@gnu.org; Fri, 30 Jul 2010 02:32:26 -0400 Original-Received: from moutng.kundenserver.de ([212.227.17.8]:64115) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oej8r-0001fr-1M for help-gnu-emacs@gnu.org; Fri, 30 Jul 2010 02:32:25 -0400 Original-Received: from [192.168.178.27] (p5DDB0A80.dip0.t-ipconnect.de [93.219.10.128]) by mrelayeu.kundenserver.de (node=mreu1) with ESMTP (Nemesis) id 0MCuYR-1OnDaH3JC7-009EBA; Fri, 30 Jul 2010 08:32:23 +0200 User-Agent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.1.11) Gecko/20100711 Thunderbird/3.0.6 In-Reply-To: X-Provags-ID: V02:K0:bkIPE9h18xkVqpbUPaROSW3rOdZlJvuoqwDICdJfcpW uDMTqXQfs/BcVSQ74LoCjpDS20jJAqX7uknYDoFxpZ/nLP4RPL SrPYnZJqC0G+srG14kHeeBW1jGPqFUknKCbgmrku6DGIj3tkrZ gIbCWdZe8+AnnUDx277pf7fGfsF9xc1YlxNyBtxqwzh/Tx3D+U zO9H/FR4KhJsimEOy7SXUxHnIlkwjsj37ca3bxpqQ8= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. 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:74350 Archived-At: Am 30.07.2010 01:48, schrieb suvayu ali: > On 29 July 2010 14:42, Andrea Crotti wrote: >>> I am a lisp newbie but how about something like this, >>> >>> (string-match "function-name" >>> (symbol-name (if (< (point) (point-max)) >>> (face-at-point) >>> (backward-char) >>> (face-at-point)))) >>> >>> I use this to have context sensitive abbreviation expansion. Maybe you >>> can adapt it for your case? >> >> Thanks a lot, but how do you use exactly this thing that there is no >> defun? >> > > Sorry I didn't include the entire defun as it involved all the other > things not relevant to your requirement. What I was suggesting was in > your defun you could check for the face with that snippet and then > apply the regex as suggested by Andreas. > > So something like this might work, (untested) > > (defun function-name-p (camelcase-to-underscore) > "Convert camel case function names to underscored names." > ;; backward-char checks if end-of-buffer as when point at e-o-b face is `nil' > (if (not (save-excursion > (string-match "function-name" > (symbol-name (if (< (point) (point-max)) > (face-at-point) > (backward-char) > (face-at-point)))))) > (funcall camelcase-to-underscore))) > > where camelcase-to-underscore is a defun that you defined to do the > conversion using the regex. > > How this works: > It looks at the face at point and checks whether the face name has the > string "function-name" and calls the function camelcase-to-underscore. > >> Anyway I see that strangely if I do face-at-point on a function call >> >> functionCall(...) >> >> I get a "default", it only recognizes functions when they're defined. >> So maybe is not the way to go... >> > > Of course my above proposal assumes you have font lock working > properly and `M-x describe-face' returns > "font-lock-function-name-face". For my setup the returns this name > both in emacs-lisp-mode and c++-mode. So I was expecting it would do > the same for your case. > > Good luck figuring this out. And do post back if you get any solution, > I would be interested to know. :) > Interesting, but even if it's the case or quite possible, the markup of a C-mode is written that way, putting different faces upon function and variable definitions, you can't rely on that with this purpose. Also you can't assume, a certain face isn't used otherwise too. To discriminate these forms, there is no way to parse the code understanding its content. Some tools may provide it, would assume Emacs' Cedet does. It comes a code-browser ECB with Emacs too. Andreas -- https://code.launchpad.net/~a-roehler/python-mode https://code.launchpad.net/s-x-emacs-werkstatt/