Hello,

While editing Scheme code with the Lisp mode enabled (:set lisp), I
have noticed that the command % does not work with parentheses inside
single line comments. This is good, since you might have just one
parenthesis in a commented line and you don't want it to mess up the
matching of parentheses in the source code.

But vim has a problem when you use an S-expression comment, a style of
comment defined in the Scheme extension SRFI-62 (http://
srfi.schemers.org/srfi-62/srfi-62.html). It's a straightforward way to
comment a whole expression in Scheme, without the need of commenting
every line. For example, with S-expression comments, you can do this:

        (this is #;(some s-expression
                  with a commented (expression)))

Instead of this:

        (this is ;(some s-expression
                 ;with a commented (expression))
        )

Both excerpts will result in the following expression:

        (this is)

If you position the cursor on the parenthesis right after the '#;'
token and press the key %, Vim won't recognize it as a match and will
mess up the matching of other parentheses. This is because Vim thinks
the parenthesis is inside a comment line, while in fact it is not
(note that '#;' does *not* produce a comment line, while ';' alone
does).

So I went ahead and tried to find the source of this inconvenience and
fix the code. I created a patch and I'm posting it here.

I also wondered if this might affect Common Lisp code somehow, but a
line like "#;is this a comment line?" seems to be invalid and triggers
an error in CLISP.

I hope this might be useful.

                                     Alonso

--- search.c    (revision 1586)
+++ search.c    (working copy)
@@ -2400,8 +2400,10 @@
                                      && *(p - 1) != '\\' && *(p - 2) != '#'))
                        instr = TRUE;
                }
-               else if (!instr && ((p - line) < 2
-                                   || (*(p - 1) != '\\' && *(p - 2) != '#')))
+               else if (!instr
+                        && ((p - line) < 1 || *(p - 1) != '#')
+                        && ((p - line) < 2
+                            || (*(p - 1) != '\\' && *(p - 2) != '#')))
                    break;      /* found! */
                ++p;
            }

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui