Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fsharp-mode-project-root breaks when the file doesn't exist #340

Open
catern opened this issue Apr 10, 2024 · 1 comment
Open

fsharp-mode-project-root breaks when the file doesn't exist #340

catern opened this issue Apr 10, 2024 · 1 comment

Comments

@catern
Copy link

catern commented Apr 10, 2024

Description

fsharp-mode adds fsharp-mode-project-root to project-find-functions, which is run by project-current. Such functions should return nil if they can't find a project; otherwise, they make cause project-current as a whole to error.

This causes Emacs to break if e.g. there's a buffer visiting a file which hasn't yet been created.

Repro steps

Please provide the steps required to reproduce the problem

  1. M-: (fsharp-mode-project-root "/non/existent")

Expected behavior

It should return nil as is the project-find-functions spec

Actual behavior

It errors:

Debugger entered--Lisp error: (file-missing "Opening directory" "No such file or directory" "/non")
  directory-files("/non/" full ".*\\.sln$")
  fsharp-mode-search-upwards(".*\\.sln$" "/non/")
  fsharp-mode/find-sln("/non/existent")
  fsharp-mode/find-sln-or-fsproj("/non/existent")
  fsharp-mode-project-root("/non/existent")
  eval((fsharp-mode-project-root "/non/existent") t)
  eval-expression((fsharp-mode-project-root "/non/existent") nil nil 127)
  funcall-interactively(eval-expression (fsharp-mode-project-root "/non/existent") nil nil 127)
  call-interactively(eval-expression nil nil)
  command-execute(eval-expression)
@dgutov
Copy link

dgutov commented Apr 10, 2024

In general, though, I would advise against buffer-local project backends altogether (for different reasons: the "current project" becomes different between files in the same directory; file listing performance won't take advantage of git ls-files).

It seems like your goal here can be reached by the user customizing the new-ish option called project-vc-extra-root-markers instead. This would avoid the above problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants