diff --git a/CHANGELOG.md b/CHANGELOG.md
index db1bc880..01747ba0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -26,6 +26,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
* fix: Don't pollute outer programs (#239)
* feat(generate/test): Add commands to setup test files (#243)
* feat: Add `docs` command (#245)
+* feat(cmds): Add `recompile` command (#254)
## 0.9.x
> Released Nov 17, 2023
diff --git a/cmds/core/compile.js b/cmds/core/compile.js
index 808696bf..c28abe37 100644
--- a/cmds/core/compile.js
+++ b/cmds/core/compile.js
@@ -18,7 +18,7 @@
"use strict";
exports.command = ['compile [names..]'];
-exports.desc = 'Byte compile all Emacs Lisp files in the package';
+exports.desc = "Byte-compile `.el' files";
exports.builder = yargs => yargs
.positional(
'[names..]', {
diff --git a/cmds/core/recompile.js b/cmds/core/recompile.js
new file mode 100644
index 00000000..7e056b3e
--- /dev/null
+++ b/cmds/core/recompile.js
@@ -0,0 +1,40 @@
+/**
+ * Copyright (C) 2024 the Eask authors.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+"use strict";
+
+exports.command = ['recompile [names..]'];
+exports.desc = "Byte-recompile `.el' files";
+exports.builder = yargs => yargs
+ .positional(
+ '[names..]', {
+ description: 'specify files to byte-compile',
+ type: 'array',
+ })
+ .options({
+ 'clean': {
+ description: 'clean byte-recompile files individually',
+ type: 'boolean',
+ group: TITLE_CMD_OPTION,
+ },
+ });
+
+exports.handler = async (argv) => {
+ await UTIL.e_call(argv, 'core/recompile'
+ , argv.names
+ , UTIL.def_flag(argv.clean, '--clean'));
+};
diff --git a/docs/content/Getting-Started/Basic-Usage/_index.en.md b/docs/content/Getting-Started/Basic-Usage/_index.en.md
index fcec8cbc..6ec1bfbc 100644
--- a/docs/content/Getting-Started/Basic-Usage/_index.en.md
+++ b/docs/content/Getting-Started/Basic-Usage/_index.en.md
@@ -35,10 +35,10 @@ Commands:
analyze [files..] Run Eask checker
archives List out all package archives [aliases: sources]
clean Delete various files produced during building
- compile [names..] Byte compile all Emacs Lisp files in the package
+ compile [names..] Byte-compile `.el' files
create Create a new elisp project
docker [args..] Launch specified Emacs version in a Docker container
- docs Build documentation [aliases: doc]
+ docs [names..] Build documentation [aliases: doc]
emacs [args..] Execute emacs with the appropriate environment
eval [form] Evaluate lisp form with a proper PATH
path [patterns..] Print the PATH (exec-path) from workspace [aliases: exec-path]
@@ -60,6 +60,7 @@ Commands:
package-directory Print path to package directory
package [destination] Build a package artifact, and put it into the given destination [aliases: pack]
recipe Suggest a recipe format
+ recompile [names..] Byte-recompile `.el' files
refresh Download package archives
reinstall [names..] Reinstall packages
run Run custom tasks
diff --git a/docs/content/Getting-Started/Basic-Usage/_index.zh-tw.md b/docs/content/Getting-Started/Basic-Usage/_index.zh-tw.md
index 71e1de71..ac7592a4 100644
--- a/docs/content/Getting-Started/Basic-Usage/_index.zh-tw.md
+++ b/docs/content/Getting-Started/Basic-Usage/_index.zh-tw.md
@@ -32,10 +32,10 @@ Commands:
analyze [files..] Run Eask checker
archives List out all package archives [aliases: sources]
clean Delete various files produced during building
- compile [names..] Byte compile all Emacs Lisp files in the package
+ compile [names..] Byte-compile `.el' files
create Create a new elisp project
docker [args..] Launch specified Emacs version in a Docker container
- docs Build documentation [aliases: doc]
+ docs [names..] Build documentation [aliases: doc]
emacs [args..] Execute emacs with the appropriate environment
eval [form] Evaluate lisp form with a proper PATH
path [patterns..] Print the PATH (exec-path) from workspace [aliases: exec-path]
@@ -57,6 +57,7 @@ Commands:
package-directory Print path to package directory
package [destination] Build a package artifact, and put it into the given destination [aliases: pack]
recipe Suggest a recipe format
+ recompile [names..] Byte-recompile `.el' files
refresh Download package archives
reinstall [names..] Reinstall packages
run Run custom tasks
diff --git a/docs/content/Getting-Started/Commands-and-options/_index.en.md b/docs/content/Getting-Started/Commands-and-options/_index.en.md
index 941ee1b1..1a7ae0d2 100644
--- a/docs/content/Getting-Started/Commands-and-options/_index.en.md
+++ b/docs/content/Getting-Started/Commands-and-options/_index.en.md
@@ -183,7 +183,7 @@ by default.
## 🔍 eask compile
-Byte-compile files.
+Byte-compile `.el` files.
```sh
$ eask compile [FILES..]
@@ -201,6 +201,19 @@ Or compile files that are already specified in your `Eask`-file.
$ eask compile
```
+## 🔍 eask recompile
+
+Byte-recompile `.el` files.
+
+```sh
+$ eask recompile [FILES..]
+```
+
+{{< hint info >}}
+💡 Similar to `eask compile`, but it will also remove old `.elc` files before
+compiling.
+{{< /hint >}}
+
## 🔍 eask package-directory
Print path to package directory, where all dependencies are installed.
diff --git a/docs/content/Getting-Started/Commands-and-options/_index.zh-tw.md b/docs/content/Getting-Started/Commands-and-options/_index.zh-tw.md
index ff1fae8c..9bae50ae 100644
--- a/docs/content/Getting-Started/Commands-and-options/_index.zh-tw.md
+++ b/docs/content/Getting-Started/Commands-and-options/_index.zh-tw.md
@@ -180,7 +180,7 @@ $ eask package [DESTINATION]
## 🔍 eask compile
-字節編譯文件。
+字節編譯 `.el` 文件。
```sh
$ eask compile [FILES..]
@@ -198,6 +198,18 @@ $ eask compile file-1.el file-2.el
$ eask compile
```
+## 🔍 eask recompile
+
+重新字節編譯 `.el` 文件。
+
+```sh
+$ eask recompile [FILES..]
+```
+
+{{< hint info >}}
+💡 與 `eask compile` 類似,但它在編譯前會刪除舊的 `.elc` 檔案。
+{{< /hint >}}
+
## 🔍 eask package-directory
打印包目錄的路徑,其中安裝了所有依賴項。
diff --git a/lisp/_prepare.el b/lisp/_prepare.el
index 722fec07..896a5cf1 100644
--- a/lisp/_prepare.el
+++ b/lisp/_prepare.el
@@ -1681,7 +1681,8 @@ For arguments MSG and ARGS, please see function `eask-print' for the detials."
For arguments MSG and ARGS, please see function `eask--format-paint-kwds' for
the detials."
- (message (apply #'eask--format-paint-kwds msg args)))
+ (apply #'eask-write msg args)
+ (eask-princ "\n" t))
(defun eask-write (msg &rest args)
"Like the function `eask-msg' but without newline at the end.
diff --git a/lisp/core/compile.el b/lisp/core/compile.el
index 0be2c263..cfa9a7b2 100644
--- a/lisp/core/compile.el
+++ b/lisp/core/compile.el
@@ -1,8 +1,8 @@
-;;; core/compile.el --- Byte compile all Emacs Lisp files in the package -*- lexical-binding: t; -*-
+;;; core/compile.el --- Byte-compile `.el' files -*- lexical-binding: t; -*-
;;; Commentary:
;;
-;; Byte compile all Emacs Lisp files in the package
+;; Byte-compile `.el' files,
;;
;; $ eask compile [names..]
;;
diff --git a/lisp/core/recompile.el b/lisp/core/recompile.el
new file mode 100644
index 00000000..e236a37e
--- /dev/null
+++ b/lisp/core/recompile.el
@@ -0,0 +1,30 @@
+;;; core/recompile.el --- Byte-recompile `.el' files -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;;
+;; Byte-recompile `.el' files,
+;;
+;; $ eask recompile [names..]
+;;
+;;
+;; Positionals:
+;;
+;; [names..] specify files to byte-recompile
+;;
+
+;;; Code:
+
+(let ((dir (file-name-directory (nth 1 (member "-scriptload" command-line-args)))))
+ (load (expand-file-name "_prepare.el"
+ (locate-dominating-file dir "_prepare.el"))
+ nil t))
+
+;;
+;;; Core
+
+(eask-start
+ (eask-call "clean/elc")
+ (eask-write "")
+ (eask-call "core/compile"))
+
+;;; core/recompile.el ends here
diff --git a/test/commands/local/run.sh b/test/commands/local/run.sh
index 86c21229..52a9dee8 100644
--- a/test/commands/local/run.sh
+++ b/test/commands/local/run.sh
@@ -59,6 +59,8 @@ eask package
# Development
eask compile
eask compile --clean
+eask recompile
+eask recompile --clean
eask recipe
eask keywords
eask run script