dir-config.el – Automatically find and evaluate .dir-config.el Elisp files to configure directory-specific settings

The dir-config.el Emacs package automatically loads and evaluates Elisp code from a .dir-config.el file found in the buffer’s current directory or its closest parent directory. This facilitates adjusting settings or executing functions specific to the directory structure of each buffer.

For instance, you can use the dir-config package to:

  • Configure project-specific settings: Automatically set up environment variables, keybindings, or modes unique to each project.
  • Apply directory-specific customizations: Set specific behaviors or preferences for files in different directories, such as enabling or disabling certain minor modes based on security considerations. For example, you might disable linters that execute code in directories where you handle untrusted code.
  • Manage multiple environments: Switch between different coding environments or workflows by loading environment-specific configurations.

Installation

To install the dir-config from MELPA:

  1. If you haven’t already done so, add MELPA repository to your Emacs configuration.
  2. Add the following code to your Emacs init file to install the dir-config repository from MELPA:
(use-package dir-config
  :ensure t
  :custom
  (dir-config-file-names '(".dir-config.el"))
  (dir-config-allowed-directories '("~/src" "~/projects"))
  :config
  (dir-config-mode))

More information about dir-config.el

Leave a Reply

Your email address will not be published. Required fields are marked *