If anyone's interested, the enclosed patch against the current CC-mode CVS makes Emacs CC-mode very well-behaved w.r.t. identifying template syntax. Along with various hacks in my .emacs file to customize how it's indented, I'm able to do this automatically:
template < class T , class U , class R , class U , template< class F , class H , class G >::type , class U = std::auto_ptr< std::vector<int, allocator< int > > >, , groot > struct foo { typedef typename foo< bar >::template baz< mumble, bag, floot >::type boo; }; The preceding commas are my preference, but it also handles trailing commas nicely. If anyone's interested in culling the relevant hacks from my .emacs file, you can find it at http://www.boost-consulting.com/.emacs Enjoy,
--- cc-engine.el.~5.428.~ 2003-07-31 16:13:21.000000000 -0400 +++ cc-engine.el 2003-08-04 22:26:47.000000000 -0400 @@ -5934,7 +5934,15 @@ (or (memq (char-after) '(?, ?=)) (and (c-major-mode-is 'c++-mode) (zerop (c-backward-token-2 1 nil lim)) - (eq (char-after) ?<))))) + (or + (eq (char-after) ?<) + ;; handle template template arguments + (and (condition-case nil + (backward-up-list) + (error nil)) + (eq (char-after) ?<) + )) + )))) (goto-char indent-point) (setq placeholder (c-beginning-of-member-init-list lim)) @@ -5984,8 +5992,11 @@ (eq (char-after placeholder) ?<)))))) ;; we can probably indent it just like an arglist-cont (goto-char placeholder) - (c-beginning-of-statement-1 lim t) - (c-add-syntax 'template-args-cont (c-point 'boi))) + (while (save-excursion + (and (zerop (c-backward-token-2 1 t lim)) + (looking-at "[<a-zA-Z_]\\|::"))) + (c-backward-token-2 1 t lim)) + (c-add-syntax 'template-args-cont (point))) ;; CASE 5D.4: perhaps a multiple inheritance line? ((and (c-major-mode-is 'c++-mode) (save-excursion
-- Dave Abrahams Boost Consulting www.boost-consulting.com
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost