From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Oleh Krehel Newsgroups: gmane.emacs.devel Subject: Re: CC Mode and GCC/CEDET integration for evaluating macros Date: Fri, 01 May 2015 20:23:32 +0200 Message-ID: <877fssi2cb.fsf@gmail.com> References: <87k2wsi62e.fsf@gmail.com> <20150501181135.GA6376@acm.fritz.box> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1430504990 22017 80.91.229.3 (1 May 2015 18:29:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 1 May 2015 18:29:50 +0000 (UTC) Cc: emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri May 01 20:29:42 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YoFgy-00069z-Ve for ged-emacs-devel@m.gmane.org; Fri, 01 May 2015 20:29:41 +0200 Original-Received: from localhost ([::1]:55161 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YoFgy-0007Ey-5m for ged-emacs-devel@m.gmane.org; Fri, 01 May 2015 14:29:40 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41172) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YoFgu-0007Bs-MP for emacs-devel@gnu.org; Fri, 01 May 2015 14:29:37 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YoFgp-0000kC-Fd for emacs-devel@gnu.org; Fri, 01 May 2015 14:29:36 -0400 Original-Received: from mail-wi0-x230.google.com ([2a00:1450:400c:c05::230]:37877) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YoFgp-0000k8-8s for emacs-devel@gnu.org; Fri, 01 May 2015 14:29:31 -0400 Original-Received: by widdi4 with SMTP id di4so55252407wid.0 for ; Fri, 01 May 2015 11:29:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=wYLG8fktVxPVd+RdaeGIAedwkaQnnfHpZipyJJsMMmA=; b=M2PcIyPeoVYLzPfntz89PWT7LS5A92u3OddjHUFBvaqISgkmz5coCcOGDht67FVShS H7DRj8mlUNCep3yrrXleUb774yaOWyG/UF50fwI9s7ypIf5XVsUq/mW1pAy5VOxlnR2N fd6IbBU5eOGxGo7Xk/CFzcPJs0TVBy7Qqb8hf1n9fli/Aj9olWz/OH/0TfUXhjIem+xn 2hCaftzFqgHsWlJXATXapegVmHZYK5r2zOWcy6H+D/h9maYAmTpREnIi9jPCpxI+Zdf4 E0CceiJKRB4G+tYmC2hNeduqYNZV7rHAqzfBv00SXhBIb/MhjVB8P61AXjfgyrThQ1Of fhnw== X-Received: by 10.180.80.197 with SMTP id t5mr16382816wix.63.1430504970175; Fri, 01 May 2015 11:29:30 -0700 (PDT) Original-Received: from firefly (dyn069045.nbw.tue.nl. [131.155.69.45]) by mx.google.com with ESMTPSA id pm1sm8593748wjb.23.2015.05.01.11.29.29 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 01 May 2015 11:29:29 -0700 (PDT) In-Reply-To: <20150501181135.GA6376@acm.fritz.box> (Alan Mackenzie's message of "Fri, 1 May 2015 18:11:35 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::230 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:186093 Archived-At: Hello Alan, Thanks for the response, I'm really glad I asked first before trying to hack up something on my own. Alan Mackenzie writes: > On Fri, May 01, 2015 at 07:03:05PM +0200, Oleh Krehel wrote: > >> Hi all, > >> I just went through the whole CC Mode manual, just to make sure that I'm >> not being silly asking for an existing feature. > >> I'd like to be able to evaluate the current symbolic constant at point >> with "C-x C-e" for C/C++. > > There's nothing like that in CC Mode. But there is c-macro-expand in > cmacexp.el which might have something like this, or be easily hackable to > something like this. I tried c-macro-expand and it works well for macros defined within the current file, and even for the standard stuff like __TIMESTAMP__. But it doesn't work, for instance for HAVE_PWD_H in editfns.c. Do you know if it could work? Is it just a matter of passing some include path to the preprocessor call? >> Moreover, I remember when I was using Visual Studio 10 years ago, it >> had a feature of parsing the macros and graying out #ifdef branches. I >> found a screenshot of this if it's not clear what I mean: >> http://stackoverflow.com/questions/11610549/ > > There is hide-ifdef-mode in Emacs which does something similar - It makes > the "non-active" bits of #ifdef branches invisible rather than changing > their appearance. Doubtless it would be easy enough to add the "greying > out" facility as an option. It appears that `hide-ifdefs' hides them unconditionally. >> I think it would be really cool to add both these features to CC Mode. > > I'm not sure CC Mode would be the best place for these. hide-ifdef-mode > nd c-macro-expand already exist. I suggest you look at these first. The functions exist, sure. But for most users they are invisible / unknown unless they are bound in a keymap. `c-mode-map' is pretty visible and would be a great way to promote these features. Oleh