@@ -211,21 +211,23 @@ 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
+ (when (file-directory-p use-dir)
216
+ (catch 'found
217
+ (let ((user (nth 2 (file-attributes use-dir)))
218
+ ; ; Abbreviate, so as to stop when we cross ~/.
219
+ (root (abbreviate-file-name use-dir)))
220
+ ; ; traverse current dir up to root as long as file owner doesn't change
221
+ (while (and root (equal user (nth 2 (file-attributes root))))
222
+ (let ((cabal-file (haskell-cabal-find-pkg-desc root)))
223
+ (when cabal-file
224
+ (throw 'found cabal-file)))
225
+
226
+ (let ((proot (file-name-directory (directory-file-name root))))
227
+ (if (equal proot root) ; ; fix-point reached?
228
+ (throw 'found nil )
229
+ (setq root proot))))
230
+ nil )))))
229
231
230
232
(defun haskell-cabal-find-pkg-desc (dir &optional allow-multiple )
231
233
" Find a package description file in the directory DIR.
0 commit comments