@@ -233,6 +233,10 @@ arguments."
233
233
(directory-files directory full match nosort)
234
234
(error nil )))
235
235
236
+ (defun idris-find-ipkg-file ()
237
+ " Return first found ipkg file in parent directory."
238
+ (car-safe (idris-find-file-upwards " ipkg" )))
239
+
236
240
(defvar idris-ipkg-build-buffer-name " *idris-build*" )
237
241
238
242
(defun idris-ipkg--compilation-buffer-name-function (_mode )
@@ -263,34 +267,34 @@ arguments."
263
267
264
268
(defun idris-ipkg-build (ipkg-file )
265
269
(interactive (list
266
- (if-let ((ipkg-default (idris-find-file-upwards " ipkg" )))
270
+ (if-let ((ipkg-default (idris-find-ipkg-file )))
267
271
(read-file-name " Package file to build: "
268
- (file-name-directory ( car ipkg-default) )
269
- ( car ipkg-default)
272
+ (file-name-directory ipkg-default)
273
+ ipkg-default
270
274
t
271
- (file-name-nondirectory ( car ipkg-default) ))
275
+ (file-name-nondirectory ipkg-default))
272
276
(read-file-name " Package file to build: " nil nil nil t ))))
273
277
(idris-ipkg-command ipkg-file 'build ))
274
278
275
279
(defun idris-ipkg-install (ipkg-file )
276
280
(interactive (list
277
- (if-let ((ipkg-default (idris-find-file-upwards " ipkg" )))
281
+ (if-let ((ipkg-default (idris-find-ipkg-file )))
278
282
(read-file-name " Package file to install: "
279
- (file-name-directory ( car ipkg-default) )
280
- ( car ipkg-default)
283
+ (file-name-directory ipkg-default)
284
+ ipkg-default
281
285
t
282
- (file-name-nondirectory ( car ipkg-default) ))
286
+ (file-name-nondirectory ipkg-default))
283
287
(read-file-name " Package file to install: " nil nil nil t ))))
284
288
(idris-ipkg-command ipkg-file 'install ))
285
289
286
290
(defun idris-ipkg-clean (ipkg-file )
287
291
(interactive (list
288
- (if-let ((ipkg-default (idris-find-file-upwards " ipkg" )))
292
+ (if-let ((ipkg-default (idris-find-ipkg-file )))
289
293
(read-file-name " Package file to clean: "
290
- (file-name-directory ( car ipkg-default) )
291
- ( car ipkg-default)
294
+ (file-name-directory ipkg-default)
295
+ ipkg-default
292
296
t
293
- (file-name-nondirectory ( car ipkg-default) ))
297
+ (file-name-nondirectory ipkg-default))
294
298
(read-file-name " Package file to clean: " nil nil nil t ))))
295
299
(idris-ipkg-command ipkg-file 'clean ))
296
300
@@ -307,14 +311,10 @@ arguments."
307
311
(file-name-directory basename))))
308
312
309
313
(defun idris-ipkg-find-src-dir (&optional ipkg-file )
310
- (if-let ((found (or (and ipkg-file (list ipkg-file))
311
- (idris-find-file-upwards " ipkg" ))))
312
- (progn
313
- (setq ipkg-file (car found))
314
- ; ; Now ipkg-file contains the path to the package
315
- (with-temp-buffer
316
- (insert-file-contents ipkg-file)
317
- (idris-ipkg-buffer-src-dir ipkg-file)))))
314
+ (if-let ((found (or ipkg-file (idris-find-ipkg-file))))
315
+ (with-temp-buffer
316
+ (insert-file-contents found)
317
+ (idris-ipkg-buffer-src-dir found))))
318
318
319
319
(defun idris-ipkg-buffer-cmdline-opts ()
320
320
(save-excursion
@@ -326,14 +326,10 @@ arguments."
326
326
" " )))
327
327
328
328
(defun idris-ipkg-find-cmdline-opts (&optional ipkg-file )
329
- (if-let ((found (or (and ipkg-file (list ipkg-file))
330
- (idris-find-file-upwards " ipkg" ))))
331
- (progn
332
- (setq ipkg-file (car found))
333
- ; ; Now ipkg-file contains the path to the package
334
- (with-temp-buffer
335
- (insert-file-contents ipkg-file)
336
- (idris-ipkg-buffer-cmdline-opts)))))
329
+ (if-let ((found (or ipkg-file (idris-find-ipkg-file))))
330
+ (with-temp-buffer
331
+ (insert-file-contents found)
332
+ (idris-ipkg-buffer-cmdline-opts))))
337
333
338
334
(defun idris-ipkg-flags-for-current-buffer ()
339
335
" Extract the command line options field from the current .ipkg buffer."
@@ -343,7 +339,7 @@ arguments."
343
339
344
340
(defun idris-ipkg-pkgs-for-current-buffer ()
345
341
" Find the explicit list of packages for the current .ipkg buffer."
346
- (if-let ((file (idris-find-file-upwards " ipkg" )))
342
+ (if-let ((file (idris-find-ipkg-file )))
347
343
(with-temp-buffer
348
344
(let ((pkgs nil ))
349
345
(cl-flet
@@ -352,7 +348,7 @@ arguments."
352
348
(let ((beg (match-beginning 0 ))
353
349
(end (match-end 0 )))
354
350
(push (buffer-substring-no-properties beg end) pkgs))))
355
- (insert-file-contents ( car file) )
351
+ (insert-file-contents file)
356
352
(goto-char (point-min ))
357
353
(when (re-search-forward " ^\\ s-*pkgs\\ s-*=\\ s-*" nil t )
358
354
(cl-loop initially (get-pkg)
0 commit comments