[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/zig-mode ab46e22 048/104: add some zig cli build commands
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/zig-mode ab46e22 048/104: add some zig cli build commands |
Date: |
Sun, 29 Aug 2021 11:37:01 -0400 (EDT) |
branch: elpa/zig-mode
commit ab46e22ceec16955d63df6e388bbeb22d47e0513
Author: Marcio Giaxa <i@mgxm.me>
Commit: Marcio Giaxa <i@mgxm.me>
add some zig cli build commands
* Adds:
- zig-compile
- zig-build-exe
- zig-build-lib
- zig-build-obj
- zig-run
- zig-test-buffer
---
zig-mode.el | 49 +++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 47 insertions(+), 2 deletions(-)
diff --git a/zig-mode.el b/zig-mode.el
index 833eb0e..819b7fd 100644
--- a/zig-mode.el
+++ b/zig-mode.el
@@ -49,14 +49,59 @@
;; zig CLI commands
+
+(defun zig--run-cmd (cmd &optional source &rest args)
+ "Use compile command to execute a zig CMD with ARGS if given.
+If given a SOURCE, execute the CMD on it."
+ (let ((cmd-args
+ (if source
+ (mapconcat 'identity (cons source args) " ")
+ args)))
+ (compile (concat zig-zig-bin " " cmd " " cmd-args))))
+
;;;###autoload
(defun zig-toggle-format-on-save ()
"Switch format before save on current buffer."
(interactive)
(if zig-format-on-save
- (setq-local zig-format-on-save nil)
- (setq-local zig-format-on-save t)))
+ (setq-local zig-format-on-save nil)
+ (setq-local zig-format-on-save t)))
+
+;;;###autoload
+(defun zig-compile ()
+ "Compile using `zig build`."
+ (interactive)
+ (zig--run-cmd "build"))
+;;;###autoload
+(defun zig-build-exe ()
+ "Create executable from source or object file."
+ (interactive)
+ (zig--run-cmd "build-exe" (buffer-file-name)))
+
+;;;###autoload
+(defun zig-build-lib ()
+ "Create library from source or assembly."
+ (interactive)
+ (zig--run-cmd "build-lib" (buffer-file-name)))
+
+;;;###autoload
+(defun zig-build-obj ()
+ "Create object from source or assembly."
+ (interactive)
+ (zig--run-cmd "build-obj" (buffer-file-name)))
+
+;;;###autoload
+(defun zig-test-buffer ()
+ "Test buffer using `zig test`."
+ (interactive)
+ (zig--run-cmd "test" (buffer-file-name) "--release-fast"))
+
+;;;###autoload
+(defun zig-run ()
+ "Create an executable from the current buffer and run it immediately."
+ (interactive)
+ (zig--run-cmd "run" (buffer-file-name)))
;;;###autoload
(defun zig-format-buffer ()
- [nongnu] elpa/zig-mode df572da 099/104: Add opaque keyword, (continued)
- [nongnu] elpa/zig-mode df572da 099/104: Add opaque keyword, ELPA Syncer, 2021/08/29
- [nongnu] elpa/zig-mode acf3ee8 104/104: Add GitHub Actions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/zig-mode 2842797 007/104: Fix builtins. Reorder tables., ELPA Syncer, 2021/08/29
- [nongnu] elpa/zig-mode e69ebc0 012/104: and, or, @panic., ELPA Syncer, 2021/08/29
- [nongnu] elpa/zig-mode 9a252eb 016/104: Update README.md, ELPA Syncer, 2021/08/29
- [nongnu] elpa/zig-mode ad9f398 028/104: Add some font-lock tests, ELPA Syncer, 2021/08/29
- [nongnu] elpa/zig-mode 2879253 029/104: Don't let backslashes escape newlines in multiline strings, ELPA Syncer, 2021/08/29
- [nongnu] elpa/zig-mode 4542a5d 036/104: add imenu support, ELPA Syncer, 2021/08/29
- [nongnu] elpa/zig-mode 604484c 039/104: M-x untabify, ELPA Syncer, 2021/08/29
- [nongnu] elpa/zig-mode 67ad48b 045/104: fix multiline string properties rules regex, ELPA Syncer, 2021/08/29
- [nongnu] elpa/zig-mode ab46e22 048/104: add some zig cli build commands,
ELPA Syncer <=
- [nongnu] elpa/zig-mode acebfb1 057/104: Add anyframe; remove promise, ELPA Syncer, 2021/08/29
- [nongnu] elpa/zig-mode fc7fde3 056/104: Merge pull request #23 from joachimschmidt557/master, ELPA Syncer, 2021/08/29
- [nongnu] elpa/zig-mode ad844c3 062/104: noasync -> nosuspend, ELPA Syncer, 2021/08/29
- [nongnu] elpa/zig-mode 2c45c45 059/104: Merge pull request #24 from joachimschmidt557/add-anyframe, ELPA Syncer, 2021/08/29
- [nongnu] elpa/zig-mode 22187f4 076/104: Merge pull request #32 from joachimschmidt557/remove-this, ELPA Syncer, 2021/08/29
- [nongnu] elpa/zig-mode 8721255 079/104: Merge pull request #34 from jdpage/shell-quoting, ELPA Syncer, 2021/08/29
- [nongnu] elpa/zig-mode b7d9613 091/104: Account for braces inside of function parameters, ELPA Syncer, 2021/08/29
- [nongnu] elpa/zig-mode 41fa032 092/104: Account for paren-wrapped return type, ELPA Syncer, 2021/08/29
- [nongnu] elpa/zig-mode bab3143 094/104: Add `zig-test-optimization-mode` and `zig-run-optimization-mode`, ELPA Syncer, 2021/08/29
- [nongnu] elpa/zig-mode 0b9cddb 098/104: Exclude all except fn and test blocks, ELPA Syncer, 2021/08/29