How to make Emacs C source directory permanent?

前端 未结 2 1571
误落风尘
误落风尘 2021-02-07 10:13

I\'m new to Emacs and I\'m just learning how to use it. I know how to set my \"Emacs C Source dir\" but I don\'t know how to make this change permanent. I guess I have to set it

相关标签:
2条回答
  • 2021-02-07 10:53

    Ordinarily most user-settable variables can be edited with Customize, but for some reason the source-directory variable isn't one of them.

    You will need to edit your ~/.emacs file to include a line such as:

    (setq source-directory "/path/to/emacs/source/dir")
    

    Do not include the trailing src directory; it will be added automatically. Then exit and restart Emacs.

    Note that setting this after Emacs is running may have no effect because it's only read when find-func.el is loaded. You can set find-function-C-source-directory instead (with the /src), but that can get overwritten. It's better just to (setq source-directory ...) at startup, as above.

    0 讨论(0)
  • 2021-02-07 11:08

    Assuming you have a decent locate-style shell-command, this saves you having to remember the path exactly. It should thus still work in your ~/.emacs.d/init.el if you upgrade to a newer version, as long as you still have the sources.

    (setq source-directory
          (file-name-directory
           (shell-command-to-string
        (concat "locate --limit 1 emacs-" emacs-version "/src"))))
    
    0 讨论(0)
提交回复
热议问题