Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 023bf79

Browse files
committed
Improve the load file's content function
1 parent aaad6fe commit 023bf79

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

psci.el

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,12 @@
148148
"The default file referencing the purescript modules to load at psci startup.")
149149

150150
(defun psci/--file-content (filename)
151-
"Load the FILENAME's content as a string."
152-
(with-temp-buffer
153-
(insert-file-contents filename)
154-
(buffer-substring-no-properties (point-min) (point-max))))
151+
"Load the FILENAME's content as a string.
152+
When FILENAME is nil or not a real file, returns nil."
153+
(when (and filename (file-exists-p filename))
154+
(with-temp-buffer
155+
(insert-file-contents filename)
156+
(buffer-substring-no-properties (point-min) (point-max)))))
155157

156158
(defun psci/--symbol (sym n)
157159
"Compute the repetition of a symbol SYM N times as a string."

0 commit comments

Comments
 (0)