Skip to content

Commit

Permalink
feat(init/source): Convert to just Eask filename
Browse files Browse the repository at this point in the history
This happens when only one file is converted
  • Loading branch information
jcs090218 committed Sep 27, 2023
1 parent 9d5b1ad commit d4b5231
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lisp/init/source.el
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@
(eask-with-verbosity 'debug
(cond ((not (string-suffix-p ".el" file))
(eask-debug "✗ Invalid elisp filename, the file should end with `.el`"))
((file-exists-p new-filename)
(eask-debug "✗ The file `%s` already presented" new-file))
(t
(when pkg-desc
(with-current-buffer (find-file new-filename)
(erase-buffer)
(goto-char (point-min))

(let* ((eask-package-desc pkg-desc)
Expand Down Expand Up @@ -73,7 +72,7 @@
(save-buffer))
(setq converted t)))))
(if converted "done ✓" "skipped ✗"))
converted))
(when converted new-filename)))

(eask-start
(let* ((patterns (eask-args))
Expand All @@ -83,16 +82,19 @@
(files (cl-remove-if-not (lambda (file)
(string-suffix-p ".el" (file-name-nondirectory file)))
files))
(converted 0))
(converted-files))
(cond
;; Files found, do the action!
(files
(dolist (file files)
(when (eask--convert-source file)
(cl-incf converted)))
(when-let ((new-filename (eask--convert-source file)))
(push new-filename converted-files)))
;; Automatically rename file into Eask file when only one file is converted!
(when (= (length converted-files) 1)
(rename-file (car converted-files) "Eask" t))
(eask-msg "")
(eask-info "(Total of %s elisp file%s converted)" converted
(eask--sinr converted "" "s")))
(eask-info "(Total of %s elisp file%s converted)" (length converted-files)
(eask--sinr converted-files "" "s")))
;; Pattern defined, but no file found!
(patterns
(eask-info "(No files match wildcard: %s)"
Expand Down

0 comments on commit d4b5231

Please sign in to comment.