emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Extensive update to hideif.el


From: Luke Lee
Subject: Extensive update to hideif.el
Date: Thu, 24 Oct 2013 17:48:12 +0800

Hi Emacs developers,

I've extensively modified hideif.el as attached and would like to contribute it back to Emacs. I've also posted it on EmacsWiki earlier http://www.emacswiki.org/emacs/HideIfDef. Here is the original posting:

---------- 
An extensively rewritten version is uploaded. Here I list some of the enhancements: 
* Automatically find and add #define macros when hiding 
* Complete C _expression_ with operator precedence implemented 
* Hex/octal/decimal number supported 
* Bit shift operation supported 
* Stringification / string concatenation / token concatenation supported 
* Argumented macro expansion supported, even for complicated and rarely used token replacement syntax. 

#define TESTVAL1 0x123 
#define TESTVAL2 291 // 0x123 

#define CONCAT(x,y) x ## y 
#define CONCAT2(x,y) CONCAT(x,y) 

#if CONCAT( TESTVAL1=,=TESTVAL2 ) 
#error correct 
#else 
#error wrong 
#endif 

#if CONCAT( TESTVAL1!,=TESTVAL2 ) 
#error wrong 
#else 
#error correct 
#endif 

after hiding, it will become 

#define TESTVAL1 0x123 
#define TESTVAL2 291 // 0x123 

#define CONCAT(x,y) x ## y 
#define CONCAT2(x,y) CONCAT(x,y) 

#if CONCAT( TESTVAL1=,=TESTVAL2 ) 
#error correct 
#else... 
#endif 

#if CONCAT( TESTVAL1!,=TESTVAL2 )... 
#else 
#error correct 
#endif 

* GNU C compatibility, i.e. "..." in macro argument supported. 
Ex. #define macro(arg1, arg2...) arg1 + arg2 
* hide/unhide a region 
* Evaluate a macro, just mark the region you want to evalute and press "C-c @ e" 
* When hiding #if..#endif themselves, consecutive "..." "..." will be merged as a single "..." 

Tips: 
* All C files share the same macro database (i.e. hide-ifdef-env). 
* Goto your "config.h" file and hide it, it will extract all #defines. 
* Goto each of your .h file in the order that C compiler compiles your C file, hide each .h file one by one. (TODO: project support, auto search for .h files) 
* To save your current macro database, you need to deploy "session" package and add the following into your init.el file: 
(unless (assoc 'hide-ifdef-env session-globals-include) 
  (push '(hide-ifdef-env 100000 t) session-globals-include)) 
* To exclude some patterns (to reduce the size of macro database), for example, if you want to exclude all macros started with "DOC_", put the following into your init.el: 
(setf hide-ifdef-exclude-define-regexp-pattern "DOC_.*") 

Compatibility note: 

The original "semantic" hack no longer work. 
---------- 

Thanks for all those nice Emacs experiences!

--
Best regards,
Luke Lee

Attachment: hideif.el
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]