branch: externals/beardbolt
commit ea22302660b1e32762e3922d372fdeba0f6567a9
Author: João Távora <[email protected]>
Commit: João Távora <[email protected]>
Delete beardbolt-split.el, doesn't justify separate file
* beardbolt-split.el: Remove
* beardbolt.el (beardbolt-split-rm-single, beardbolt-split-rm-double): Move
here
---
beardbolt-split.el | 74 ------------------------------------------------------
beardbolt.el | 17 ++++++++++++-
2 files changed, 16 insertions(+), 75 deletions(-)
diff --git a/beardbolt-split.el b/beardbolt-split.el
deleted file mode 100644
index b145efe052..0000000000
--- a/beardbolt-split.el
+++ /dev/null
@@ -1,74 +0,0 @@
-;;; beardbolt-split.el --- An Elisp library to edit command lines -*-
lexical-binding: t; -*-
-
-;; Copyright (C) 2018 Jay Kamat
-;; Author: Jay Kamat <[email protected]>
-;; Version: 0.1.0
-;; Keywords: compilation, tools
-;; URL: http://gitlab.com/jgkamat/beardbolt
-;; 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 beardbolt-split--regexp (rx (1+ blank)))
-
-;;; Code:
-
-(defun beardbolt-split-rm-single (cmd flag &optional comparator)
- "Remove a single FLAG from CMD.
-
-Optionally compares using COMPARATOR."
- (let ((cmd (split-string cmd beardbolt-split--regexp))
- (comparator (or comparator #'string=)))
- (mapconcat
- #'identity
- (cl-remove-if (apply-partially comparator flag) cmd)
- " ")))
-
-(defun beardbolt-split-rm-double (cmd flag)
- "Remove a single FLAG and arg from CMD."
- (let ((cmd (split-string cmd beardbolt-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)
- " ")))
-
-(provide 'beardbolt-split)
-
-;;; beardbolt-split.el ends here
diff --git a/beardbolt.el b/beardbolt.el
index 8049a89788..b946ed6b2c 100644
--- a/beardbolt.el
+++ b/beardbolt.el
@@ -76,7 +76,6 @@
(require 'color)
(require 'beardbolt-java)
-(require 'beardbolt-split)
;;; Code:
;;;; Customize:
@@ -414,6 +413,22 @@ Return value is quoted for passing to the shell."
(declare (debug (symbolp form)))
`(set (make-local-variable ,var) ,val))
+(defun beardbolt-split-rm-single (cmd flag &optional test)
+ "Remove a single FLAG from CMD. Test according to TEST."
+ (mapconcat #'identity (cl-remove flag (split-string cmd)
+ :test (or test #'string=))
+ " "))
+
+(defun beardbolt-split-rm-double (cmd flag)
+ "Remove a single FLAG and arg from CMD."
+ (cl-loop while split with split = (split-string cmd)
+ for i from 0
+ for probe = (car split)
+ if (string= probe flag) do (setq split (cddr split))
+ else
+ concat (and (cl-plusp i) " ")
+ and concat probe and do (setq split (cdr split))))
+
;;;; Language Functions
;;;;; Compile Commands