Skip to content

Commit

Permalink
Simplify by always loading file with absolute path and avoid extra sw…
Browse files Browse the repository at this point in the history
…itching working directory
  • Loading branch information
keram committed Jun 22, 2024
1 parent f1f1538 commit afa99a3
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions idris-commands.el
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
;; some modules, returning () instead. Remove this (and the
;; surrounding (if fc)) after Idris 0.9.17, which contains a fix.
(idris-update-loaded-region
`((:filename ,(cdr (idris-filename-to-load)))
`((:filename ,(idris-filename-to-load))
(:start 1 1)
,`(:end ,(idris-get-line-num (point-max)) 1)))))

Expand Down Expand Up @@ -168,14 +168,7 @@
(defun idris-filename-to-load ()
"Compute the working directory and filename to load in Idris.
Returning these as a cons."
(let* ((fn (buffer-file-name))
(ipkg-srcdir (idris-ipkg-find-src-dir))
(srcdir (or ipkg-srcdir (file-name-directory fn))))
(when (and ;; check that srcdir is prefix of filename - then load relative
(> (length fn) (length srcdir))
(string= (substring fn 0 (length srcdir)) srcdir))
(setq fn (file-relative-name fn srcdir)))
(cons srcdir fn)))
(buffer-file-name))

(defun idris-load-file (&optional set-line)
"Pass the current buffer's file to the inferior Idris process.
Expand All @@ -201,12 +194,9 @@ A prefix argument SET-LINE forces loading but only up to the current line."
(with-current-buffer idris-notes-buffer-name
(let ((inhibit-read-only t)) (erase-buffer))))
;; Actually do the loading
(let* ((dir-and-fn (idris-filename-to-load))
(fn (cdr dir-and-fn))
(srcdir (car dir-and-fn))
(let ((fn (idris-filename-to-load))
(idris-semantic-source-highlighting (idris-buffer-semantic-source-highlighting)))
(setq idris-currently-loaded-buffer nil)
(idris-switch-working-directory srcdir)
(idris-delete-ibc t) ;; delete the ibc to avoid interfering with partial loads
(idris-toggle-semantic-source-highlighting)
(idris-eval-async
Expand Down Expand Up @@ -266,11 +256,9 @@ This sets the load position to point, if there is one."
(when (and idris-load-to-here
(< (marker-position idris-load-to-here) (point)))
(idris-load-to (point)))
(let* ((dir-and-fn (idris-filename-to-load))
(fn (cdr dir-and-fn))
(srcdir (car dir-and-fn)))
(let ((fn (idris-filename-to-load)))
(setq idris-currently-loaded-buffer nil)
(idris-switch-working-directory srcdir)
;; (idris-switch-working-directory srcdir)
(let ((result
(idris-eval
(if idris-load-to-here
Expand Down

0 comments on commit afa99a3

Please sign in to comment.