[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
hide-ifdef-mode (hideif.el) enhancements
From: |
Luke Lee |
Subject: |
hide-ifdef-mode (hideif.el) enhancements |
Date: |
Tue, 22 Oct 2013 23:21:53 -0700 (PDT) |
User-agent: |
G2/1.0 |
Hi Emacers,
I've submitted my (nearly re-written) modification of hide-ifdef mode onto
EmacsWiki. Please check http://www.emacswiki.org/emacs/HideIfDef for more
details.
If you found any bug, please inform me. Thanks.
Here I copy&paste some of my posts there:
----------
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.
----------
Have fun!
Best regards,
Luke Lee
- hide-ifdef-mode (hideif.el) enhancements,
Luke Lee <=