-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(fmt): Add formatters * chore: Changelog * correct spelling * don't test foramt elisp-autofmt
- Loading branch information
Showing
16 changed files
with
360 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* 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 <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
"use strict"; | ||
|
||
exports.command = ['format <type>', 'fmt <type>']; | ||
exports.desc = 'Run formatters'; | ||
exports.builder = function (yargs) { | ||
yargs.usage(`${exports.desc} | ||
Usage: eask format <type> [options..]`) | ||
.commandDir('../format/') | ||
.demandCommand(); | ||
|
||
/* XXX: Configure only in the menu. */ | ||
if (UTIL.cmd_count() == 1) { | ||
yargs.positional( | ||
'<type>', { | ||
description: 'type of the formatter', | ||
}); | ||
} | ||
} | ||
|
||
exports.handler = async (argv) => { }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* 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 <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
"use strict"; | ||
|
||
exports.command = ['elfmt [files..]']; | ||
exports.desc = 'Reformat Elisp source with elfmt'; | ||
exports.builder = yargs => yargs | ||
.positional( | ||
'[files..]', { | ||
description: 'specify files to do elfmt', | ||
type: 'array', | ||
}); | ||
|
||
exports.handler = async (argv) => { | ||
await UTIL.e_call(argv, 'format/elfmt', argv.files); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* 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 <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
"use strict"; | ||
|
||
exports.command = ['elisp-autofmt [files..]']; | ||
exports.desc = 'Reformat Elisp source with elisp-autofmt'; | ||
exports.builder = yargs => yargs | ||
.positional( | ||
'[files..]', { | ||
description: 'specify files to do elisp-autofmt', | ||
type: 'array', | ||
}); | ||
|
||
exports.handler = async (argv) => { | ||
await UTIL.e_call(argv, 'format/elisp-autofmt', argv.files); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
;;; format/elfmt.el --- Run elfmt -*- lexical-binding: t; -*- | ||
|
||
;;; Commentary: | ||
;; | ||
;; Commmand use to run `elfmt' for all files | ||
;; | ||
;; $ eask format elfmt [files..] | ||
;; | ||
;; | ||
;; Positionals: | ||
;; | ||
;; [files..] files you want elfmt to run on | ||
;; | ||
|
||
;;; 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)) | ||
|
||
;; | ||
;;; Externals | ||
|
||
(declare-function elfmt-buffer "ext:elisp-autofmt.el") | ||
|
||
;; | ||
;;; Flags | ||
|
||
(advice-add #'eask-allow-error-p :override #'always) | ||
|
||
;; | ||
;;; Core | ||
|
||
(defconst eask-format-elfmt--version nil | ||
"`elfmt' version.") | ||
|
||
(defun eask-format-elfmt--file (filename) | ||
"Run elfmt on FILENAME." | ||
(let* ((filename (expand-file-name filename)) | ||
(file (eask-root-del filename))) | ||
(with-current-buffer (find-file filename) | ||
(elfmt-buffer) | ||
(save-buffer) | ||
(kill-buffer)))) | ||
|
||
(eask-start | ||
;; Preparation | ||
(eask-with-archives '("gnu" "melpa" "jcs-elpa") | ||
(eask-package-install 'elfmt)) | ||
(setq eask-format-elfmt--version (eask-package--version-string 'elfmt)) | ||
|
||
;; Start formatting | ||
(require 'elfmt) | ||
(let* ((patterns (eask-args)) | ||
(files (if patterns | ||
(eask-expand-file-specs patterns) | ||
(eask-package-el-files)))) | ||
(cond | ||
;; Files found, do the action! | ||
(files | ||
(eask-msg "") | ||
(eask-msg "Running `%s` formatter (%s)" | ||
(ansi-green "elfmt") (ansi-yellow eask-format-elfmt--version)) | ||
(eask-progress-seq " - Formatting" files "done! ✓" #'eask-format-elfmt--file) | ||
(eask-msg "") | ||
(eask-info "(Total of %s file%s %s formatted)" (length files) | ||
(eask--sinr files "" "s") | ||
(eask--sinr files "has" "have"))) | ||
;; Pattern defined, but no file found! | ||
(patterns | ||
(eask-info "(No files match wildcard: %s)" | ||
(mapconcat #'identity patterns " "))) | ||
;; Default, print help! | ||
(t | ||
(eask-info "(No files have been formatted)") | ||
(eask-help "format/elfmt"))))) | ||
|
||
;;; format/elfmt.el ends here |
Oops, something went wrong.