summaryrefslogtreecommitdiff
path: root/src/misc1.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2004-07-05 15:58:32 +0000
committerBram Moolenaar <Bram@vim.org>2004-07-05 15:58:32 +0000
commit325b7a2fb5b970b77f7b9ec28ba15eb794f6edf8 (patch)
treea2b0cfed6da973286326442419e56938dc966ea4 /src/misc1.c
parent592e0a2a1dbc542134c3fd88b4cdfa40e258f41b (diff)
downloadvim-git-325b7a2fb5b970b77f7b9ec28ba15eb794f6edf8.tar.gz
updated for version 7.0006
Diffstat (limited to 'src/misc1.c')
-rw-r--r--src/misc1.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/misc1.c b/src/misc1.c
index 63301103e..2825c538a 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -7377,11 +7377,13 @@ lisp_match(p)
* - it doesn't know about comments starting with a semicolon
* - it incorrectly interprets '(' as a character literal
* All this messes up get_lisp_indent in some rare cases.
+ * Update from Sergey Khorev:
+ * I tried to fix the first two issues.
*/
int
get_lisp_indent()
{
- pos_T *pos, realpos;
+ pos_T *pos, realpos, paren;
int amount;
char_u *that;
colnr_T col;
@@ -7395,7 +7397,16 @@ get_lisp_indent()
realpos = curwin->w_cursor;
curwin->w_cursor.col = 0;
- if ((pos = findmatch(NULL, '(')) != NULL)
+ if ((pos = findmatch(NULL, '(')) == NULL)
+ pos = findmatch(NULL, '[');
+ else
+ {
+ paren = *pos;
+ pos = findmatch(NULL, '[');
+ if (pos == NULL || ltp(pos, &paren))
+ pos = &paren;
+ }
+ if (pos != NULL)
{
/* Extra trick: Take the indent of the first previous non-white
* line that is at the same () level. */
@@ -7426,9 +7437,9 @@ get_lisp_indent()
while (*that && (*that != '"' || *(that - 1) == '\\'))
++that;
}
- if (*that == '(')
+ if (*that == '(' || *that == '[')
++parencount;
- else if (*that == ')')
+ else if (*that == ')' || *that == ']')
--parencount;
}
if (parencount == 0)
@@ -7465,7 +7476,8 @@ get_lisp_indent()
* (...)) of (...))
*/
- if (!vi_lisp && *that == '(' && lisp_match(that + 1))
+ if (!vi_lisp && (*that == '(' || *that == '[')
+ && lisp_match(that + 1))
amount += 2;
else
{
@@ -7483,7 +7495,7 @@ get_lisp_indent()
{
/* test *that != '(' to accomodate first let/do
* argument if it is more than one line */
- if (!vi_lisp && *that != '(')
+ if (!vi_lisp && *that != '(' && *that != '[')
firsttry++;
parencount = 0;
@@ -7499,16 +7511,18 @@ get_lisp_indent()
&& (!vim_iswhite(*that)
|| quotecount
|| parencount)
- && (!(*that == '('
+ && (!((*that == '(' || *that == '[')
&& !quotecount
&& !parencount
&& vi_lisp)))
{
if (*that == '"')
quotecount = !quotecount;
- if (*that == '(' && !quotecount)
+ if ((*that == '(' || *that == '[')
+ && !quotecount)
++parencount;
- if (*that == ')' && !quotecount)
+ if ((*that == ')' || *that == ']')
+ && !quotecount)
--parencount;
if (*that == '\\' && *(that+1) != NUL)
amount += lbr_chartabsize_adv(&that,
@@ -7530,7 +7544,7 @@ get_lisp_indent()
}
}
else
- amount = 0; /* no matching '(' found, use zero indent */
+ amount = 0; /* no matching '(' or '[' found, use zero indent */
curwin->w_cursor = realpos;