@@ -211,21 +211,25 @@ Return nil if no Cabal description file could be located via
211
211
If DIR is nil, `default-directory' is used as starting point for
212
212
directory traversal. Upward traversal is aborted if file owner
213
213
changes. Uses`haskell-cabal-find-pkg-desc' internally."
214
- (catch 'found
215
- (let ((user (nth 2 (file-attributes (or dir default-directory))))
216
- ; ; Abbreviate, so as to stop when we cross ~/.
217
- (root (abbreviate-file-name (or dir default-directory))))
218
- ; ; traverse current dir up to root as long as file owner doesn't change
219
- (while (and root (equal user (nth 2 (file-attributes root))))
220
- (let ((cabal-file (haskell-cabal-find-pkg-desc root)))
221
- (when cabal-file
222
- (throw 'found cabal-file)))
223
-
224
- (let ((proot (file-name-directory (directory-file-name root))))
225
- (if (equal proot root) ; ; fix-point reached?
226
- (throw 'found nil )
227
- (setq root proot))))
228
- nil )))
214
+ (let ((use-dir (or dir default-directory)))
215
+ (while (and use-dir (not (file-directory-p use-dir)))
216
+ (setq use-dir (file-name-directory (directory-file-name use-dir))))
217
+ (when use-dir
218
+ (catch 'found
219
+ (let ((user (nth 2 (file-attributes use-dir)))
220
+ ; ; Abbreviate, so as to stop when we cross ~/.
221
+ (root (abbreviate-file-name use-dir)))
222
+ ; ; traverse current dir up to root as long as file owner doesn't change
223
+ (while (and root (equal user (nth 2 (file-attributes root))))
224
+ (let ((cabal-file (haskell-cabal-find-pkg-desc root)))
225
+ (when cabal-file
226
+ (throw 'found cabal-file)))
227
+
228
+ (let ((proot (file-name-directory (directory-file-name root))))
229
+ (if (equal proot root) ; ; fix-point reached?
230
+ (throw 'found nil )
231
+ (setq root proot))))
232
+ nil )))))
229
233
230
234
(defun haskell-cabal-find-pkg-desc (dir &optional allow-multiple )
231
235
" Find a package description file in the directory DIR.
0 commit comments