wisp
 
(Arne Babenhauserheide)
2014-01-21: resolve quote-as-only-char bug: The testsuite passes again.

resolve quote-as-only-char bug: The testsuite passes again.

diff --git a/.bugs/bugs b/.bugs/bugs
--- a/.bugs/bugs
+++ b/.bugs/bugs
@@ -22,4 +22,4 @@ make this work: let : : origfile ( open-
 wisp.py breaks on \ - quote, escaped backslash, quote        | owner:Arne Babenhauserheide <bab@draketo.de>, open:True, id:d75a93ca58ade5b3e3e51f1e7ee9782e743ac131, time:1377424552.02
 comments containing a closing parenthesis can break the parser. | owner:, open:False, id:d9147504868960e5fbc2648474d48ce5c9bd1a02, time:1374838747.22
 breaks on empty files                                        | owner:Arne Babenhauserheide <bab@draketo.de>, open:False, id:e40fa7a93eb2c497dca1af7eed22ad5ed5cfbe7f, time:1390325470.91
-quote as only char in a line gets parenthized instead of becoming a paren-prefix. | owner:Arne Babenhauserheide <bab@draketo.de>, open:True, id:eb7468387e90bb5d13f5a5d81c6f4a704f2ca0fb, time:1390326369.6
+quote as only char in a line gets parenthized instead of becoming a paren-prefix. | owner:Arne Babenhauserheide <bab@draketo.de>, open:False, id:eb7468387e90bb5d13f5a5d81c6f4a704f2ca0fb, time:1390326369.6
diff --git a/wisp-guile.w b/wisp-guile.w
--- a/wisp-guile.w
+++ b/wisp-guile.w
@@ -231,6 +231,10 @@ define : line-only-colon? line
     . "Check whether the line content consists only of a colon and whitespace."
     equal? ":" : string-trim-right : line-content line
 
+define : line-only-prefix? line prefix
+    . "Check whether the line content consists only of a colon and whitespace."
+    equal? prefix : string-trim-right : line-content line
+
 define : line-merge-comment line
     . "Merge comment and content into the content. Return the new line."
     let 
@@ -501,18 +505,26 @@ The line *must* have a whitespace after 
                          line-content line
                      line-comment line
                  ; otherwise check all possible prefixes
-                 let : : prefix : car paren-prefixes
-                     if 
-                         or : string-prefix? prefix : line-content line
-                              equal? prefix : line-content line
-                         list 
-                             line-indent line
-                             string-append 
-                                 . (string-drop-right prefix 1) "("
-                                 string-drop (line-content line) : string-length prefix
-                             line-comment line
-                         ; else
-                         loop : cdr paren-prefixes
+                 let* 
+                     : prefix : car paren-prefixes
+                       prefix-no-space : string-drop-right prefix 1
+                     cond
+                         : string-prefix? prefix : line-content line
+                           list 
+                               line-indent line
+                               string-append 
+                                   . prefix-no-space "("
+                                   string-drop (line-content line) : string-length prefix
+                               line-comment line
+                         : line-only-prefix? line prefix-no-space
+                           list 
+                               line-indent line
+                               string-append 
+                                   . (string-drop-right prefix 1) "("
+                                   string-drop (line-content line) : string-length prefix-no-space
+                               line-comment line
+                         else
+                           loop : cdr paren-prefixes
        
 define : line-add-closing-brackets line number
     . "Add a closing bracket to the line."