summaryrefslogtreecommitdiffstats
path: root/src/mark.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2006-03-03 22:50:42 +0000
committerBram Moolenaar <Bram@vim.org>2006-03-03 22:50:42 +0000
commitbfb2d40b6ec0b8fff51bc6fadabf4aaeb383beb8 (patch)
tree12ef17978672a5981dbe661a5d0ba4dbfad3d8a6 /src/mark.c
parenta55252087b1b771b0a1a509d2ac90067404287d7 (diff)
updated for version 7.0213
Diffstat (limited to 'src/mark.c')
-rw-r--r--src/mark.c58
1 files changed, 46 insertions, 12 deletions
diff --git a/src/mark.c b/src/mark.c
index 98550b3d97..8a3d108d65 100644
--- a/src/mark.c
+++ b/src/mark.c
@@ -39,13 +39,27 @@ static void write_one_filemark __ARGS((FILE *fp, xfmark_T *fm, int c1, int c2));
#endif
/*
- * Set named mark 'c' at current cursor position.
+ * Set named mark "c" at current cursor position.
* Returns OK on success, FAIL if bad name given.
*/
int
setmark(c)
int c;
{
+ return setmark_pos(c, &curwin->w_cursor, curbuf->b_fnum);
+}
+
+/*
+ * Set named mark "c" to position "pos".
+ * When "c" is upper case use file "fnum".
+ * Returns OK on success, FAIL if bad name given.
+ */
+ int
+setmark_pos(c, pos, fnum)
+ int c;
+ pos_T *pos;
+ int fnum;
+{
int i;
/* Check for a special key (may cause islower() to crash). */
@@ -54,9 +68,14 @@ setmark(c)
if (c == '\'' || c == '`')
{
- setpcmark();
- /* keep it even when the cursor doesn't move */
- curwin->w_prev_pcmark = curwin->w_pcmark;
+ if (pos == &curwin->w_cursor)
+ {
+ setpcmark();
+ /* keep it even when the cursor doesn't move */
+ curwin->w_prev_pcmark = curwin->w_pcmark;
+ }
+ else
+ curwin->w_pcmark = *pos;
return OK;
}
@@ -64,12 +83,12 @@ setmark(c)
* file. */
if (c == '[')
{
- curbuf->b_op_start = curwin->w_cursor;
+ curbuf->b_op_start = *pos;
return OK;
}
if (c == ']')
{
- curbuf->b_op_end = curwin->w_cursor;
+ curbuf->b_op_end = *pos;
return OK;
}
@@ -81,14 +100,14 @@ setmark(c)
if (islower(c))
{
i = c - 'a';
- curbuf->b_namedm[i] = curwin->w_cursor;
+ curbuf->b_namedm[i] = *pos;
return OK;
}
if (isupper(c))
{
i = c - 'A';
- namedfm[i].fmark.mark = curwin->w_cursor;
- namedfm[i].fmark.fnum = curbuf->b_fnum;
+ namedfm[i].fmark.mark = *pos;
+ namedfm[i].fmark.fnum = fnum;
vim_free(namedfm[i].fname);
namedfm[i].fname = NULL;
return OK;
@@ -267,6 +286,9 @@ movechangelist(count)
/*
* Find mark "c".
+ * If "changefile" is TRUE it's allowed to edit another file for '0, 'A, etc.
+ * If "fnum" is not NULL store the fnum there for '0, 'A etc., don't edit
+ * another file.
* Returns:
* - pointer to pos_T if found. lnum is 0 when mark not set, -1 when mark is
* in another file which can't be gotten. (caller needs to check lnum!)
@@ -276,7 +298,16 @@ movechangelist(count)
pos_T *
getmark(c, changefile)
int c;
- int changefile; /* allowed to edit another file */
+ int changefile;
+{
+ return getmark_fnum(c, changefile, NULL);
+}
+
+ pos_T *
+getmark_fnum(c, changefile, fnum)
+ int c;
+ int changefile;
+ int *fnum;
{
pos_T *posp;
#ifdef FEAT_VISUAL
@@ -382,11 +413,14 @@ getmark(c, changefile)
if (namedfm[c].fmark.fnum == 0)
fname2fnum(&namedfm[c]);
- if (namedfm[c].fmark.fnum != curbuf->b_fnum)
+
+ if (fnum != NULL)
+ *fnum = namedfm[c].fmark.fnum;
+ else if (namedfm[c].fmark.fnum != curbuf->b_fnum)
{
+ /* mark is in another file */
posp = &pos_copy;
- /* mark is in another file */
if (namedfm[c].fmark.mark.lnum != 0
&& changefile && namedfm[c].fmark.fnum)
{