Skip to content

Commit 2f5a34e

Browse files
committed
Simplify idris-load-file
1 parent 47767fa commit 2f5a34e

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

idris-commands.el

+13-16
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ A prefix argument SET-LINE forces loading but only up to the current line."
180180
(idris-load-to (point))
181181
(idris-make-dirty))
182182
(when (and set-line (= set-line 16)) (idris-no-load-to))
183-
(if (buffer-file-name)
183+
(if-let ((fn (idris-filename-to-load)))
184184
(when (idris-current-buffer-dirty-p)
185185
(when idris-prover-currently-proving
186186
(if (y-or-n-p (format "%s is open in the prover. Abandon and load? "
@@ -194,8 +194,7 @@ A prefix argument SET-LINE forces loading but only up to the current line."
194194
(with-current-buffer idris-notes-buffer-name
195195
(let ((inhibit-read-only t)) (erase-buffer))))
196196
;; Actually do the loading
197-
(let ((fn (idris-filename-to-load))
198-
(idris-semantic-source-highlighting (idris-buffer-semantic-source-highlighting)))
197+
(let ((idris-semantic-source-highlighting (idris-buffer-semantic-source-highlighting)))
199198
(setq idris-currently-loaded-buffer nil)
200199
(idris-delete-ibc t) ;; delete the ibc to avoid interfering with partial loads
201200
(idris-toggle-semantic-source-highlighting)
@@ -250,24 +249,22 @@ A prefix argument SET-LINE forces loading but only up to the current line."
250249
This sets the load position to point, if there is one."
251250
(save-buffer)
252251
(idris-ensure-process-and-repl-buffer)
253-
(if (buffer-file-name)
252+
(if-let ((fn (idris-filename-to-load)))
254253
(unless (idris-position-loaded-p (point))
255254
(idris-warning-reset-all)
256255
(when (and idris-load-to-here
257256
(< (marker-position idris-load-to-here) (point)))
258257
(idris-load-to (point)))
259-
(let ((fn (idris-filename-to-load)))
260-
(setq idris-currently-loaded-buffer nil)
261-
;; (idris-switch-working-directory srcdir)
262-
(let ((result
263-
(idris-eval
264-
(if idris-load-to-here
265-
`(:load-file ,fn ,(idris-get-line-num idris-load-to-here))
266-
`(:load-file ,fn)))))
267-
(idris-update-options-cache)
268-
(setq idris-currently-loaded-buffer (current-buffer))
269-
(idris-make-clean)
270-
(idris-update-loaded-region (car result)))))
258+
(setq idris-currently-loaded-buffer nil)
259+
(let ((result
260+
(idris-eval
261+
(if idris-load-to-here
262+
`(:load-file ,fn ,(idris-get-line-num idris-load-to-here))
263+
`(:load-file ,fn)))))
264+
(idris-update-options-cache)
265+
(setq idris-currently-loaded-buffer (current-buffer))
266+
(idris-make-clean)
267+
(idris-update-loaded-region (car result))))
271268
(error "Cannot find file for current buffer")))
272269

273270

0 commit comments

Comments
 (0)