travisbhartwell / nix-emacs

A set of useful Emacs modes and functions for users of Nix and Nix OS.
225 stars 32 forks source link

fix sandbox detection to exclude directories #51

Closed thalesmg closed 3 years ago

thalesmg commented 3 years ago

the previous detection of nix sandboxes was incorrectly considering directories that ended in -nix as a sandbox directory (it was searching for .nix without escaping the dot).

also, even fixing the regex, if one had a directory ending in .nix (for example: haskell.nix for IOHK's repo), the parent directory would be considered the sandbox directory.

therefore, here, we fix the regex to escape the dot and to also reject directories that end in .nix from the search.

Examples:

The examples below use the following test structure:

ͳ pwd
/home/thales/tmp/test-nix-sandbox
ͳ tree
.
├── current-project
│   └── current.buffer
├── test-nix
│   └── some.file
└── test.nix
    └── some.file

3 directories, 3 files

Results of (nix-current-sandbox)