Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
* fix(lisp): Let buttercup tests handle exit code themselves ([#385](../../pull/385))
* fix(lisp): Set up paths regardless of the working environment ([#386](../../pull/386))
* feat(cmds): Move `el2org` to docs subcommand ([#388](../../pull/388))
* fix(lisp): Report error only inside the command's execution ([#389](../../pull/389))

## 0.12.x
> Released Dec 02, 2025
Expand Down
36 changes: 24 additions & 12 deletions lisp/_prepare.el
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,18 @@ will return `lint/checkdoc' with a dash between two subcommands."
version)))

(defun eask-command-p (commands)
"Return t if COMMANDS is the current command."
"Return t when the current command matches any entry in the COMMANDS list."
(member (eask-command) (eask-listify commands)))

(defun eask-special-p ()
"Return t if the command that can be run without Eask-file existence.

These commands will first respect the current workspace. If the current
workspace has no valid Eask-file; it will load global workspace instead."
workspace has no valid Eask-file; it will load the Eask-file form the global
workspace instead.

If there is no valid Eask-file presented; the execution continues without
printing the missing Eask-file message."
(eask-command-p '("init" "init/source" "init/cask" "init/eldev" "init/keg"
"create/package" "create/elpa" "create/el-project"
"bump" "cat" "keywords" "repl"
Expand Down Expand Up @@ -255,6 +259,14 @@ the `eask-start' execution.")
;;
;;; Util

(defmacro eask-add-hook (hooks &rest body)
"The eye candy for the function `add-hook'."
(declare (indent 1))
`(cond ((listp ,hooks)
(dolist (hook ,hooks)
(add-hook hook (lambda (&optional arg0 arg1 arg2 &rest args) ,@body))))
(t (add-hook ,hooks (lambda (&optional arg0 arg1 arg2 &rest args) ,@body)))))

(defmacro eask-defvc< (version &rest body)
"Define scope if Emacs version is below VERSION.

Expand Down Expand Up @@ -484,7 +496,7 @@ You can pass BUFFER-OR-NAME to replace current buffer."
(line-end-position))))
;; The variable `line' can contains format specifier, avoid it with `%s'!
(cond ((string-match-p "[: ][Ee]rror: " line)
(eask-error "%s" line))
(eask-ignore-errors (eask-error "%s" line)))
((string-match-p "[: ][Ww]arning: " line)
(eask-warn "%s" line))
(t
Expand Down Expand Up @@ -2032,6 +2044,7 @@ The argument ARGS is passed from the function `eask--error'."
;; Handle https://github.com/emacs-eask/cli/issues/11.
(unless (string-prefix-p "Can't find library " (car args))
(setq eask--has-error-p t)))
;; Flag the error normally.
(t
(setq eask--has-error-p t))) ; Just a record.

Expand Down Expand Up @@ -2092,15 +2105,14 @@ Arguments FNC and ARGS are used for advice `:around'."
(write-region (with-current-buffer ,buffer (buffer-string)) nil
(expand-file-name ,file log-dir)))))

(add-hook 'kill-emacs-hook ; Write log files
(lambda (&rest _)
(when eask-log-file
(let ((log-dir (expand-file-name eask-log-path eask-file-root)))
(make-directory log-dir t)
(eask--log-write-buffer "*Messages*" "messages.log")
(eask--log-write-buffer "*Warnings*" "warnings.log")
(eask--log-write-buffer "*Backtrace*" "backtrace.log")
(eask--log-write-buffer "*Compile-Log*" "compile-log.log")))))
(eask-add-hook '( kill-emacs-hook)
(when eask-log-file ; Write log files
(let ((log-dir (expand-file-name eask-log-path eask-file-root)))
(make-directory log-dir t)
(eask--log-write-buffer "*Messages*" "messages.log")
(eask--log-write-buffer "*Warnings*" "warnings.log")
(eask--log-write-buffer "*Backtrace*" "backtrace.log")
(eask--log-write-buffer "*Compile-Log*" "compile-log.log"))))

;;
;;; File
Expand Down
47 changes: 21 additions & 26 deletions lisp/core/compile.el
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,14 @@
(locate-dominating-file dir "_prepare.el"))
nil t))

;;
;;; Flags

(advice-add #'eask-allow-error-p :override #'eask-always)

;;
;;; Handle options

(add-hook 'eask-before-command-hook
(lambda ()
(when (eask-strict-p)
(setq byte-compile-error-on-warn t))
(when (eask-reach-verbosity-p 'debug)
(setq byte-compile-verbose t))))
(eask-add-hook '( eask-before-command-hook)
(when (eask-strict-p)
(setq byte-compile-error-on-warn t))
(when (eask-reach-verbosity-p 'debug)
(setq byte-compile-verbose t)))

;;
;;; Core
Expand Down Expand Up @@ -98,21 +92,22 @@ The CMD is the command to start a new Emacs session."

(defun eask-compile--byte-compile-file (filename)
"Byte compile FILENAME."
;; *Compile-Log* does not kill itself. Make sure it's clean before we do
;; next byte-compile task.
(ignore-errors (kill-buffer byte-compile-log-buffer))
(let* ((filename (expand-file-name filename))
(result))
(eask-with-progress
(unless byte-compile-verbose (format "Compiling %s... " filename))
(eask-with-verbosity 'debug
(setq result (if (eask-clean-p)
(eask-compile--byte-compile-file-external filename)
(byte-compile-file filename))
result (eq result t)))
(unless byte-compile-verbose (if result "done ✓" "skipped ✗")))
(eask-compile--print-log)
result))
(eask-ignore-errors
;; *Compile-Log* does not kill itself. Make sure it's clean before we do
;; next byte-compile task.
(ignore-errors (kill-buffer byte-compile-log-buffer))
(let* ((filename (expand-file-name filename))
(result))
(eask-with-progress
(unless byte-compile-verbose (format "Compiling %s... " filename))
(eask-with-verbosity 'debug
(setq result (if (eask-clean-p)
(eask-compile--byte-compile-file-external filename)
(byte-compile-file filename))
result (eq result t)))
(unless byte-compile-verbose (if result "done ✓" "skipped ✗")))
(eask-compile--print-log)
result)))

(defun eask-compile--files (files)
"Compile sequence of FILES."
Expand Down
7 changes: 1 addition & 6 deletions lisp/format/elfmt.el
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@

(declare-function elfmt-buffer "ext:elisp-autofmt.el")

;;
;;; Flags

(advice-add #'eask-allow-error-p :override #'eask-always)

;;
;;; Core

Expand All @@ -40,7 +35,7 @@
(let* ((filename (expand-file-name filename))
(file (eask-root-del filename)))
(with-current-buffer (find-file filename)
(elfmt-buffer)
(eask-ignore-errors (elfmt-buffer))
(save-buffer)
(kill-buffer))))

Expand Down
4 changes: 1 addition & 3 deletions lisp/format/elisp-autofmt.el
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@

(eask-command-check "29.1")

(advice-add #'eask-allow-error-p :override #'eask-always)

;;
;;; Core

Expand All @@ -42,7 +40,7 @@
(let* ((filename (expand-file-name filename))
(file (eask-root-del filename)))
(with-current-buffer (find-file filename)
(elisp-autofmt-buffer)
(eask-ignore-errors (elisp-autofmt-buffer))
(save-buffer)
(kill-buffer))))

Expand Down
7 changes: 1 addition & 6 deletions lisp/lint/checkdoc.el
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@

(declare-function checkdoc-buffer-label "ext:checkdoc.el")

;;
;;; Flags

(advice-add #'eask-allow-error-p :override #'eask-always)

;;
;;; Core

Expand Down Expand Up @@ -59,7 +54,7 @@ be assigned to variable `checkdoc-create-error-function'."
(eask-lint-checkdoc--errors))
(eask-lint-first-newline)
(eask-msg "`%s` with checkdoc (%s)" (ansi-green file) checkdoc-version)
(checkdoc-file filename)
(eask-ignore-errors (checkdoc-file filename))
(unless eask-lint-checkdoc--errors (eask-msg "No issues found"))))

(eask-start
Expand Down
16 changes: 7 additions & 9 deletions lisp/lint/declare.el
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@

(defvar check-declare-warning-buffer)

;;
;;; Flags

(advice-add #'eask-allow-error-p :override #'eask-always)

;;
;;; Core

Expand All @@ -40,10 +35,13 @@
(eask-lint-first-newline)
(eask-msg "`%s` with check-declare" (ansi-green file))
(setq errors (eask--silent (check-declare-file filename)))
(if errors
(with-current-buffer check-declare-warning-buffer
(eask-report (string-remove-prefix " \n" (buffer-string))))
(eask-msg "No issues found"))))
(eask-ignore-errors ; Continue checking.
(if errors
(with-current-buffer check-declare-warning-buffer
(eask-report
(string-remove-prefix " \n"
(buffer-string))))
(eask-msg "No issues found")))))

(eask-start
(require 'check-declare)
Expand Down
8 changes: 2 additions & 6 deletions lisp/lint/elint.el
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@

(declare-function elint-get-log-buffer "ext:elsa.el")

;;
;;; Flags

(advice-add #'eask-allow-error-p :override #'eask-always)

;;
;;; Core

Expand All @@ -39,7 +34,8 @@
(noninteractive))
(eask-lint-first-newline)
(eask-msg "`%s` with elint" (ansi-green file))
(eask-with-verbosity 'debug (elint-file filename))
(eask-with-verbosity 'debug
(eask-ignore-errors (elint-file filename)))
(let ((log-buffer (elint-get-log-buffer)))
(eask-print-log-buffer log-buffer)
(kill-buffer log-buffer))))
Expand Down
20 changes: 8 additions & 12 deletions lisp/lint/elisp-lint.el
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@

(declare-function elisp-lint-file "ext:elsa.el")

;;
;;; Flags

(advice-add #'eask-allow-error-p :override #'eask-always)

;;
;;; Core

Expand All @@ -42,13 +37,14 @@
success)
(eask-msg "")
(eask-msg "`%s` with elisp-lint (%s)" (ansi-green file) eask-lint-elisp-lint--version)
(eask-with-verbosity 'debug
(setq success (elisp-lint-file filename)))
;; Report result!
(cond (success
(eask-msg "No issues found"))
((eask-strict-p)
(eask-error "Linting failed")))))
(eask-ignore-errors
(eask-with-verbosity 'debug
(setq success (elisp-lint-file filename)))
;; Report result!
(cond (success
(eask-msg "No issues found"))
((eask-strict-p)
(eask-error "Linting failed"))))))

(eask-start
;; Preparation
Expand Down
28 changes: 12 additions & 16 deletions lisp/lint/elsa.el
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@
(declare-function elsa-analyse-file "ext:elsa.el")
(declare-function --each "ext:dash.el")

;;
;;; Flags

(advice-add #'eask-allow-error-p :override #'eask-always)

;;
;;; Core

Expand All @@ -48,17 +43,18 @@
errors)
(eask-msg "")
(eask-msg "`%s` with elsa (%s)" (ansi-green file) eask-lint-elsa--version)
(eask-with-verbosity 'debug
(setq errors (oref (elsa-analyse-file filename elsa-global-state) errors)))
(if errors
(--each (reverse errors)
(let ((line (string-trim (concat file ":" (elsa-message-format it)))))
(cond ((string-match-p "[: ][Ee]rror:" line)
(eask-error "%s" line))
((string-match-p "[: ][Ww]arning:" line)
(eask-warn "%s" line))
(t (eask-log "%s" line)))))
(eask-msg "No issues found"))))
(eask-ignore-errors
(eask-with-verbosity 'debug
(setq errors (oref (elsa-analyse-file filename elsa-global-state) errors)))
(if errors
(--each (reverse errors)
(let ((line (string-trim (concat file ":" (elsa-message-format it)))))
(cond ((string-match-p "[: ][Ee]rror:" line)
(eask-error "%s" line))
((string-match-p "[: ][Ww]arning:" line)
(eask-warn "%s" line))
(t (eask-log "%s" line)))))
(eask-msg "No issues found")))))

(eask-start
;; Preparation
Expand Down
10 changes: 3 additions & 7 deletions lisp/lint/indent.el
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@
(locate-dominating-file dir "_prepare.el"))
nil t))

;;
;;; Flags

(advice-add #'eask-allow-error-p :override #'eask-always)

;;
;;; Core

Expand Down Expand Up @@ -61,8 +56,9 @@
(column (nth 1 info))
(current (eask-with-buffer
(eask--goto-line line) (current-indentation))))
(eask-report "%s:%s: Expected indentation is %s but found %s"
(buffer-name) line column current)))
(eask-ignore-errors
(eask-report "%s:%s: Expected indentation is %s but found %s"
(buffer-name) line column current))))
(eask-log "No mismatch indentation found"))))

(eask-start
Expand Down
14 changes: 6 additions & 8 deletions lisp/lint/keywords.el
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@
(locate-dominating-file dir "_prepare.el"))
nil t))

;;
;;; Flags

(advice-add #'eask-allow-error-p :override #'eask-always)

;;
;;; Core

Expand All @@ -38,10 +33,12 @@
(file (eask-root-del eask-package-file)))
(cond
((not eask-package-file)
(eask-report "Can't lint keywords without the package-file specified")
(eask-ignore-errors
(eask-report "Can't lint keywords without the package-file specified"))
(eask-help "lint/keywords-file"))
((not keywords)
(eask-report "Keywords header seems to be missing in the `%s' file" file)
(eask-ignore-errors
(eask-report "Keywords header seems to be missing in the `%s' file" file))
(eask-help "lint/keywords-header"))
(t
(eask-lint-first-newline)
Expand All @@ -50,7 +47,8 @@
(progn
(eask-msg "")
(eask-info "(No issues found.)"))
(eask-report "Missing a standard keyword, consider adding one to the Keywords header!")
(eask-ignore-errors
(eask-report "Missing a standard keyword, consider adding one to the Keywords header!"))
(eask-help "lint/keywords"))))))

;;; lint/keywords.el ends here
Loading