简体   繁体   English

使用emacs进入“ cd”更改目录

[英]Hook into “cd” change directory with emacs

I'm looking to load a local config file for emacs when I "Mx: cd" into a new directory. 当我将“ Mx:cd”放入新目录时,我希望为emacs加载本地配置文件。 Project specific settings. 项目特定的设置。 I'm wondering how'd I'd set this up in my init.el. 我想知道如何在init.el中进行设置。 I've got a local config setup like 我有一个本地配置设置

(if (file-exists-p "~/.emacs.d/local.el") (load-file "~/.emacs.d/local.el")) (如果(file-exists-p“〜/ .emacs.d / local.el”)(加载文件“〜/ .emacs.d / local.el”))

Your question isn't entirely clear, but one very useful technique for project-specific settings is to use a .dir-locals.el file : 您的问题尚不完全清楚,但是针对项目特定设置的一种非常有用的技术是使用.dir-locals.el文件

Sometimes, you may wish to define the same set of local variables to all the files in a certain directory and its subdirectories, such as the directory tree of a large software project. 有时,您可能希望为某个目录及其子目录(例如大型软件项目的目录树)中的所有文件定义相同的局部变量集。 This can be accomplished with directory-local variables. 这可以通过目录局部变量来完成。

...

Here's an example of a .dir-locals.el file: 这是一个.dir-locals.el文件的示例:

 ((nil . ((indent-tabs-mode . t) (fill-column . 80))) (c-mode . ((c-file-style . "BSD") (subdirs . nil))) ("src/imported" . ((nil . ((change-log-default-name . "ChangeLog.local")))))) 

对我来说,您要问的不是很清楚,但是如果您想在调用Emacs函数(命令) cd时做其他事情,则只建议它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM