[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/inf-clojure 8eaf885 275/313: [Fix #152] Sanitize should on
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/inf-clojure 8eaf885 275/313: [Fix #152] Sanitize should only remove whitespace at the end of a command |
Date: |
Wed, 11 Aug 2021 10:00:32 -0400 (EDT) |
branch: elpa/inf-clojure
commit 8eaf885cb03515c010eff6d9924b641d30b3eb45
Author: Andrea Richiardi <a.richiardi.work@gmail.com>
Commit: Bozhidar Batsov <bozhidar.batsov@gmail.com>
[Fix #152] Sanitize should only remove whitespace at the end of a command
---
inf-clojure.el | 14 +-------------
test/inf-clojure-tests.el | 23 ++++-------------------
2 files changed, 5 insertions(+), 32 deletions(-)
diff --git a/inf-clojure.el b/inf-clojure.el
index 62d9402..e63a183 100644
--- a/inf-clojure.el
+++ b/inf-clojure.el
@@ -375,24 +375,12 @@ Should be a symbol that is a key in
`inf-clojure-repl-features'."
"Return non-nil iff STRING is a whole line semicolon comment."
(string-match-p "^\s*;" string))
-(defun inf-clojure--make-single-line (string)
- "Convert a multi-line STRING in a single-line STRING.
-It also reduces redundant whitespace for readability and removes
-comments."
- (let* ((lines (seq-filter (lambda (s) (not
(inf-clojure--whole-comment-line-p s)))
- (split-string string "[\r\n]" t))))
- (mapconcat (lambda (s)
- (if (not (string-match-p ";" s))
- (replace-regexp-in-string "\s+" " " s)
- (concat s "\n")))
- lines " ")))
-
(defun inf-clojure--sanitize-command (command)
"Sanitize COMMAND for sending it to a process.
An example of things that this function does is to add a final
newline at the end of the form. Return an empty string if the
sanitized command is empty."
- (let ((sanitized (inf-clojure--make-single-line command)))
+ (let ((sanitized (string-trim-right command)))
(if (string-blank-p sanitized)
""
(concat sanitized "\n"))))
diff --git a/test/inf-clojure-tests.el b/test/inf-clojure-tests.el
index 7821c06..1dd4d01 100644
--- a/test/inf-clojure-tests.el
+++ b/test/inf-clojure-tests.el
@@ -111,24 +111,6 @@
(expect (ict-bounds-string
(inf-clojure-completion-bounds-of-expr-at-point))
:to-equal "deref")))))
-(describe "inf-clojure--make-single-line"
- (it "replaces newlines with whitespace"
- (expect (inf-clojure--make-single-line "(do\n(println \"hello
world\")\n)") :to-equal "(do (println \"hello world\") )"))
-
- (it "does not leave whitespace at the end"
- (expect (inf-clojure--make-single-line "(do\n(println \"hello
world\")\n)\n\n") :to-equal "(do (println \"hello world\") )"))
-
- (it "returns empty string when the line is only newlines"
- (expect (inf-clojure--make-single-line "\n\n\n\n") :to-equal ""))
-
- (it "removes comments when on their own line"
- (expect (inf-clojure--make-single-line "(do\n(println \"hello world\")\n
;; remove me\n)") :to-equal "(do (println \"hello world\") )"))
-
- (it "preserves newlines of inline comments"
- (expect (inf-clojure--make-single-line "(do\n(println \"hello world\")
;; don't remove this\n)") :to-equal "(do (println \"hello world\") ;; don't
remove this\n )"))
-
- )
-
(describe "inf-clojure--sanitize-command"
(it "sanitizes the command correctly"
(expect (inf-clojure--sanitize-command "(doc println)") :to-equal "(doc
println)\n"))
@@ -137,7 +119,10 @@
(expect (inf-clojure--sanitize-command "(doc println)\n\n\n\n") :to-equal
"(doc println)\n"))
(it "returns empty string when the command is empty"
- (expect (inf-clojure--sanitize-command " ") :to-equal "")))
+ (expect (inf-clojure--sanitize-command " ") :to-equal ""))
+
+ (it "only removes whitespace at the end of the command - fix 152"
+ (expect (inf-clojure--sanitize-command "1 5") :to-equal "1 5\n")))
(describe "inf-clojure--update-feature"
(it "updates new forms correctly"
- [nongnu] elpa/inf-clojure 630471b 194/313: Update CHANGELOG.md, (continued)
- [nongnu] elpa/inf-clojure 630471b 194/313: Update CHANGELOG.md, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure c3217c3 200/313: Skip sanitation of comments, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 9b77479 207/313: Set inf-clojure-tools-deps-cmd to "clojure" (#144), ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 58150d7 256/313: Improve some wording in the README, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure f63c609 252/313: Fix a typo, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure b5e915c 204/313: Travis test like in cider, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure b88de63 260/313: Tweak a docstring, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure e144b33 276/313: Improve the Makefile commands, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 917ee77 268/313: Improve the README a bit, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 91f4121 280/313: Bump the copyright years, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 8eaf885 275/313: [Fix #152] Sanitize should only remove whitespace at the end of a command,
ELPA Syncer <=
- [nongnu] elpa/inf-clojure ec4a85e 285/313: Bump copyright years, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 2046b12 298/313: Make inf-clojure-repl-p a bit more flexible, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure e1d7007 297/313: Touch up the previous commit, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 9841b38 303/313: Remove some redundant code, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 3d31bee 313/313: Update my email, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 26a2076 305/313: Replace if + not with unless, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure be3e2e7 195/313: Introduce inf-clojure-reload, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 953feb0 198/313: Improve command sanitation code, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 7ed4f44 203/313: Remove emacs 24.3 and add 26 to Travis tests, ELPA Syncer, 2021/08/11
- [nongnu] elpa/inf-clojure 010d859 219/313: Fix spelling issues (#156), ELPA Syncer, 2021/08/11