0

I'm using Doom Emacs with (cc +tree-sitter +lsp), you can find my full config here: https://github.com/ZaneH/doom-emacs-config/blob/main/init.el

When editing this file:

// ./src/gui/ChatWindow.h

#pragma once
#include "../libs/Models/Message.h"
#include <QThread>
#include <QWidget>

class QTextEdit;
class QPushButton;

class ChatWindow : public QWidget {
  Q_OBJECT
  QThread consumerThread;

public:
  ChatWindow(QWidget *parent = nullptr);

private slots:
  void sendMessage();
  void adjustTextEditHeight();
  void addMessage(Message *message);

private:
  QTextEdit *chatLog;
  QTextEdit *messageBox;
  QPushButton *sendButton;
};

If I put a newline after ChatWindow(QWidget *parent = nullptr); it indents all the way to the ; character from the previous line like so:

  QThread consumerThread;

public:
  ChatWindow(QWidget *parent = nullptr);
                                      |

If I press C-c C-s it shows: ((inher-cont 247)).

Things I've tried:

  • Add and configure the google-c-style package
  • Check that Q_OBJECT is in c-macro-names-with-semicolon
  • Set inher-cont to 0
  • Configure clangd

Luckily, when I save the file, the formatter takes care of this awkward indention but it is something I'd like to fix without having to save.

5
  • As a workaround, what happens if you then type foo<TAB>? Does it realign the foo with the ChatWindow? Also is electric-indent-mode enabled? If so, try disabling it. Commented Jul 29 at 3:09
  • Writing foo<TAB> in the newline didn't react when pressing tab. When I turn electric-indent-mode off, pressing tab takes me back, but not exactly the correct indention level (still has 2 extra spaces) Commented Jul 29 at 20:40
  • Try the same experiments but starting with emacs -Q, which will bypass your init file. I suspect that the settings in your init file are partly to blame, but you need to start from a solid starting point. ATM, we don't have that. Commented Jul 29 at 21:35
  • I forgot that you mentioned you are using Doom though - that may complicate things a bit... Commented Jul 30 at 0:32
  • 1
    You have two styles working, one is doom as set by the cc-mode, the other is google-set-style which cancel all fine tweaking made in cc-mode - the culprit is google-make-newline-indent - so remove that package and base your settings only on cc and clang-format; working with multiple projects is easier if you have a suitable .clang-format file in root folder of your projects. Commented Aug 6 at 11:16

0

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.