Using Emacs as an IDE

后端 未结 18 1836
清酒与你
清酒与你 2020-11-29 14:29

Currently my workflow with Emacs when I am coding in C or C++ involves three windows. The largest on the right contains the file I am working with. The left is split into

18条回答
  •  囚心锁ツ
    2020-11-29 15:09

    Okay, everyone here is giving perfect hints to make emacs a great IDE.

    But anyone should keep in mind that, when you customize your emacs with a lot of extension (especially with the ones for type-checking on the fly, function definition lookups etc) your emacs will load very, very slow for an editor.

    To workaround this, I would highly recommend to use emacs in server mode.

    It is pretty simple to use, no need to customize your init file. You just need to start emacs in daemon mode;

    emacs --daemon
    

    This will create an emacs server, then you can connect it either from terminal, or from gui. I'd also recommend to create some aliases to make it easy to call.

    alias ec="emacsclient -t"
    alias ecc="emacsclient -c &"
    # some people also prefer this but no need to fight here;
    alias vi="emacsclient -t"
    

    This way, emacs will fire up even faster than gedit, promise.

    The one possible problem here, if you are running emacs daemon from your casual user, you probably can't connect emacs server as root.

    So, if you need to open a file that has root access; use tramp instead. Just run your emacs client with your normal user and open files like this;

    C-x C-f
    /sudo:root@localhost/some/file/that/has/root/access/permissions
    # on some linux distro it might be `/su:root@...` 
    

    This made my life easier, I can open my heavy customized python IDE in miliseconds this way. You may also want to add emacs --daemon to your system startup, or create a desktop file for emacsclient. Thats up to you.

    More on emacs daemon and emacs client can be found at wiki;

    http://www.emacswiki.org/emacs/EmacsAsDaemon

    http://www.emacswiki.org/emacs/EmacsClient

提交回复
热议问题