Skip to content

Commit afa99a3

Browse files
committed
Simplify by always loading file with absolute path and avoid extra switching working directory
1 parent f1f1538 commit afa99a3

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

idris-commands.el

+5-17
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
;; some modules, returning () instead. Remove this (and the
137137
;; surrounding (if fc)) after Idris 0.9.17, which contains a fix.
138138
(idris-update-loaded-region
139-
`((:filename ,(cdr (idris-filename-to-load)))
139+
`((:filename ,(idris-filename-to-load))
140140
(:start 1 1)
141141
,`(:end ,(idris-get-line-num (point-max)) 1)))))
142142

@@ -168,14 +168,7 @@
168168
(defun idris-filename-to-load ()
169169
"Compute the working directory and filename to load in Idris.
170170
Returning these as a cons."
171-
(let* ((fn (buffer-file-name))
172-
(ipkg-srcdir (idris-ipkg-find-src-dir))
173-
(srcdir (or ipkg-srcdir (file-name-directory fn))))
174-
(when (and ;; check that srcdir is prefix of filename - then load relative
175-
(> (length fn) (length srcdir))
176-
(string= (substring fn 0 (length srcdir)) srcdir))
177-
(setq fn (file-relative-name fn srcdir)))
178-
(cons srcdir fn)))
171+
(buffer-file-name))
179172

180173
(defun idris-load-file (&optional set-line)
181174
"Pass the current buffer's file to the inferior Idris process.
@@ -201,12 +194,9 @@ A prefix argument SET-LINE forces loading but only up to the current line."
201194
(with-current-buffer idris-notes-buffer-name
202195
(let ((inhibit-read-only t)) (erase-buffer))))
203196
;; Actually do the loading
204-
(let* ((dir-and-fn (idris-filename-to-load))
205-
(fn (cdr dir-and-fn))
206-
(srcdir (car dir-and-fn))
197+
(let ((fn (idris-filename-to-load))
207198
(idris-semantic-source-highlighting (idris-buffer-semantic-source-highlighting)))
208199
(setq idris-currently-loaded-buffer nil)
209-
(idris-switch-working-directory srcdir)
210200
(idris-delete-ibc t) ;; delete the ibc to avoid interfering with partial loads
211201
(idris-toggle-semantic-source-highlighting)
212202
(idris-eval-async
@@ -266,11 +256,9 @@ This sets the load position to point, if there is one."
266256
(when (and idris-load-to-here
267257
(< (marker-position idris-load-to-here) (point)))
268258
(idris-load-to (point)))
269-
(let* ((dir-and-fn (idris-filename-to-load))
270-
(fn (cdr dir-and-fn))
271-
(srcdir (car dir-and-fn)))
259+
(let ((fn (idris-filename-to-load)))
272260
(setq idris-currently-loaded-buffer nil)
273-
(idris-switch-working-directory srcdir)
261+
;; (idris-switch-working-directory srcdir)
274262
(let ((result
275263
(idris-eval
276264
(if idris-load-to-here

0 commit comments

Comments
 (0)