aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_docmd.c
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2022-08-21 18:49:46 -0600
committerJosh Rahm <joshuarahm@gmail.com>2022-08-21 18:49:46 -0600
commit8436383af96dc7afa3596fc22c012d68e76f47f8 (patch)
treeb67c79f3e01a6e48117ef9ec3e919ee1bbafbf11 /src/nvim/ex_docmd.c
parent629169462a82f0fbb7a8911a4554894537d6776c (diff)
downloadrneovim-8436383af96dc7afa3596fc22c012d68e76f47f8.tar.gz
rneovim-8436383af96dc7afa3596fc22c012d68e76f47f8.tar.bz2
rneovim-8436383af96dc7afa3596fc22c012d68e76f47f8.zip
feat(usermark); implement "user marks", i.e. marks whose behavior can be defined by the user.
(Neo)vim has many different marks defined, but sometimes this may not be completely adequate. This change give the user the ability to define behavior for marks which are not built in to (Neo)vim directly. This is accomplished through a new option called the "usermarkfunc." The usermarkfunc points to a vimscript function that takes an "action" paramter (either "get" or "set") and a mark name. a basic implementation that re-implements global mark behavior for user marks would look something like: let s:marks = {} function UserMarkFunc(action, mark) if a:action == "set" let [n, lnum, col, off, curswant] = getcurpos() let s:marks[a:mark] = \ { "line": lnum, "col": col, "file": expand("%:p") } else return s:marks[a:mark] endif endfunction set usermarkfunc=UserMarkFunc of course the user could make the behavior be whatever. It should also be noted that any valid unicode character can now be a mark. It is not just limited to ASCII characters.
Diffstat (limited to 'src/nvim/ex_docmd.c')
-rw-r--r--src/nvim/ex_docmd.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 4ac9847e53..0dde82c235 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -4017,7 +4017,7 @@ char *skip_range(const char *cmd, int *ctx)
}
}
if (*cmd != NUL) {
- ++cmd;
+ cmd += utf_ptr2len(cmd);
}
}
@@ -4162,13 +4162,13 @@ static linenr_T get_address(exarg_T *eap, char **ptr, cmd_addr_T addr_type, int
goto error;
}
if (skip) {
- ++cmd;
+ cmd += utfc_ptr2len(cmd);
} else {
// Only accept a mark in another file when it is
// used by itself: ":'M".
MarkGet flag = to_other_file && cmd[1] == NUL ? kMarkAll : kMarkBufLocal;
- fmark_T *fm = mark_get(curbuf, curwin, NULL, flag, *cmd);
- cmd++;
+ fmark_T *fm = mark_get(curbuf, curwin, NULL, flag, utf_ptr2char(cmd));
+ cmd += utf_ptr2len(cmd);
if (fm != NULL && fm->fnum != curbuf->handle) {
// Jumped to another file.
lnum = curwin->w_cursor.lnum;