aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/private/helpers.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-05-12 13:04:48 +0200
committerJustin M. Keyes <justinkz@gmail.com>2019-05-12 13:04:48 +0200
commitf35d233e077539a4ae8591a7a05b4df0f3d598d3 (patch)
tree0dd4dcccc0368d83dea20b98e8b161218c6d0656 /src/nvim/api/private/helpers.c
parentfbf2c414ad3409e8359ff744765e7486043bb4f7 (diff)
downloadrneovim-f35d233e077539a4ae8591a7a05b4df0f3d598d3.tar.gz
rneovim-f35d233e077539a4ae8591a7a05b4df0f3d598d3.tar.bz2
rneovim-f35d233e077539a4ae8591a7a05b4df0f3d598d3.zip
API/nvim_set_keymap: minor cleanup
ref #9924
Diffstat (limited to 'src/nvim/api/private/helpers.c')
-rw-r--r--src/nvim/api/private/helpers.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index aa9b3f5f18..2bd51f71d7 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -770,7 +770,7 @@ void modify_keymap(Buffer buffer, bool is_unmap, String mode, String lhs,
MapArguments parsed_args;
memset(&parsed_args, 0, sizeof(parsed_args));
if (parse_keymap_opts(opts, &parsed_args, err)) {
- goto FAIL_AND_FREE;
+ goto fail_and_free;
}
parsed_args.buffer = !global;
@@ -782,14 +782,14 @@ void modify_keymap(Buffer buffer, bool is_unmap, String mode, String lhs,
err_msg = "LHS exceeds maximum map length: %s";
err_arg = lhs.data;
err_type = kErrorTypeValidation;
- goto FAIL_WITH_MESSAGE;
+ goto fail_with_message;
}
if (mode.size > 1) {
err_msg = "Shortname is too long: %s";
err_arg = mode.data;
err_type = kErrorTypeValidation;
- goto FAIL_WITH_MESSAGE;
+ goto fail_with_message;
}
int mode_val; // integer value of the mapping mode, to be passed to do_map()
char_u *p = (char_u *)((mode.size) ? mode.data : "m");
@@ -804,7 +804,7 @@ void modify_keymap(Buffer buffer, bool is_unmap, String mode, String lhs,
err_msg = "Invalid mode shortname: %s";
err_arg = (char *)p;
err_type = kErrorTypeValidation;
- goto FAIL_WITH_MESSAGE;
+ goto fail_with_message;
}
}
}
@@ -813,7 +813,7 @@ void modify_keymap(Buffer buffer, bool is_unmap, String mode, String lhs,
err_msg = "Invalid (empty) LHS";
err_arg = "";
err_type = kErrorTypeValidation;
- goto FAIL_WITH_MESSAGE;
+ goto fail_with_message;
}
bool is_noremap = parsed_args.noremap;
@@ -829,16 +829,16 @@ void modify_keymap(Buffer buffer, bool is_unmap, String mode, String lhs,
err_msg = "Parsing of nonempty RHS failed: %s";
err_arg = rhs.data;
err_type = kErrorTypeException;
- goto FAIL_WITH_MESSAGE;
+ goto fail_with_message;
}
} else if (is_unmap && parsed_args.rhs_len) {
err_msg = "Gave nonempty RHS in unmap command: %s";
err_arg = (char *)parsed_args.rhs;
err_type = kErrorTypeValidation;
- goto FAIL_WITH_MESSAGE;
+ goto fail_with_message;
}
- // buf_do_map_explicit reads noremap/unmap as its own argument
+ // buf_do_map() reads noremap/unmap as its own argument.
int maptype_val = 0;
if (is_unmap) {
maptype_val = 1;
@@ -846,23 +846,22 @@ void modify_keymap(Buffer buffer, bool is_unmap, String mode, String lhs,
maptype_val = 2;
}
- switch (buf_do_map_explicit(maptype_val, &parsed_args, mode_val,
- 0, target_buf)) {
+ switch (buf_do_map(maptype_val, &parsed_args, mode_val, 0, target_buf)) {
case 0:
break;
case 1:
api_set_error(err, kErrorTypeException, (char *)e_invarg, 0);
- goto FAIL_AND_FREE;
+ goto fail_and_free;
case 2:
api_set_error(err, kErrorTypeException, (char *)e_nomap, 0);
- goto FAIL_AND_FREE;
+ goto fail_and_free;
case 5:
api_set_error(err, kErrorTypeException,
"E227: mapping already exists for %s", parsed_args.lhs);
- goto FAIL_AND_FREE;
+ goto fail_and_free;
default:
assert(false && "Unrecognized return code!");
- goto FAIL_AND_FREE;
+ goto fail_and_free;
} // switch
xfree(lhs_buf);
@@ -872,10 +871,10 @@ void modify_keymap(Buffer buffer, bool is_unmap, String mode, String lhs,
return;
-FAIL_WITH_MESSAGE:
+fail_with_message:
api_set_error(err, err_type, err_msg, err_arg);
-FAIL_AND_FREE:
+fail_and_free:
xfree(lhs_buf);
xfree(rhs_buf);
xfree(parsed_args.rhs);
@@ -913,7 +912,7 @@ Integer parse_keymap_opts(Dictionary opts, MapArguments *out, Error *err)
err_msg = "Gave non-boolean value for an opt: %s";
err_arg = optname;
err_type = kErrorTypeValidation;
- goto FAIL_WITH_MESSAGE;
+ goto fail_with_message;
}
bool was_valid_opt = false;
@@ -961,13 +960,13 @@ Integer parse_keymap_opts(Dictionary opts, MapArguments *out, Error *err)
err_msg = "Invalid key: %s";
err_arg = optname;
err_type = kErrorTypeValidation;
- goto FAIL_WITH_MESSAGE;
+ goto fail_with_message;
}
} // for
return 0;
-FAIL_WITH_MESSAGE:
+fail_with_message:
api_set_error(err, err_type, err_msg, err_arg);
return 1;
}