[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/beardbolt 5e389a88d9 152/323: Add rmsbolt splitter for
From: |
ELPA Syncer |
Subject: |
[elpa] externals/beardbolt 5e389a88d9 152/323: Add rmsbolt splitter for splitting and mutating commands |
Date: |
Thu, 9 Mar 2023 10:58:26 -0500 (EST) |
branch: externals/beardbolt
commit 5e389a88d9f4f0a8d0d409160a0ddaa791625aec
Author: Jay Kamat <jaygkamat@gmail.com>
Commit: Jay Kamat <jaygkamat@gmail.com>
Add rmsbolt splitter for splitting and mutating commands
Very far from being foolproof, doesn't even handle quotes yet, but we
shouldn't spend time on stuff no one will use (probably), since
generated output is pretty predictable.
See #4
---
.ert-runner | 2 +-
Cask | 3 +-
rmsbolt-split.el | 70 ++++++++++++++++++++++++++++++++++++++++++++++
test/rmsbolt-split-test.el | 63 +++++++++++++++++++++++++++++++++++++++++
test/rmsbolt-test.el | 1 +
5 files changed, 137 insertions(+), 2 deletions(-)
diff --git a/.ert-runner b/.ert-runner
index fbc31e4b07..b5f5e2ff74 100644
--- a/.ert-runner
+++ b/.ert-runner
@@ -1 +1 @@
--l rmsbolt-java.el rmsbolt.el
+-l rmsbolt-java.el rmsbolt.el rmsbolt-split.el
diff --git a/Cask b/Cask
index 0827a85ac2..8059cb55ef 100644
--- a/Cask
+++ b/Cask
@@ -4,7 +4,8 @@
(package-file "rmsbolt.el")
(files "rmsbolt.el"
- "rmsbolt-java.el")
+ "rmsbolt-java.el"
+ "rmsbolt-split.el")
(development
(depends-on "ert-runner")
diff --git a/rmsbolt-split.el b/rmsbolt-split.el
new file mode 100644
index 0000000000..2e7e5bf1ea
--- /dev/null
+++ b/rmsbolt-split.el
@@ -0,0 +1,70 @@
+;;; rmsbolt-split.el --- An Elisp library to edit command lines -*-
lexical-binding: t; -*-
+
+;; Copyright (C) 2018 Jay Kamat
+;; Author: Jay Kamat <jaygkamat@gmail.com>
+;; Version: 0.1.0
+;; Keywords: compilation, tools
+;; URL: http://gitlab.com/jgkamat/rmsbolt
+;; Package-Requires: ((emacs "25.1"))
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU Affero General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, 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 Affero General Public License for more details.
+
+;; You should have received a copy of the GNU Affero General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This is a small library for editing command line parameters, passed as
+;; a string. For example, given:
+;; gcc -o one two -c -S
+;; This library tries to make it possible to remove '-o one' '-c' and '-S'.
+;;
+;; This is not easy to do without bugs, and therefore this is mostly
incomplete.
+;; Hopefully we will never see more complicated formats (such as quoted
arguments)
+;; in generated commands, or we will need to write a parser.
+
+;;; Requires:
+
+(require 'cl-lib)
+
+;;; Variables
+
+(defvar rmsbolt-split--regexp (rx (1+ blank)))
+
+;;; Code:
+
+(defun rmsbolt-split-rm-single (cmd flag)
+ "Remove a single FLAG from CMD."
+ (let ((cmd (split-string cmd rmsbolt-split--regexp)))
+ (mapconcat
+ #'identity
+ (cl-remove-if (apply-partially #'string= flag) cmd)
+ " ")))
+
+(defun rmsbolt-split-rm-double (cmd flag)
+ "Remove a single FLAG and arg from CMD."
+ (let ((cmd (split-string cmd rmsbolt-split--regexp))
+ (removed nil))
+ (mapconcat
+ #'identity
+ (cl-remove-if (lambda (f)
+ (cond
+ ((string= f flag)
+ (setq removed t))
+ (removed
+ (setq removed nil)
+ t)
+ (t nil)))
+ cmd)
+ " ")))
+
+;;; rmsbolt-split.el ends here
+(provide 'rmsbolt-split)
diff --git a/test/rmsbolt-split-test.el b/test/rmsbolt-split-test.el
new file mode 100644
index 0000000000..c8e15afcb2
--- /dev/null
+++ b/test/rmsbolt-split-test.el
@@ -0,0 +1,63 @@
+;;; rmsbolt-split-test.el --- Tests for rmsbolt-split -*- lexical-binding: t;
-*-
+
+;;; Commentary:
+;; Tests for rmsbolt
+
+;;; Code:
+
+(require 'rmsbolt-split)
+
+(ert-deftest test-split-single ()
+ "Test split single function"
+ (should (equal
+ (rmsbolt-split-rm-single "/usr/bin/c++ -a -R -c" "-R")
+ "/usr/bin/c++ -a -c"))
+
+ (should (equal
+ (rmsbolt-split-rm-single "/usr/bin/c++ -a -R -c" "-R")
+ "/usr/bin/c++ -a -c"))
+
+ (should (equal
+ (rmsbolt-split-rm-single "/usr/bin/c++ -a -R -c" "-a")
+ "/usr/bin/c++ -R -c"))
+
+ (should (equal
+ (rmsbolt-split-rm-single "/usr/bin/c++ -a -R -c" "-c")
+ "/usr/bin/c++ -a -R"))
+
+ (should (equal
+ (rmsbolt-split-rm-single "/usr/bin/c++ -a -R -c" "-z")
+ "/usr/bin/c++ -a -R -c"))
+
+ (should (equal
+ (rmsbolt-split-rm-single "/usr/bin/c++ -a -R -a" "-a")
+ "/usr/bin/c++ -R"))
+
+ (should (equal
+ (rmsbolt-split-rm-single
+ "/usr/bin/c++ -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB
-DQT_NO_KEYWORDS -DQT_WIDGETS_LIB -Isrc/googletest/include -I../common -Icommon
-Icommon/protobuf -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem
/usr/include/x86_64-linux-gnu/qt5/QtCore -isystem
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -isystem
/usr/include/x86_64-linux-gnu/qt5/QtNetwork -isystem
/usr/include/x86_64-linux-gnu/qt5/QtWidgets -isystem
/usr/include/x86_64-linux-gnu/qt5/QtGui -Werror=retu [...]
+ "/usr/bin/c++ -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB
-DQT_NO_KEYWORDS -DQT_WIDGETS_LIB -Isrc/googletest/include -I../common -Icommon
-Icommon/protobuf -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem
/usr/include/x86_64-linux-gnu/qt5/QtCore -isystem
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -isystem
/usr/include/x86_64-linux-gnu/qt5/QtNetwork -isystem
/usr/include/x86_64-linux-gnu/qt5/QtWidgets -isystem
/usr/include/x86_64-linux-gnu/qt5/QtGui -Werror=return-lo [...]
+
+
+(ert-deftest test-split-double ()
+ "Test split single function"
+ (should (equal
+ (rmsbolt-split-rm-double "/usr/bin/c++ -a -R -c" "-R")
+ "/usr/bin/c++ -a"))
+
+ (should (equal
+ (rmsbolt-split-rm-double "/usr/bin/c++ -a -R -c" "-c")
+ "/usr/bin/c++ -a -R"))
+
+ (should (equal
+ (rmsbolt-split-rm-double "/usr/bin/c++ -a -R -c" "-a")
+ "/usr/bin/c++ -c"))
+
+ (should (equal
+ (rmsbolt-split-rm-double
+ "/usr/bin/c++ -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB
-DQT_NO_KEYWORDS -DQT_WIDGETS_LIB -Isrc/googletest/include -I../common -Icommon
-Icommon/protobuf -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem
/usr/include/x86_64-linux-gnu/qt5/QtCore -isystem
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -isystem
/usr/include/x86_64-linux-gnu/qt5/QtNetwork -isystem
/usr/include/x86_64-linux-gnu/qt5/QtWidgets -isystem
/usr/include/x86_64-linux-gnu/qt5/QtGui -Werror=retu [...]
+ "/usr/bin/c++ -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB
-DQT_NO_KEYWORDS -DQT_WIDGETS_LIB -Isrc/googletest/include -I../common -Icommon
-Icommon/protobuf -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem
/usr/include/x86_64-linux-gnu/qt5/QtCore -isystem
/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -isystem
/usr/include/x86_64-linux-gnu/qt5/QtNetwork -isystem
/usr/include/x86_64-linux-gnu/qt5/QtWidgets -isystem
/usr/include/x86_64-linux-gnu/qt5/QtGui -Werror=return-lo [...]
+
+(provide 'rmsbolt-split-test)
+
+;;; rmsbolt-split-test.el ends here
diff --git a/test/rmsbolt-test.el b/test/rmsbolt-test.el
index 8880b1caeb..79258ca9a6 100644
--- a/test/rmsbolt-test.el
+++ b/test/rmsbolt-test.el
@@ -108,3 +108,4 @@
;;; rmsbolt-test.el ends here
+(provide 'rmsbolt-test)
- [elpa] externals/beardbolt c009c2df44 130/323: Trim left side of strings to activate 'starting with period' opt, (continued)
- [elpa] externals/beardbolt c009c2df44 130/323: Trim left side of strings to activate 'starting with period' opt, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 9e38f2238b 135/323: Add support for functions as arguments to :compile-cmd, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 1cc069a121 132/323: Quote filenames before passing them as shell arguments, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 495d481a94 136/323: Move rmsbolt-command initialization to end, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 39055a3dc4 133/323: Fix disassembly of partial files in C/C++, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 27e7bb714f 139/323: Add suppport for PHP, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 4b6abc5ef8 129/323: Optimize rmsbolt-process-src-asm-lines, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 67238e0272 138/323: Add rmsbolt-default-directory customization, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 9b2c85397c 149/323: Add texinfo version of docs, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt ec99a1aa31 146/323: Attempt to fix whitespace clearing on hot recompiles, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 5e389a88d9 152/323: Add rmsbolt splitter for splitting and mutating commands,
ELPA Syncer <=
- [elpa] externals/beardbolt 0fbc3d3f09 153/323: Enable compile_commands.json parsing for c/cpp, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 743f9a68ec 158/323: Handle non absolute .file paths, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 609f781b3a 165/323: Fix usages of when-let, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt c9f3b839e9 156/323: Add support for D, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt a4f794666d 160/323: Add D to commentary, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt b7d318dfe1 178/323: Add Swift language support, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 98e984493b 170/323: Prevent hot recompile on deleted buffers, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt c655e2af39 186/323: Add check for dead buffers in compilation finish fn, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt d51e71f894 188/323: Use special named buffer for compilation, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 712981e16c 187/323: Remove langauges godbolt has added support for, ELPA Syncer, 2023/03/09