Skip to content

Commit

Permalink
While using %edit, provide better error message when EDITOR is unset (k…
Browse files Browse the repository at this point in the history
  • Loading branch information
digikar99 committed Jan 15, 2024
1 parent d92116f commit 5131f0f
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/command.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,18 @@
"Edit code with text editor specified by $EDITOR."
(declare (ignore args))
(let ((editor (uiop:getenv "EDITOR")))
(if (null filename)
(uiop:with-temporary-file
(:stream s :pathname p :type "lisp" :prefix "cl-repl-edit" :suffix "")
(setf filename (namestring p))
(message-from-magic "CL-REPL will make a temporary file named: ~a~%" filename)
(format s "#|-*- mode:lisp -*-|#~2%")
(close s)
(edit-file-and-read editor filename))
(edit-file-and-read editor filename))))
(cond ((null editor)
(message-from-magic "Please set the EDITOR environment variable and retry.~%You can also use~% (setf (uiop:getenv \"EDITOR\") \"editor/name/or/path\")~%to set the variable without restarting the REPL."))
((null filename)
(uiop:with-temporary-file
(:stream s :pathname p :type "lisp" :prefix "cl-repl-edit" :suffix "")
(setf filename (namestring p))
(message-from-magic "CL-REPL will make a temporary file named: ~a~%" filename)
(format s "#|-*- mode:lisp -*-|#~2%")
(close s)
(edit-file-and-read editor filename)))
(t
(edit-file-and-read editor filename)))))

(define-magic cd (&optional (dest (uiop:getenv "HOME")) &rest args)
"Change working directory."
Expand Down

0 comments on commit 5131f0f

Please sign in to comment.