Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

direnv integration for emacs

License

NotificationsYou must be signed in to change notification settings

wbolster/emacs-direnv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

melpa badge

melpa stable badge

this package providesdirenv integration for emacs.

it works by invokingdirenv to obtain the environmentfor the current file,then updating the emacs variablesprocess-environment andexec-path.

the result is thatprograms started from within emacs,such as inferior shells, linters, compilers, and test runners,will be looked up in the correct$PATH,and will be startedwith the correct environment variables set.

to get started, add this to yourinit.el:

(use-package direnv:config (direnv-mode))

mandatory screenshot

installation

direnv.el isavailable from melpa.

withuse-package:

(use-package direnv)

manually:

M-x package-install RET direnv RET

alternatively, put the elisp filesomewhere in the loading pathand load it explicitly:

(require'direnv)

also make surethat the direnv version (direnv version)is at least 2.8.0since this package usesthe json export capabilities (direnv export json).

usage

the commanddirenv-update-environmentprovides the core functionality of this package:it updates the emacs environmentto the direnv environment for the current file.the minibuffer will show a messagewith a summary of the changes made to the environment,similar to whatdirenv does in a shell.its sibling commanddirenv-update-directory-environmentdoes the same for buffers that don't have an associated file.

the global minor modedirenv-mode does the same,but automatically updates the emacs environmentwhen the active buffer changes,so that the environment always matches the current file.to automatically enable this behaviour when emacs starts,put this in your~/.emacs/init.el:

(direnv-mode)

or use theuse-package:config block:

(use-package direnv:config (direnv-mode))

finally, thedirenv-allow commandacts likedirenv allow from a shell:it allows loading the.envrc fileassociated with the current directoryor one of its parent directories.this command is useful for new projects(always check whether the.envrc file is trustworthy),or after editing the.envrc file within emacs itself.

configuration

this packages offers various configuration settings.these settings can be set in ause-package:custom block,using(setq), or via the customize interface:

M-x customize-group RET direnv RET

the available settings are outlined below.

  • direnv-always-show-summary

    whendirenv-mode automatically changes the environment,a summary message will be shown in the minibuffer.summary messages of automatic changes can be suppressedby settingdirenv-always-show-summary tonil.interactive calls, e.g.direnv-update-environment,will still show a summary message.

  • direnv-show-paths-in-summary

    the summary message containsthe paths of the old and new directories,which may be a bit too verbose for your taste.thedirenv-show-paths-in-summary variablecontrols whether the summary includes path names.to get shorter summary messages, usenil.

  • direnv-use-faces-in-summary

    the summary message uses different font facesfor added, changed, and removed environment variables.depending on your theme,this usually results in different colours.this behaviour can be disabledby settingdirenv-use-faces-in-summary tonil.

  • direnv-non-file-modes

    this is a list of modeswhere direnv will updateeven if the buffer has no file.examples include shells andinteractive compilation (comint) buffers.example usage (withuse-package):

    (use-package foobar:config (add-to-list'direnv-non-file-modes'foobar-mode))
  • warning-suppress-types

    this is an emacs variable with a list of warning typeswhich are not displayed immediately.use it to hide error messages fromdirenv.example usage (withuse-package):

    (use-package direnv:config (add-to-list'warning-suppress-types '(direnv)))

troubleshooting

if you experience problems,first check the buffer named*direnv*.this buffer containsthe output of the lastdirenv invocation,which will likely contain more informationabout the source of the problem.

when an error happens, the direnv stderr willbe automatically shown in the message area,but for non-fatal problemssuch as incorrect.envrc filesyou may have to open this buffer manually for inspectionof the full output of the lastdirenv call.

to hide direnv errors such as.envrc is blocked,customize the variablewarning-suppress-types.

contributing

praise? complaints? bugs? questions? ideas?

please use the github issue tracker.

credits

this emacs package was created bywouter bolsterlee (@wbolster).

it incorporates ideas from earlierpackages created byjonathan lange (@jml)andchristian romney (@christianromney).

history

  • 2.2.0 (2021-10-11)
    • depend on emacs 25.1+
    • allow user to hide warnings and errors from direnv#61
    • use bothpost-command-hook andbefore-hack-local-variables-hook whendirenv-mode is used.this should cause direnv to load earlier which can avoid certainissues when opening a file in a direnv controlled directory forthe first time. see#61 and#17
    • loaddiff-mode to avoid ‘invalid face reference’ warnings#69
    • explicitly set json-object-type when parsing jsonto avoid potential conflicts with other packages#72
  • 2.1.0 (2020-02-29)
    • require emacs 25+ (it's 3 years old)#42
    • fix emacs 25 compatibility issues
    • also consider derived modes fordirenv-non-file-modes#49
    • usedirenv inmagit-mode by default#50
    • try to avoid opening remote connections#46
    • preventeshell-path-env getting out-of-sync with$PATH#55
    • use base buffer mode directories for indirect buffers#51
    • includecomint-mode andcompilation-mode indirenv-non-file-modes by default#58
  • 2.0.0 (2019-05-11)
    • adddirenv-allow command; see#43
    • use friendlier path formatting in summary message; see#44
    • improve handling of direnv output and improve error reporting; see#41 and#42
    • remove brokendirenv-edit command#20
  • 1.5.0 (2019-03-19)
    • handle indirect buffers correctly; see#25
    • displaydirenv errors in the message area; see#34
    • make the*direnv* buffer easier to find by removing theleading space
    • addeshell anddired to list of non-file-modes; see#36 and#33
  • 1.4.0 (2018-03-01)
    • smarter default behaviour of summary messages on environmentchange; see#23
  • 1.3.0 (2018-02-13)
    • improved operation with non-file modes,such as shells and compilation buffers.seedirenv-non-file-modes.
  • 1.2.1 (2017-06-22)
    • direnv-mode no longer fails when opening a file ina directory that does not (yet) exist.
  • 1.2.0 (2017-05-01)
    • summary message now uses custom font faces (colours!)
    • improved error handling
  • 1.1.0 (2017-03-09)
    • implemented summary message after updating environment,and configuration variables to tweak how it works.
    • expanded docs
  • 1.0.1 (2017-03-08)
    • initial release with basic functionality

license

3-clause new bsd license; see LICENSE.rst.


[8]ページ先頭

©2009-2025 Movatter.jp