branch: elpa/lua-mode
commit 563ac50158336a16243e1f3f22076e64a853ba72
Merge: 6511687 f2915c3
Author: dennis again <[email protected]>
Commit: dennis again <[email protected]>
Merge pull request #115 from RobertCochran/escape-tabs
Escape tabs in lua-make-lua-string
---
lua-mode.el | 12 ++++++++----
test/test-inferior-process.el | 7 +++++++
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/lua-mode.el b/lua-mode.el
index b34d1dd..95bf6dc 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -1708,10 +1708,14 @@ This function just searches for a `end' at the
beginning of a line."
(with-temp-buffer
(insert str)
(goto-char (point-min))
- (while (re-search-forward "[\"'\\\n]" nil t)
- (if (string= (match-string 0) "\n")
- (replace-match "\\\\n")
- (replace-match "\\\\\\&" t)))
+ (while (re-search-forward "[\"'\\\t\\\n]" nil t)
+ (cond
+ ((string= (match-string 0) "\n")
+ (replace-match "\\\\n"))
+ ((string= (match-string 0) "\t")
+ (replace-match "\\\\t"))
+ (t
+ (replace-match "\\\\\\&" t))))
(concat "'" (buffer-string) "'"))))
;;;###autoload
diff --git a/test/test-inferior-process.el b/test/test-inferior-process.el
index 2fedd29..e51f00c 100644
--- a/test/test-inferior-process.el
+++ b/test/test-inferior-process.el
@@ -142,3 +142,10 @@ function () end
(kill-buffer buf))
(delete-file fname)
(kill-buffer "*lua*")))))
+
+(describe "String escaping"
+ (it "Escapes literal tabs"
+ (expect (string=
+ (lua-make-lua-string "\
+ -- comment indented with a tab")
+ "'\\t-- comment indented with a tab'"))))