aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/private/helpers.h
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-10-27 15:26:32 -0700
committerJustin M. Keyes <justinkz@gmail.com>2019-10-29 22:39:07 -0700
commitefaf4732e26e2f0fbfab947296141376223b30d7 (patch)
treea194f621b9d4cff6ce75af11fd7a689f8fb0a567 /src/nvim/api/private/helpers.h
parent83b6d9f197a44e3b8140619e6b7e9950f217aafb (diff)
downloadrneovim-efaf4732e26e2f0fbfab947296141376223b30d7.tar.gz
rneovim-efaf4732e26e2f0fbfab947296141376223b30d7.tar.bz2
rneovim-efaf4732e26e2f0fbfab947296141376223b30d7.zip
lua/executor.c: use TRY_WRAP
Diffstat (limited to 'src/nvim/api/private/helpers.h')
-rw-r--r--src/nvim/api/private/helpers.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/nvim/api/private/helpers.h b/src/nvim/api/private/helpers.h
index 0ea7667428..8930f252f6 100644
--- a/src/nvim/api/private/helpers.h
+++ b/src/nvim/api/private/helpers.h
@@ -102,6 +102,20 @@ typedef struct {
int did_emsg;
} TryState;
+// `msg_list` controls the collection of abort-causing non-exception errors,
+// which would otherwise be ignored. This pattern is from do_cmdline().
+//
+// TODO(bfredl): prepare error-handling at "top level" (nv_event).
+#define TRY_WRAP(code) \
+ do { \
+ struct msglist **saved_msg_list = msg_list; \
+ struct msglist *private_msg_list; \
+ msg_list = &private_msg_list; \
+ private_msg_list = NULL; \
+ code \
+ msg_list = saved_msg_list; /* Restore the exception context. */ \
+ } while (0)
+
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "api/private/helpers.h.generated.h"
#endif