@@ 1385,48 1385,30 @@ minibuffer, even without explicitly focusing it."
(my/indent-variable-mode-alist-add csharp-mode c-basic-offset)
(my/indent-variable-mode-alist-add csharp-ts-mode csharp-ts-mode-indent-offset)
- (defun find-project-root ()
- (interactive)
- (if (ignore-errors (eproject-root))
- (eproject-root)
- (or (find-git-repo (buffer-file-name)) (file-name-directory (buffer-file-name)))))
-
- (defun find-git-repo (dir)
- (if (string= "/" dir)
- nil
- (if (file-exists-p (expand-file-name "./.git/" dir))
- dir
- (find-git-repo (file-name-parent-directory dir)))))
-
- (defun get-csproj-in-directory (dir)
+ (defun csharp--get-csproj-in-directory (dir)
(car (directory-files dir
:mach-regexp ".*\\.csproj"
:count 1)))
;; Finds .csproj above current buffer directory, and returns path to the csproj
- (defun find-csproj (dir root)
- (if (string-match-p (regexp-quote root) dir)
- (let ((csproj (get-csproj-in-directory dir)))
- (if csproj
- csproj
- (find-csproj (file-name-parent-directory dir) root)))
- nil))
-
- (defun find-current-csproj ()
- (let ((root (find-project-root))
- (dir (file-name-directory buffer-file-name)))
- (find-csproj dir root)))
-
- (defun extract-project-name ()
+ (defun csharp--find-csproj (dir)
+ (csharp--get-csproj-in-directory
+ (locate-dominating-file
+ dir #'get-csproj-in-directory)))
+
+ (defun csharp--find-current-csproj ()
+ (csharp--find-csproj buffer-file-name))
+
+ (defun csharp--extract-project-name ()
(interactive)
- (let ((csproj (find-current-csproj)))
+ (let ((csproj (csharp--find-current-csproj)))
(file-name-base csproj)))
- (defun file-path-to-namespace ()
+ (defun csharp-file-path-to-namespace ()
(interactive)
- (let* ((root (file-name-directory (find-current-csproj)))
+ (let* ((root (file-name-directory (csharp--find-current-csproj)))
(base (file-name-nondirectory buffer-file-name))
- (project-name (extract-project-name))
+ (project-name (csharp--extract-project-name))
(subdirectory
(replace-regexp-in-string "/" "\." (substring buffer-file-name (length root) (* -1 (length base))) t t)))
(concat