• 1 Post
  • 13 Comments
Joined 2 years ago
cake
Cake day: June 20th, 2023

help-circle

  • Sweet! It’s actually my main language. C mode is built-in so no concern on that side.

    Some general advice:

    • I leaned it way too late, but you can use M-x compile and then type your build command (make clean && make all) instead of using a terminal to compile your project.
    • Try to learn a bit about Makefiles, it’s useful. Avoid cmake like plague.
    • C is great for embedded, so you should look up TRAMP if that’s your use case; it basically removes the need for SSH-ing from a shell.

    To have Emacs behave like an IDE:

    • Install clang17 clang17-extra-tools bear on the host system.
    • Configure eglot and company in your Emacs config:
    (use-package eglot)
    (add-hook 'c-mode-hook 'eglot-ensure)
    (with-eval-after-load 'eglot
      (add-to-list 'eglot-server-programs
                   '((c-mode c++-mode)
                     . ("clangd"))))
    
    (use-package company)
    (add-hook 'after-init-hook 'global-company-mode)
    
    • Use the bear tool (ex. bear --config bear_config.json -- make all) to make the non-trivial project understandable by Emacs. Since it re-uses your Makefile, it even works for cross-compilation!

    Good luck!


  • Interesting for sure, but I would not recommend going for most of these packages unless you are already very familiar with Emacs.

    Here are the steps I would recommend if you find motivation to learn the editor:

    1. Install it, learn the basic use and navigation
    2. Focus on learning and configuring it for your main use-case (writing code in a specific language, taking notes, writing papers, playing Tetris, etc.). This might take a while.
    3. Question life, re-try VSCode and get instantly grossed out.
    4. ???
    5. Try weird packages, moving most of you digital life inside Emacs.

    Enjoy =)