1

In emacs 21:

namespace Abc { namespace Def { 
    class X;
    namespace Ghi {
        class Y;
    }
} }

But now in emacs 22.2.1:

namespace Abc { namespace Def {
        class X;
        namespace Ghi {
            class Y;
        }
    } }

How do I get the old behaviour back? Note that I don't want a fixed column for indentation, I want it to indent one level regardless of how many 'namespace {' the line contains.

2
  • Apologies as this is not directly relevant to the question, but is your project so large and maintained by so many independent developers that you need nested namespaces? It looks as though namespaces are being used here more for organizational purposes than to avoid name conflicts, but I'd recommend against doing that as it can cause more headaches in the long run (ex: ADL problems). Commented Jul 1, 2010 at 10:14
  • What is wrong with nested namespaces? Commented Jul 1, 2010 at 12:04

1 Answer 1

3

I actually found the answer myself, in a moment of clear thinking:

(defun followed-by (cases)
  (cond ((null cases) nil)
        ((assq (car cases) 
               (cdr (memq c-syntactic-element c-syntactic-context))) t)
        (t (followed-by (cdr cases)))))


(c-add-style  "foo"      
              `( ...
        (c-offsets-alist
         ( ... )
         (innamespace
          . (lambda (x) 
          (if (followed-by 
               '(innamespace namespace-close)) 0 '+))))))

The '...' symbolizes other personalizations of course.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.