aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/lsp.c
diff options
context:
space:
mode:
authorRobin Haberkorn <rhaberkorn@fmsbw.de>2026-08-23 00:28:23 +0200
committerRobin Haberkorn <rhaberkorn@fmsbw.de>2026-08-23 00:28:23 +0200
commit32122651bdb51006edce2be3586dd09179bed52f (patch)
tree6fa0bb17ec74693e25eebe8e05a9e04828c3c446 /src/lsp.c
parent2e097cec409182c3cb39b74489387480bf8a278f (diff)
introduced helper functions teco_qreg_table_get_string() and teco_qreg_table_get_integer()
* Simplifies the common task of querying an integer or string from a Q-Register table. * Undefined Q-Regs are reported as TECO_ERROR_QREGUNDEF, so you can theoretically handle this case. In practice however, it requires less boilerplating to just call teco_qreg_table_find() manually. * It also doesn't make sense to use these functions when getting and setting a register at the same time as you will want to avoid repeated lookups.
Diffstat (limited to 'src/lsp.c')
-rw-r--r--src/lsp.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/lsp.c b/src/lsp.c
index 2c1f89b..ff7ddc7 100644
--- a/src/lsp.c
+++ b/src/lsp.c
@@ -444,16 +444,9 @@ teco_lsp_launch(GError **error)
G_SPAWN_STDERR_TO_DEV_NULL;
static const gchar lsp_reg_name[] = "$SCITECO_LSP";
- teco_qreg_t *reg = teco_qreg_table_find(&teco_qreg_table_globals,
- lsp_reg_name, strlen(lsp_reg_name));
- if (!reg) {
- g_set_error(error, TECO_ERROR, TECO_ERROR_FAILED,
- "Q-Register %s is undefined.", lsp_reg_name);
- return FALSE;
- }
-
g_auto(teco_string_t) command = {NULL, 0};
- if (!reg->vtable->get_string(reg, &command.data, &command.len, NULL, error))
+ if (!teco_qreg_table_get_string(&teco_qreg_table_globals, lsp_reg_name,
+ &command.data, &command.len, error))
return FALSE;
if (teco_string_contains(command, '\0')) {
teco_error_qregcontainsnull_set(error, lsp_reg_name, strlen(lsp_reg_name), FALSE);
@@ -497,8 +490,8 @@ teco_lsp_launch(GError **error)
g_auto(teco_string_t) root = {NULL, 0};
static const gchar root_reg_name[] = "$SCITECO_LSP_ROOT";
- reg = teco_qreg_table_find(&teco_qreg_table_globals,
- root_reg_name, strlen(root_reg_name));
+ teco_qreg_t *reg = teco_qreg_table_find(&teco_qreg_table_globals,
+ root_reg_name, strlen(root_reg_name));
if (reg) {
if (!reg->vtable->get_string(reg, &root.data, &root.len, NULL, error))
return FALSE;