Skip to content

Commit

Permalink
feat: Add I/O
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Jul 1, 2024
1 parent ace5f04 commit 43c81fb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Eask
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
(source 'jcs-elpa)

(depends-on "emacs" "26.1")
(depends-on "msgu")
(depends-on "s")
(depends-on "list-utils")

(setq network-security-level 'low) ; see https://github.com/jcs090218/setup-emacs-windows/issues/156#issuecomment-932956432
36 changes: 35 additions & 1 deletion elenv.el
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
;; Maintainer: Shen, Jen-Chieh <jcs090218@gmail.com>
;; URL: https://github.com/jcs-elpa/elenv
;; Version: 0.1.0
;; Package-Requires: ((emacs "26.1") (list-utils "0.4.6"))
;; Package-Requires: ((emacs "26.1") (msgu "0.1.0") (s "1.12.0") (list-utils "0.4.6"))
;; Keywords: maint

;; This file is not part of GNU Emacs.
Expand All @@ -33,6 +33,11 @@

;;; Code:

;;
;;; Compiler pacifier

(declare-function s-blank-str-p "ext:s.el")

;;
;;; OS

Expand Down Expand Up @@ -244,6 +249,35 @@ For argument REMOTE, see function `executable-find' description."
(push ,newelt ,seq)
(list-utils-insert-after-pos ,seq (max (1- (length ,seq)) 0) ,newelt)))

;;
;;; I/O

;;;###autoload
(defun elenv-file-contents (filename)
"Return FILENAME's contents."
(if (file-exists-p filename)
(with-temp-buffer (insert-file-contents filename) (buffer-string))
""))

;;;###autoload
(defun elenv-shell-execute (cmd &rest args)
"Return non-nil if CMD executed succesfully with ARGS."
(save-window-excursion
(msgu-silent
(= 0 (shell-command
(concat cmd " "
(mapconcat #'shell-quote-argument
(cl-remove-if #'s-blank-str-p args)
" ")))))))

;;;###autoload
(defun elenv-move-path (path dest)
"Move PATH to DEST."
(ignore-errors (make-directory dest t))
(elenv-shell-execute (if elenv-windows "move" "mv")
(unless elenv-windows "-f")
(expand-file-name path) (expand-file-name dest)))

;;
;;; Buffer

Expand Down

0 comments on commit 43c81fb

Please sign in to comment.