summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/buffer.c8
-rw-r--r--src/charset.c5
-rw-r--r--src/diff.c2
-rw-r--r--src/edit.c12
-rw-r--r--src/evalfunc.c8
-rw-r--r--src/ex_cmds.c31
-rw-r--r--src/ex_getln.c8
-rw-r--r--src/fileio.c4
-rw-r--r--src/fold.c2
-rw-r--r--src/gui.c4
-rw-r--r--src/gui_beval.c4
-rw-r--r--src/if_perl.xs2
-rw-r--r--src/macros.h30
-rw-r--r--src/main.c5
-rw-r--r--src/mark.c17
-rw-r--r--src/misc1.c8
-rw-r--r--src/move.c2
-rw-r--r--src/normal.c71
-rw-r--r--src/ops.c22
-rw-r--r--src/option.c2
-rw-r--r--src/popupmnu.c2
-rw-r--r--src/regexp.c4
-rw-r--r--src/screen.c4
-rw-r--r--src/search.c79
-rw-r--r--src/spell.c4
-rw-r--r--src/tag.c2
-rw-r--r--src/ui.c6
-rw-r--r--src/undo.c6
-rw-r--r--src/version.c4
-rw-r--r--src/workshop.c2
30 files changed, 194 insertions, 166 deletions
diff --git a/src/buffer.c b/src/buffer.c
index c25cb2f1a3..ca3be14a93 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -111,7 +111,7 @@ read_buffer(
{
/* Set or reset 'modified' before executing autocommands, so that
* it can be changed there. */
- if (!readonlymode && !bufempty())
+ if (!readonlymode && !BUFEMPTY())
changed();
else if (retval == OK)
unchanged(curbuf, FALSE);
@@ -1959,7 +1959,7 @@ buflist_new(
&& curbuf != NULL
&& curbuf->b_ffname == NULL
&& curbuf->b_nwindows <= 1
- && (curbuf->b_ml.ml_mfp == NULL || bufempty()))
+ && (curbuf->b_ml.ml_mfp == NULL || BUFEMPTY()))
{
buf = curbuf;
#ifdef FEAT_AUTOCMD
@@ -2334,7 +2334,7 @@ buflist_getfile(
/* If 'switchbuf' contains "split", "vsplit" or "newtab" and the
* current buffer isn't empty: open new tab or window */
if (wp == NULL && (swb_flags & (SWB_VSPLIT | SWB_SPLIT | SWB_NEWTAB))
- && !bufempty())
+ && !BUFEMPTY())
{
if (swb_flags & SWB_NEWTAB)
tabpage_new();
@@ -5017,7 +5017,7 @@ do_arg_all(
#ifdef FEAT_WINDOWS
/* ":drop all" should re-use an empty window to avoid "--remote-tab"
* leaving an empty tab page when executed locally. */
- if (keep_tabs && bufempty() && curbuf->b_nwindows == 1
+ if (keep_tabs && BUFEMPTY() && curbuf->b_nwindows == 1
&& curbuf->b_ffname == NULL && !curbuf->b_changed)
use_firstwin = TRUE;
#endif
diff --git a/src/charset.c b/src/charset.c
index 984d7653e7..1e1b8b1af8 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -1403,7 +1403,8 @@ getvcol(
&& (State & NORMAL)
&& !wp->w_p_list
&& !virtual_active()
- && !(VIsual_active && (*p_sel == 'e' || ltoreq(*pos, VIsual)))
+ && !(VIsual_active
+ && (*p_sel == 'e' || LTOREQ_POS(*pos, VIsual)))
)
*cursor = vcol + incr - 1; /* cursor at end */
else
@@ -1496,7 +1497,7 @@ getvcols(
{
colnr_T from1, from2, to1, to2;
- if (ltp(pos1, pos2))
+ if (LT_POSP(pos1, pos2))
{
getvvcol(wp, pos1, &from1, NULL, &to1);
getvvcol(wp, pos2, &from2, NULL, &to2);
diff --git a/src/diff.c b/src/diff.c
index 435269984e..8c70e0cab1 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -2333,7 +2333,7 @@ ex_diffgetput(exarg_T *eap)
end_skip = 0;
}
- buf_empty = bufempty();
+ buf_empty = BUFEMPTY();
added = 0;
for (i = 0; i < count; ++i)
{
diff --git a/src/edit.c b/src/edit.c
index 065b030f6b..7082b9adcb 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -408,7 +408,7 @@ edit(
* the "A" command, thus set State to avoid that. Also check that the
* line number is still valid (lines may have been deleted).
* Do not restore if v:char was set to a non-empty string. */
- if (!equalpos(curwin->w_cursor, save_cursor)
+ if (!EQUAL_POS(curwin->w_cursor, save_cursor)
# ifdef FEAT_EVAL
&& *get_vim_var_str(VV_CHAR) == NUL
# endif
@@ -1631,7 +1631,7 @@ ins_redraw(
# endif
)
# ifdef FEAT_AUTOCMD
- && !equalpos(last_cursormoved, curwin->w_cursor)
+ && !EQUAL_POS(last_cursormoved, curwin->w_cursor)
# endif
# ifdef FEAT_INS_EXPAND
&& !pum_visible()
@@ -4130,7 +4130,7 @@ expand_by_function(
}
curwin->w_cursor = pos; /* restore the cursor position */
validate_cursor();
- if (!equalpos(curwin->w_cursor, pos))
+ if (!EQUAL_POS(curwin->w_cursor, pos))
{
EMSG(_(e_compldel));
goto theend;
@@ -5408,7 +5408,7 @@ ins_complete(int c, int enable_pum)
}
curwin->w_cursor = pos; /* restore the cursor position */
validate_cursor();
- if (!equalpos(curwin->w_cursor, pos))
+ if (!EQUAL_POS(curwin->w_cursor, pos))
{
EMSG(_(e_compldel));
return FAIL;
@@ -8947,7 +8947,7 @@ ins_bs(
* can't backup past starting point unless 'backspace' > 1
* can backup to a previous line if 'backspace' == 0
*/
- if ( bufempty()
+ if ( BUFEMPTY()
|| (
#ifdef FEAT_RIGHTLEFT
!revins_on &&
@@ -9462,7 +9462,7 @@ ins_mousescroll(int dir)
}
# endif
- if (!equalpos(curwin->w_cursor, tpos))
+ if (!EQUAL_POS(curwin->w_cursor, tpos))
{
start_arrow(&tpos);
# ifdef FEAT_CINDENT
diff --git a/src/evalfunc.c b/src/evalfunc.c
index c30b57ba14..7e03d4d3eb 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -9552,20 +9552,20 @@ do_searchpair(
save_cursor = curwin->w_cursor;
pos = curwin->w_cursor;
- clearpos(&firstpos);
- clearpos(&foundpos);
+ CLEAR_POS(&firstpos);
+ CLEAR_POS(&foundpos);
pat = pat3;
for (;;)
{
n = searchit(curwin, curbuf, &pos, dir, pat, 1L,
options, RE_SEARCH, lnum_stop, &tm);
- if (n == FAIL || (firstpos.lnum != 0 && equalpos(pos, firstpos)))
+ if (n == FAIL || (firstpos.lnum != 0 && EQUAL_POS(pos, firstpos)))
/* didn't find it or found the first match again: FAIL */
break;
if (firstpos.lnum == 0)
firstpos = pos;
- if (equalpos(pos, foundpos))
+ if (EQUAL_POS(pos, foundpos))
{
/* Found the same position again. Can happen with a pattern that
* has "\zs" at the end and searching backwards. Advance one
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index c38687d740..05575ef70c 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -851,24 +851,41 @@ do_move(linenr_T line1, linenr_T line2, linenr_T dest)
* their final destination at the new text position -- webb
*/
last_line = curbuf->b_ml.ml_line_count;
- mark_adjust(line1, line2, last_line - line2, 0L);
- changed_lines(last_line - num_lines + 1, 0, last_line + 1, num_lines);
+ mark_adjust_nofold(line1, line2, last_line - line2, 0L);
if (dest >= line2)
{
- mark_adjust(line2 + 1, dest, -num_lines, 0L);
+ mark_adjust_nofold(line2 + 1, dest, -num_lines, 0L);
+#ifdef FEAT_FOLDING
+ win_T *win;
+ tabpage_T *tp;
+
+ FOR_ALL_TAB_WINDOWS(tp, win) {
+ if (win->w_buffer == curbuf)
+ foldSwapRange(&win->w_folds, line1, line2, dest + 1,
+ dest + num_lines);
+ }
+#endif
curbuf->b_op_start.lnum = dest - num_lines + 1;
curbuf->b_op_end.lnum = dest;
}
else
{
- mark_adjust(dest + 1, line1 - 1, num_lines, 0L);
+ mark_adjust_nofold(dest + 1, line1 - 1, num_lines, 0L);
+#ifdef FEAT_FOLDING
+ win_T *win;
+ tabpage_T *tp;
+
+ FOR_ALL_TAB_WINDOWS(tp, win) {
+ if (win->w_buffer == curbuf)
+ foldSwapRange(&win->w_folds, dest + 1, line1 - 1, line1, line2);
+ }
+#endif
curbuf->b_op_start.lnum = dest + 1;
curbuf->b_op_end.lnum = dest + num_lines;
}
curbuf->b_op_start.col = curbuf->b_op_end.col = 0;
- mark_adjust(last_line - num_lines + 1, last_line,
+ mark_adjust_nofold(last_line - num_lines + 1, last_line,
-(last_line - dest - extra), 0L);
- changed_lines(last_line - num_lines + 1, 0, last_line + 1, -extra);
/*
* Now we delete the original text -- webb
@@ -4211,7 +4228,7 @@ do_ecmd(
/* If autocommands change the cursor position or topline, we should
* keep it. Also when it moves within a line. */
- if (!equalpos(curwin->w_cursor, orig_pos))
+ if (!EQUAL_POS(curwin->w_cursor, orig_pos))
{
newlnum = curwin->w_cursor.lnum;
newcol = curwin->w_cursor.col;
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 9180319148..d3fda24c87 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -234,7 +234,7 @@ getcmdline(
ccline.overstrike = FALSE; /* always start in insert mode */
#ifdef FEAT_SEARCH_EXTRA
- clearpos(&match_end);
+ CLEAR_POS(&match_end);
save_cursor = curwin->w_cursor; /* may be restored later */
search_start = curwin->w_cursor;
old_curswant = curwin->w_curswant;
@@ -1479,7 +1479,7 @@ getcmdline(
if (did_incsearch)
{
curwin->w_cursor = match_end;
- if (!equalpos(curwin->w_cursor, search_start))
+ if (!EQUAL_POS(curwin->w_cursor, search_start))
{
c = gchar_cursor();
/* If 'ignorecase' and 'smartcase' are set and the
@@ -1707,7 +1707,7 @@ getcmdline(
search_start = t;
(void)decl(&search_start);
}
- if (lt(t, search_start) && c == Ctrl_G)
+ if (LT_POS(t, search_start) && c == Ctrl_G)
{
/* wrap around */
search_start = t;
@@ -2007,7 +2007,7 @@ returncmd:
curwin->w_cursor = save_cursor;
else
{
- if (!equalpos(save_cursor, search_start))
+ if (!EQUAL_POS(save_cursor, search_start))
{
/* put the '" mark at the original position */
curwin->w_cursor = save_cursor;
diff --git a/src/fileio.c b/src/fileio.c
index 2001c0d9a5..48955e01ce 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -7118,7 +7118,7 @@ buf_reload(buf_T *buf, int orig_mode)
* the old contents. Can't use memory only, the file might be
* too big. Use a hidden buffer to move the buffer contents to.
*/
- if (bufempty() || saved == FAIL)
+ if (BUFEMPTY() || saved == FAIL)
savebuf = NULL;
else
{
@@ -7161,7 +7161,7 @@ buf_reload(buf_T *buf, int orig_mode)
{
/* Put the text back from the save buffer. First
* delete any lines that readfile() added. */
- while (!bufempty())
+ while (!BUFEMPTY())
if (ml_delete(buf->b_ml.ml_line_count, FALSE) == FAIL)
break;
(void)move_lines(savebuf, buf);
diff --git a/src/fold.c b/src/fold.c
index d75e937003..db8da63ed1 100644
--- a/src/fold.c
+++ b/src/fold.c
@@ -1039,7 +1039,7 @@ foldAdjustVisual(void)
if (!VIsual_active || !hasAnyFolding(curwin))
return;
- if (ltoreq(VIsual, curwin->w_cursor))
+ if (LTOREQ_POS(VIsual, curwin->w_cursor))
{
start = &VIsual;
end = &curwin->w_cursor;
diff --git a/src/gui.c b/src/gui.c
index 203035f5d2..36d6975ed4 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -4476,7 +4476,7 @@ gui_do_scroll(void)
pum_redraw();
#endif
- return (wp == curwin && !equalpos(curwin->w_cursor, old_cursor));
+ return (wp == curwin && !EQUAL_POS(curwin->w_cursor, old_cursor));
}
@@ -5118,7 +5118,7 @@ gui_update_screen(void)
curwin->w_p_cole > 0
# endif
)
- && !equalpos(last_cursormoved, curwin->w_cursor))
+ && !EQUAL_POS(last_cursormoved, curwin->w_cursor))
{
# ifdef FEAT_AUTOCMD
if (has_cursormoved())
diff --git a/src/gui_beval.c b/src/gui_beval.c
index dd619450e5..c06e75a094 100644
--- a/src/gui_beval.c
+++ b/src/gui_beval.c
@@ -84,7 +84,7 @@ general_beval_cb(BalloonEval *beval, int state UNUSED)
result = eval_to_string(bexpr, NULL, TRUE);
/* Remove one trailing newline, it is added when the result was a
- * list and it's hardly every useful. If the user really wants a
+ * list and it's hardly ever useful. If the user really wants a
* trailing newline he can add two and one remains. */
if (result != NULL)
{
@@ -366,7 +366,7 @@ get_beval_info(
if (VIsual_active)
{
- if (lt(VIsual, curwin->w_cursor))
+ if (LT_POS(VIsual, curwin->w_cursor))
{
spos = &VIsual;
epos = &curwin->w_cursor;
diff --git a/src/if_perl.xs b/src/if_perl.xs
index ecb9726e3b..076c5c6019 100644
--- a/src/if_perl.xs
+++ b/src/if_perl.xs
@@ -1288,7 +1288,7 @@ ex_perldo(exarg_T *eap)
linenr_T i;
buf_T *was_curbuf = curbuf;
- if (bufempty())
+ if (BUFEMPTY())
return;
if (perl_interp == NULL)
diff --git a/src/macros.h b/src/macros.h
index faa8ccc9c5..559a4bef02 100644
--- a/src/macros.h
+++ b/src/macros.h
@@ -11,46 +11,46 @@
*/
/*
- * pchar(lp, c) - put character 'c' at position 'lp'
+ * PCHAR(lp, c) - put character 'c' at position 'lp'
*/
-#define pchar(lp, c) (*(ml_get_buf(curbuf, (lp).lnum, TRUE) + (lp).col) = (c))
+#define PCHAR(lp, c) (*(ml_get_buf(curbuf, (lp).lnum, TRUE) + (lp).col) = (c))
/*
* Position comparisons
*/
#ifdef FEAT_VIRTUALEDIT
-# define lt(a, b) (((a).lnum != (b).lnum) \
+# define LT_POS(a, b) (((a).lnum != (b).lnum) \
? (a).lnum < (b).lnum \
: (a).col != (b).col \
? (a).col < (b).col \
: (a).coladd < (b).coladd)
-# define ltp(a, b) (((a)->lnum != (b)->lnum) \
+# define LT_POSP(a, b) (((a)->lnum != (b)->lnum) \
? (a)->lnum < (b)->lnum \
: (a)->col != (b)->col \
? (a)->col < (b)->col \
: (a)->coladd < (b)->coladd)
-# define equalpos(a, b) (((a).lnum == (b).lnum) && ((a).col == (b).col) && ((a).coladd == (b).coladd))
-# define clearpos(a) {(a)->lnum = 0; (a)->col = 0; (a)->coladd = 0;}
+# define EQUAL_POS(a, b) (((a).lnum == (b).lnum) && ((a).col == (b).col) && ((a).coladd == (b).coladd))
+# define CLEAR_POS(a) {(a)->lnum = 0; (a)->col = 0; (a)->coladd = 0;}
#else
-# define lt(a, b) (((a).lnum != (b).lnum) \
+# define LT_POS(a, b) (((a).lnum != (b).lnum) \
? ((a).lnum < (b).lnum) : ((a).col < (b).col))
-# define ltp(a, b) (((a)->lnum != (b)->lnum) \
+# define LT_POSP(a, b) (((a)->lnum != (b)->lnum) \
? ((a)->lnum < (b)->lnum) : ((a)->col < (b)->col))
-# define equalpos(a, b) (((a).lnum == (b).lnum) && ((a).col == (b).col))
-# define clearpos(a) {(a)->lnum = 0; (a)->col = 0;}
+# define EQUAL_POS(a, b) (((a).lnum == (b).lnum) && ((a).col == (b).col))
+# define CLEAR_POS(a) {(a)->lnum = 0; (a)->col = 0;}
#endif
-#define ltoreq(a, b) (lt(a, b) || equalpos(a, b))
+#define LTOREQ_POS(a, b) (LT_POS(a, b) || EQUAL_POS(a, b))
/*
- * lineempty() - return TRUE if the line is empty
+ * LINEEMPTY() - return TRUE if the line is empty
*/
-#define lineempty(p) (*ml_get(p) == NUL)
+#define LINEEMPTY(p) (*ml_get(p) == NUL)
/*
- * bufempty() - return TRUE if the current buffer is empty
+ * BUFEMPTY() - return TRUE if the current buffer is empty
*/
-#define bufempty() (curbuf->b_ml.ml_line_count == 1 && *ml_get((linenr_T)1) == NUL)
+#define BUFEMPTY() (curbuf->b_ml.ml_line_count == 1 && *ml_get((linenr_T)1) == NUL)
/*
* toupper() and tolower() that use the current locale.
diff --git a/src/main.c b/src/main.c
index 2f8d291bfe..f96bca99d8 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1144,7 +1144,7 @@ main_loop(
# endif
)
# ifdef FEAT_AUTOCMD
- && !equalpos(last_cursormoved, curwin->w_cursor)
+ && !EQUAL_POS(last_cursormoved, curwin->w_cursor)
# endif
)
{
@@ -3557,8 +3557,11 @@ set_progpath(char_u *argv0)
&& vim_FullName(argv0, buf, MAXPATHL, TRUE) != FAIL)
val = buf;
}
+# endif
# endif
+
set_vim_var_string(VV_PROGPATH, val, -1);
+
# ifdef WIN32
vim_free(path);
# endif
diff --git a/src/mark.c b/src/mark.c
index 59ac01dc51..0265160ab1 100644
--- a/src/mark.c
+++ b/src/mark.c
@@ -206,7 +206,7 @@ setpcmark(void)
checkpcmark(void)
{
if (curwin->w_prev_pcmark.lnum != 0
- && (equalpos(curwin->w_pcmark, curwin->w_cursor)
+ && (EQUAL_POS(curwin->w_pcmark, curwin->w_cursor)
|| curwin->w_pcmark.lnum == 0))
{
curwin->w_pcmark = curwin->w_prev_pcmark;
@@ -401,7 +401,7 @@ getmark_buf_fnum(
{
startp = &buf->b_visual.vi_start;
endp = &buf->b_visual.vi_end;
- if (((c == '<') == lt(*startp, *endp) || endp->lnum == 0)
+ if (((c == '<') == LT_POS(*startp, *endp) || endp->lnum == 0)
&& startp->lnum != 0)
posp = startp;
else
@@ -497,14 +497,14 @@ getnextmark(
{
if (dir == FORWARD)
{
- if ((result == NULL || lt(curbuf->b_namedm[i], *result))
- && lt(pos, curbuf->b_namedm[i]))
+ if ((result == NULL || LT_POS(curbuf->b_namedm[i], *result))
+ && LT_POS(pos, curbuf->b_namedm[i]))
result = &curbuf->b_namedm[i];
}
else
{
- if ((result == NULL || lt(*result, curbuf->b_namedm[i]))
- && lt(curbuf->b_namedm[i], pos))
+ if ((result == NULL || LT_POS(*result, curbuf->b_namedm[i]))
+ && LT_POS(curbuf->b_namedm[i], pos))
result = &curbuf->b_namedm[i];
}
}
@@ -1063,7 +1063,7 @@ mark_adjust(
one_adjust(&(curbuf->b_last_change.lnum));
/* last cursor position, if it was set */
- if (!equalpos(curbuf->b_last_cursor, initpos))
+ if (!EQUAL_POS(curbuf->b_last_cursor, initpos))
one_adjust(&(curbuf->b_last_cursor.lnum));
@@ -1838,7 +1838,8 @@ write_buffer_marks(buf_T *buf, FILE *fp_out)
for (i = 0; i < buf->b_changelistlen; ++i)
{
/* skip duplicates */
- if (i == 0 || !equalpos(buf->b_changelist[i - 1], buf->b_changelist[i]))
+ if (i == 0 || !EQUAL_POS(buf->b_changelist[i - 1],
+ buf->b_changelist[i]))
write_one_mark(fp_out, '+', &buf->b_changelist[i]);
}
#endif
diff --git a/src/misc1.c b/src/misc1.c
index c6b8d13b78..e862219ab8 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -5272,7 +5272,8 @@ ind_find_start_CORS(void) /* XXX */
/* If comment_pos is before rs_pos the raw string is inside the comment.
* If rs_pos is before comment_pos the comment is inside the raw string. */
- if (comment_pos == NULL || (rs_pos != NULL && lt(*rs_pos, *comment_pos)))
+ if (comment_pos == NULL || (rs_pos != NULL
+ && LT_POS(*rs_pos, *comment_pos)))
return rs_pos;
return comment_pos;
}
@@ -7217,7 +7218,8 @@ get_c_indent(void)
comment_pos = &tryposCopy;
}
trypos = find_start_rawstring(curbuf->b_ind_maxcomment);
- if (trypos != NULL && (comment_pos == NULL || lt(*trypos, *comment_pos)))
+ if (trypos != NULL && (comment_pos == NULL
+ || LT_POS(*trypos, *comment_pos)))
{
amount = -1;
goto laterend;
@@ -9352,7 +9354,7 @@ get_lisp_indent(void)
{
paren = *pos;
pos = findmatch(NULL, '[');
- if (pos == NULL || ltp(pos, &paren))
+ if (pos == NULL || LT_POSP(pos, &paren))
pos = &paren;
}
if (pos != NULL)
diff --git a/src/move.c b/src/move.c
index c4f21a7864..3d6d2ec8f4 100644
--- a/src/move.c
+++ b/src/move.c
@@ -210,7 +210,7 @@ update_topline(void)
/*
* If the buffer is empty, always set topline to 1.
*/
- if (bufempty()) /* special case - file is empty */
+ if (BUFEMPTY()) /* special case - file is empty */
{
if (curwin->w_topline != 1)
redraw_later(NOT_VALID);
diff --git a/src/normal.c b/src/normal.c
index c8385f6a84..7701fcf5b2 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -1540,7 +1540,7 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
if (VIsual_select && VIsual_mode == 'V'
&& cap->oap->op_type != OP_DELETE)
{
- if (lt(VIsual, curwin->w_cursor))
+ if (LT_POS(VIsual, curwin->w_cursor))
{
VIsual.col = 0;
curwin->w_cursor.col =
@@ -1572,7 +1572,7 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
* Set oap->start to the first position of the operated text, oap->end
* to the end of the operated text. w_cursor is equal to oap->start.
*/
- if (lt(oap->start, curwin->w_cursor))
+ if (LT_POS(oap->start, curwin->w_cursor))
{
#ifdef FEAT_FOLDING
/* Include folded lines completely. */
@@ -1776,7 +1776,7 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
&& (!oap->inclusive
|| (oap->op_type == OP_YANK
&& gchar_pos(&oap->end) == NUL))
- && equalpos(oap->start, oap->end)
+ && EQUAL_POS(oap->start, oap->end)
#ifdef FEAT_VIRTUALEDIT
&& !(virtual_op && oap->start.coladd != oap->end.coladd)
#endif
@@ -2683,12 +2683,12 @@ do_mouse(
jump_flags = MOUSE_MAY_STOP_VIS;
else
{
- if ((lt(curwin->w_cursor, VIsual)
- && (lt(m_pos, curwin->w_cursor)
- || lt(VIsual, m_pos)))
- || (lt(VIsual, curwin->w_cursor)
- && (lt(m_pos, VIsual)
- || lt(curwin->w_cursor, m_pos))))
+ if ((LT_POS(curwin->w_cursor, VIsual)
+ && (LT_POS(m_pos, curwin->w_cursor)
+ || LT_POS(VIsual, m_pos)))
+ || (LT_POS(VIsual, curwin->w_cursor)
+ && (LT_POS(m_pos, VIsual)
+ || LT_POS(curwin->w_cursor, m_pos))))
{
jump_flags = MOUSE_MAY_STOP_VIS;
}
@@ -2754,7 +2754,7 @@ do_mouse(
* Remember the start and end of visual before moving the
* cursor.
*/
- if (lt(curwin->w_cursor, VIsual))
+ if (LT_POS(curwin->w_cursor, VIsual))
{
start_visual = curwin->w_cursor;
end_visual = VIsual;
@@ -2891,9 +2891,9 @@ do_mouse(
* If the click is after the end of visual, change the end. If
* the click is inside the visual, change the closest side.
*/
- if (lt(curwin->w_cursor, start_visual))
+ if (LT_POS(curwin->w_cursor, start_visual))
VIsual = end_visual;
- else if (lt(end_visual, curwin->w_cursor))
+ else if (LT_POS(end_visual, curwin->w_cursor))
VIsual = start_visual;
else
{
@@ -3097,7 +3097,7 @@ do_mouse(
if (oap != NULL
&& VIsual_mode == 'v'
&& !vim_iswordc(gchar_pos(&end_visual))
- && equalpos(curwin->w_cursor, VIsual)
+ && EQUAL_POS(curwin->w_cursor, VIsual)
&& (pos = findmatch(oap, NUL)) != NULL)
{
curwin->w_cursor = *pos;
@@ -3105,7 +3105,7 @@ do_mouse(
VIsual_mode = 'V';
else if (*p_sel == 'e')
{
- if (lt(curwin->w_cursor, VIsual))
+ if (LT_POS(curwin->w_cursor, VIsual))
++VIsual.col;
else
++curwin->w_cursor.col;
@@ -3117,7 +3117,7 @@ do_mouse(
{
/* When not found a match or when dragging: extend to include
* a word. */
- if (lt(curwin->w_cursor, orig_cursor))
+ if (LT_POS(curwin->w_cursor, orig_cursor))
{
find_start_of_word(&curwin->w_cursor);
find_end_of_word(&VIsual);
@@ -3745,7 +3745,7 @@ clear_showcmd(void)
if (VIsual_active && !char_avail())
{
- int cursor_bot = lt(VIsual, curwin->w_cursor);
+ int cursor_bot = LT_POS(VIsual, curwin->w_cursor);
long lines;
colnr_T leftcol, rightcol;
linenr_T top, bot;
@@ -4353,7 +4353,7 @@ find_decl(
curwin->w_cursor.col = 0;
/* Search forward for the identifier, ignore comment lines. */
- clearpos(&found_pos);
+ CLEAR_POS(&found_pos);
for (;;)
{
valid = FALSE;
@@ -4419,13 +4419,10 @@ find_decl(
* declarations this skips the function header without types. */
if (!valid)
{
- /* Braces needed due to macro expansion of clearpos. */
- clearpos(&found_pos);
+ CLEAR_POS(&found_pos);
}
else
- {
found_pos = curwin->w_cursor;
- }
/* Remove SEARCH_START from flags to avoid getting stuck at one
* position. */
searchflags &= ~SEARCH_START;
@@ -5834,7 +5831,7 @@ get_visual_text(
}
else
{
- if (lt(curwin->w_cursor, VIsual))
+ if (LT_POS(curwin->w_cursor, VIsual))
{
*pp = ml_get_pos(&curwin->w_cursor);
*lenp = VIsual.col - curwin->w_cursor.col + 1;
@@ -6020,7 +6017,7 @@ nv_right(cmdarg_T *cap)
* included, move to next line after that */
if ( cap->oap->op_type != OP_NOP
&& !cap->oap->inclusive
- && !lineempty(curwin->w_cursor.lnum))
+ && !LINEEMPTY(curwin->w_cursor.lnum))
cap->oap->inclusive = TRUE;
else
{
@@ -6042,7 +6039,7 @@ nv_right(cmdarg_T *cap)
}
else
{
- if (!lineempty(curwin->w_cursor.lnum))
+ if (!LINEEMPTY(curwin->w_cursor.lnum))
cap->oap->inclusive = TRUE;
}
break;
@@ -6121,7 +6118,7 @@ nv_left(cmdarg_T *cap)
* Don't adjust op_end now, otherwise it won't work. */
if ( (cap->oap->op_type == OP_DELETE
|| cap->oap->op_type == OP_CHANGE)
- && !lineempty(curwin->w_cursor.lnum))
+ && !LINEEMPTY(curwin->w_cursor.lnum))
{
char_u *cp = ml_get_cursor();
@@ -6333,7 +6330,7 @@ nv_search(cmdarg_T *cap)
}
(void)normal_search(cap, cap->cmdchar, cap->searchbuf,
- (cap->arg || !equalpos(save_cursor, curwin->w_cursor))
+ (cap->arg || !EQUAL_POS(save_cursor, curwin->w_cursor))
? 0 : SEARCH_MARK);
}
@@ -6347,7 +6344,7 @@ nv_next(cmdarg_T *cap)
pos_T old = curwin->w_cursor;
int i = normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg);
- if (i == 1 && equalpos(old, curwin->w_cursor))
+ if (i == 1 && EQUAL_POS(old, curwin->w_cursor))
{
/* Avoid getting stuck on the current cursor position, which can
* happen when an offset is given and the cursor is on the last char
@@ -6689,9 +6686,9 @@ nv_brackets(cmdarg_T *cap)
if (VIsual_active)
{
- start = ltoreq(VIsual, curwin->w_cursor)
+ start = LTOREQ_POS(VIsual, curwin->w_cursor)
? VIsual : curwin->w_cursor;
- end = equalpos(start,VIsual) ? curwin->w_cursor : VIsual;
+ end = EQUAL_POS(start,VIsual) ? curwin->w_cursor : VIsual;
curwin->w_cursor = (dir == BACKWARD ? start : end);
}
# ifdef FEAT_CLIPBOARD
@@ -7315,7 +7312,7 @@ n_swapchar(cmdarg_T *cap)
if (checkclearopq(cap->oap))
return;
- if (lineempty(curwin->w_cursor.lnum) && vim_strchr(p_ww, '~') == NULL)
+ if (LINEEMPTY(curwin->w_cursor.lnum) && vim_strchr(p_ww, '~') == NULL)
{
clearopbeep(cap->oap);
return;
@@ -7559,7 +7556,7 @@ nv_gomark(cmdarg_T *cap)
#ifdef FEAT_FOLDING
if (cap->oap->op_type == OP_NOP
&& pos != NULL
- && (pos == (pos_T *)-1 || !equalpos(old_cursor, *pos))
+ && (pos == (pos_T *)-1 || !EQUAL_POS(old_cursor, *pos))
&& (fdo_flags & FDO_MARK)
&& old_KeyTyped)
foldOpenCursor();
@@ -8763,7 +8760,7 @@ nv_wordcmd(cmdarg_T *cap)
/* Don't leave the cursor on the NUL past the end of line. Unless we
* didn't move it forward. */
- if (lt(startpos, curwin->w_cursor))
+ if (LT_POS(startpos, curwin->w_cursor))
adjust_cursor(cap->oap);
if (n == FAIL && cap->oap->op_type == OP_NOP)
@@ -8833,7 +8830,7 @@ nv_beginline(cmdarg_T *cap)
adjust_for_sel(cmdarg_T *cap)
{
if (VIsual_active && cap->oap->inclusive && *p_sel == 'e'
- && gchar_cursor() != NUL && lt(VIsual, curwin->w_cursor))
+ && gchar_cursor() != NUL && LT_POS(VIsual, curwin->w_cursor))
{
#ifdef FEAT_MBYTE
if (has_mbyte)
@@ -8855,9 +8852,9 @@ unadjust_for_sel(void)
{
pos_T *pp;
- if (*p_sel == 'e' && !equalpos(VIsual, curwin->w_cursor))
+ if (*p_sel == 'e' && !EQUAL_POS(VIsual, curwin->w_cursor))
{
- if (lt(VIsual, curwin->w_cursor))
+ if (LT_POS(VIsual, curwin->w_cursor))
pp = &curwin->w_cursor;
else
pp = &VIsual;
@@ -9071,8 +9068,8 @@ nv_edit(cmdarg_T *cap)
/* When the last char in the line was deleted then append. Detect this
* by checking if the cursor moved to before the Visual area. */
- if (*ml_get_cursor() != NUL && lt(curwin->w_cursor, old_pos)
- && lt(curwin->w_cursor, old_visual))
+ if (*ml_get_cursor() != NUL && LT_POS(curwin->w_cursor, old_pos)
+ && LT_POS(curwin->w_cursor, old_visual))
inc_cursor();
/* Insert to replace the deleted text with the pasted text. */
diff --git a/src/ops.c b/src/ops.c
index 757c115497..8b883aa305 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -2190,7 +2190,7 @@ op_replace(oparg_T *oap, int c)
else if (!oap->inclusive)
dec(&(oap->end));
- while (ltoreq(curwin->w_cursor, oap->end))
+ while (LTOREQ_POS(curwin->w_cursor, oap->end))
{
n = gchar_cursor();
if (n != NUL)
@@ -2229,7 +2229,7 @@ op_replace(oparg_T *oap, int c)
getvpos(&oap->end, end_vcol