Skip to content

Commit

Permalink
style(lisp): Fix naming convetion
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Feb 20, 2024
1 parent c2b9ce6 commit dcd32bd
Show file tree
Hide file tree
Showing 56 changed files with 363 additions and 362 deletions.
2 changes: 1 addition & 1 deletion cmds/checker/check-eask.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"use strict";

exports.command = ['check-eask [files..]'];
exports.desc = 'Run eask checker';
exports.desc = 'Run Eask checker';
exports.builder = yargs => yargs
.positional(
'[files..]', {
Expand Down
54 changes: 27 additions & 27 deletions lisp/checker/check-eask.el
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@
nil t))

;; Plain Text
(defvar eask--checker-log nil)
(defvar eask-checker--log nil)
;; JSON format
(defvar eask--checker-warnings nil)
(defvar eask--checker-errors nil)
(defvar eask-checker--warnings nil)
(defvar eask-checker--errors nil)

(defun eask--pretty-json (json)
(defun eask-checker--pretty-json (json)
"Return pretty JSON."
(with-temp-buffer (insert json) (json-pretty-print-buffer) (buffer-string)))

(defun eask--load-buffer ()
(defun eask-checker--load-buffer ()
"Return the current file loading session."
(car (cl-remove-if-not
(lambda (elm) (string-prefix-p " *load*-" (buffer-name elm))) (buffer-list))))

(defun eask--write-json-format (level msg)
(defun eask-checker--write-json-format (level msg)
"Prepare log for JSON format.
For arguments LEVEL and MSG, please see function `eask--write-log' for more
For arguments LEVEL and MSG, please see function `eask-checker--write-log' for more
information."
(let* ((bounds (bounds-of-thing-at-point 'sexp))
(filename (or load-file-name eask-file))
Expand All @@ -63,13 +63,13 @@ information."
(filename . ,filename)
(message . ,msg))
(cl-case level
(`error eask--checker-errors)
(`warn eask--checker-warnings)))))
(`error eask-checker--errors)
(`warn eask-checker--warnings)))))

(defun eask--write-plain-text (level msg)
(defun eask-checker--write-plain-text (level msg)
"Prepare log for plain text format.
For arguments LEVEL and MSG, please see function `eask--write-log' for more
For arguments LEVEL and MSG, please see function `eask-checker--write-log' for more
information."
(let* ((level-string (cl-case level
(`error "Error")
Expand All @@ -80,20 +80,20 @@ information."
(if load-file-name (current-column) 0)
level-string
msg)))
(push (ansi-color-filter-apply log) eask--checker-log)))
(push (ansi-color-filter-apply log) eask-checker--log)))

(defun eask--write-log (level msg)
(defun eask-checker--write-log (level msg)
"Write the log.
Argument LEVEL and MSG are data from the debug log signal."
(unless (string= " *temp*" (buffer-name)) ; avoid error from `package-file' directive
(with-current-buffer (or (eask--load-buffer) (buffer-name))
(with-current-buffer (or (eask-checker--load-buffer) (buffer-name))
(funcall
(cond ((eask-json-p) #'eask--write-json-format)
(t #'eask--write-plain-text))
(cond ((eask-json-p) #'eask-checker--write-json-format)
(t #'eask-checker--write-plain-text))
level msg))))

(defun eask--check-file (files)
(defun eask-checker--check-file (files)
"Lint list of Eask FILES."
(let (checked-files content)
;; Linting
Expand All @@ -105,19 +105,19 @@ Argument LEVEL and MSG are data from the debug log signal."
;; Print result
(eask-msg "")
(cond ((and (eask-json-p) ; JSON format
(or eask--checker-warnings eask--checker-errors))
(or eask-checker--warnings eask-checker--errors))
(setq content
(eask--pretty-json (json-encode
`((warnings . ,eask--checker-warnings)
(errors . ,eask--checker-errors)))))
(eask-checker--pretty-json (json-encode
`((warnings . ,eask-checker--warnings)
(errors . ,eask-checker--errors)))))
(eask-msg content))
(eask--checker-log ; Plain text
(eask-checker--log ; Plain text
(setq content
(with-temp-buffer
(dolist (msg (reverse eask--checker-log))
(dolist (msg (reverse eask-checker--log))
(insert msg "\n"))
(buffer-string)))
(mapc #'eask-msg (reverse eask--checker-log)))
(mapc #'eask-msg (reverse eask-checker--log)))
(t
(eask-info "(Checked %s file%s)"
(length checked-files)
Expand All @@ -131,8 +131,8 @@ Argument LEVEL and MSG are data from the debug log signal."
;;; Program Entry

;; Preparation
(add-hook 'eask-on-error-hook #'eask--write-log)
(add-hook 'eask-on-warning-hook #'eask--write-log)
(add-hook 'eask-on-error-hook #'eask-checker--write-log)
(add-hook 'eask-on-warning-hook #'eask-checker--write-log)

(let* ((default-directory (cond ((eask-global-p) eask-homedir)
((eask-config-p) user-emacs-directory)
Expand All @@ -144,7 +144,7 @@ Argument LEVEL and MSG are data from the debug log signal."
(cond
;; Files found, do the action!
(files
(eask--check-file files))
(eask-checker--check-file files))
;; Pattern defined, but no file found!
(patterns
(eask-info "(No files match wildcard: %s)"
Expand Down
20 changes: 10 additions & 10 deletions lisp/clean/all.el
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,31 @@
(defvar eask-no-cleaning-operation-p nil
"Set to non-nil if there is no cleaning operation done.")

(defconst eask--clean-tasks-total 6
(defconst eask-clean-all--tasks-total 6
"Count cleaning task.")

(defvar eask--clean-tasks-count 0
(defvar eask-clean-all--tasks-count 0
"Count cleaning task.")

(defvar eask--clean-tasks-cleaned 0
(defvar eask-clean-all--tasks-cleaned 0
"Total cleaned tasks.")

(defmacro eask--clean-section (title &rest body)
"Print clean up TITLE and execute BODY."
(declare (indent 1))
`(let (eask-no-cleaning-operation-p)
(cl-incf eask--clean-tasks-count)
(cl-incf eask-clean-all--tasks-count)
(eask-with-progress
(concat (format " - [%s/%s] " eask--clean-tasks-count eask--clean-tasks-total)
(concat (format " - [%s/%s] " eask-clean-all--tasks-count eask-clean-all--tasks-total)
(format "%s... " ,title))
(eask-with-verbosity 'debug ,@body)
(if eask-no-cleaning-operation-p
"skipped ✗"
(cl-incf eask--clean-tasks-cleaned)
(cl-incf eask-clean-all--tasks-cleaned)
"done ✓"))))

(eask-start
(eask-msg "Applying %s cleaning tasks..." eask--clean-tasks-total)
(eask-msg "Applying %s cleaning tasks..." eask-clean-all--tasks-total)
(eask-msg "")
(eask--clean-section (format "Cleaning %s" (ansi-green "workspace"))
(eask-call "clean/workspace"))
Expand All @@ -57,8 +57,8 @@
(eask-call "clean/log-file"))
(eask-msg "")
(eask-info "(Total of %s task%s cleaned, %s skipped)"
eask--clean-tasks-cleaned
(eask--sinr eask--clean-tasks-cleaned "" "s")
(- eask--clean-tasks-count eask--clean-tasks-cleaned)))
eask-clean-all--tasks-cleaned
(eask--sinr eask-clean-all--tasks-cleaned "" "s")
(- eask-clean-all--tasks-count eask-clean-all--tasks-cleaned)))

;;; clean/all.el ends here
6 changes: 3 additions & 3 deletions lisp/clean/dist.el
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@

(eask-load "core/package") ; load dist path

(defun eask--clean-dist (path)
(defun eask-clean-dist (path)
"Clean up dist PATH."
(let* ((name (eask-guess-package-name))
(version (eask-package-version))
(readme (expand-file-name (format "%s-readme.txt" name) path))
(entry (expand-file-name (format "%s-%s.entry" name version) path))
(packaged (eask-packaged-file))
(packaged (eask-package-packaged-file))
(deleted 0)
(delete-dir))
(when (eask-delete-file readme) (cl-incf deleted))
Expand All @@ -49,7 +49,7 @@
(let* ((eask-dist-path (or (eask-args 0) eask-dist-path))
(eask-dist-path (expand-file-name eask-dist-path)))
(if (file-directory-p eask-dist-path)
(eask--clean-dist eask-dist-path)
(eask-clean-dist eask-dist-path)
(eask-info "(No dist folder needs to be cleaned)" eask-dist-path)
(setq eask-no-cleaning-operation-p t))))

Expand Down
4 changes: 2 additions & 2 deletions lisp/clean/log-file.el
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
(locate-dominating-file dir "_prepare.el"))
nil t))

(defun eask--clean-log (path)
(defun eask-clean-log-file (path)
"Clean up .log PATH."
(let ((log-files '("messages.log"
"warnings.log"
Expand All @@ -41,7 +41,7 @@
(eask-start
(let ((log-dir (expand-file-name eask-log-path eask-file-root)))
(if (file-directory-p log-dir)
(eask--clean-log log-dir)
(eask-clean-log-file log-dir)
(eask-info "(No log file found in workspace)")
(setq eask-no-cleaning-operation-p t))))

Expand Down
25 changes: 13 additions & 12 deletions lisp/core/archives.el
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,43 @@
(locate-dominating-file dir "_prepare.el"))
nil t))

(defvar eask--length-name)
(defvar eask--length-url)
(defvar eask--length-priority)
(defvar eask-archive--length-name)
(defvar eask-archive--length-url)
(defvar eask-archive--length-priority)

(defun eask--print-archive (archive)
(defun eask-archive--print (archive)
"Print the ARCHIVE."
(let* ((name (car archive))
(url (cdr archive))
(priority (assoc name package-archive-priorities))
(priority (cdr priority)))
(eask-println
(concat " %-" eask--length-name "s %-" eask--length-url "s %-" eask--length-priority "s")
(concat " %-" eask-archive--length-name "s %-" eask-archive--length-url
"s %-" eask-archive--length-priority "s")
name (eask-2url url) (or priority 0))))

(defun eask--print-archive-alist (alist)
(defun eask-archive--print-alist (alist)
"Print the archvie ALIST."
(let* ((names (mapcar #'car alist))
(eask--length-name (eask-2str (eask-seq-str-max names)))
(eask-archive--length-name (eask-2str (eask-seq-str-max names)))
(urls (mapcar #'cdr alist))
(eask--length-url (eask-2str (eask-seq-str-max urls)))
(eask-archive--length-url (eask-2str (eask-seq-str-max urls)))
(priorities (mapcar #'cdr package-archive-priorities))
(eask--length-priority (eask-2str (eask-seq-str-max priorities))))
(mapc #'eask--print-archive alist)))
(eask-archive--length-priority (eask-2str (eask-seq-str-max priorities))))
(mapc #'eask-archive--print alist)))

(eask-start
(cond
((eask-all-p)
(eask-info "Available archives:")
(eask-msg "")
(eask--print-archive-alist eask-source-mapping)
(eask-archive--print-alist eask-source-mapping)
(eask-info "(Total of %s archive%s available)" (length eask-source-mapping)
(eask--sinr eask-source-mapping "" "s")))
(package-archives
(eask-info "In used archives:")
(eask-msg "")
(eask--print-archive-alist package-archives)
(eask-archive--print-alist package-archives)
(eask-info "(Total of %s archive%s listed)" (length package-archives)
(eask--sinr package-archives "" "s")))
(t
Expand Down
20 changes: 10 additions & 10 deletions lisp/core/bump.el
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@
(locate-dominating-file dir "_prepare.el"))
nil t))

(defun eask-bump-version--version (version index)
(defun eask-bump--version (version index)
"Bump VERSION with INDEX."
(let ((lst (if (stringp version) (version-to-list version) version)))
(setf (nth index lst) (cl-incf (nth index lst)))
(mapconcat #'eask-2str lst version-separator)))

(defun eask-bump-version--major-version (version)
(defun eask-bump--version-major-version (version)
"Bump VERSION major level."
(eask-bump-version--version version 0))
(eask-bump--version version 0))

(defun eask-bump-version--minor-version (version)
(defun eask-bump--version-minor-version (version)
"Bump VERSION minor level."
(eask-bump-version--version version 1))
(eask-bump--version version 1))

(defun eask-bump-version--patch-level (version)
(defun eask-bump--version-patch-level (version)
"Bump VERSION patch level."
(eask-bump-version--version version 2))
(eask-bump--version version 2))

(eask-start
(let ((package-file (or eask-package-file
Expand All @@ -58,11 +58,11 @@
(setq desc (package-buffer-info)))
(setq version (package-desc-version desc))
(when (member "major" levels)
(setq version (eask-bump-version--major-version version)))
(setq version (eask-bump--version-major-version version)))
(when (member "minor" levels)
(setq version (eask-bump-version--minor-version version)))
(setq version (eask-bump--version-minor-version version)))
(when (member "patch" levels)
(setq version (eask-bump-version--patch-level version)))
(setq version (eask-bump--version-patch-level version)))
(eask-msg "New version: %s" version)
(let (success)
(eask-with-progress
Expand Down
2 changes: 1 addition & 1 deletion lisp/core/eval.el
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
(if-let ((name (eask-argv 0)))
(eask-with-progress
(ansi-green "Exporting environment variables... ")
(eask--export-env)
(eask-exec-export-env)
(ansi-green "done ✓"))
(eask-info "(No expression found)")
(eask-help "core/eval")))
Expand Down
6 changes: 3 additions & 3 deletions lisp/core/exec-path.el
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@

(eask-load "core/load-path")

(defun eask--print-exec-path (path)
(defun eask-exec-path--print (path)
"Print out the PATH."
(eask-println "%s" path))

(eask-start
(eask-pkg-init)
(let* ((patterns (eask-args))
(exec-path (if patterns
(cl-remove-if-not #'eask--filter-path exec-path)
(cl-remove-if-not #'eask-load-path--filter exec-path)
exec-path)))
(eask-msg "")
(mapc #'eask--print-exec-path exec-path)
(mapc #'eask-exec-path--print exec-path)
(if (zerop (length exec-path))
(eask-info "(No exec-path found)")
(eask-info "(Total of %s exec-path)" (length exec-path)))))
Expand Down
16 changes: 8 additions & 8 deletions lisp/core/exec.el
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@
(locate-dominating-file dir "_prepare.el"))
nil t))

(defconst eask--exec-path-file (expand-file-name "exec-path" eask-homedir)
(defconst eask-exec--path-file (expand-file-name "exec-path" eask-homedir)
"Target file to export the variable `exec-path'.")

(defconst eask--load-path-file (expand-file-name "load-path" eask-homedir)
(defconst eask-load--path-file (expand-file-name "load-path" eask-homedir)
"Target file to export the variable `load-path'.")

(defun eask--export-env ()
(defun eask-exec-export-env ()
"Export environments."
(ignore-errors (delete-file eask--exec-path-file))
(ignore-errors (delete-file eask--load-path-file))
(ignore-errors (delete-file eask-exec--path-file))
(ignore-errors (delete-file eask-load--path-file))
(ignore-errors (make-directory eask-homedir t)) ; generate dir `~/.eask/'
(write-region (getenv "PATH") nil eask--exec-path-file)
(write-region (getenv "EMACSLOADPATH") nil eask--load-path-file))
(write-region (getenv "PATH") nil eask-exec--path-file)
(write-region (getenv "EMACSLOADPATH") nil eask-load--path-file))

(eask-start
(eask-defvc< 27 (eask-pkg-init)) ; XXX: remove this after we drop 26.x
Expand All @@ -40,7 +40,7 @@
(if (eask-argv 1)
(eask-with-progress
(ansi-green "Exporting environment variables... ")
(eask--export-env)
(eask-exec-export-env)
(ansi-green "done ✓"))
(eask-info "(No exeuction output)")
(eask-help "core/exec")))
Expand Down
Loading

0 comments on commit dcd32bd

Please sign in to comment.