autocmd: add a service function `autocmd_in_use`
authorSébastien Marie <semarie@users.noreply.github.com>
Tue, 28 Oct 2014 11:09:40 +0000 (12:09 +0100)
committerSébastien Marie <semarie@users.noreply.github.com>
Tue, 28 Oct 2014 11:09:40 +0000 (12:09 +0100)
The function should permit to check if an AuEvent is actually in use or
not. It would permit to change program behaviour at runtime, and reduce
the overhead of some functions when AuEvent isn't used.

src/autocmd.c
src/autocmd.h

index 87054eb..58698e5 100644 (file)
@@ -242,6 +242,14 @@ gboolean autocmd_add(char *name, gboolean delete)
     return true;
 }
 
+/**
+ * Return if an event is actually used by autocmd
+ */
+gboolean autocmd_in_use(AuEvent event)
+{
+    return usedbits & events[event].bits;
+}
+
 /**
  * Run named auto command.
  */
index 605c4ba..e11e7c0 100644 (file)
@@ -43,6 +43,7 @@ void autocmd_init(void);
 void autocmd_cleanup(void);
 gboolean autocmd_augroup(char *name, gboolean delete);
 gboolean autocmd_add(char *name, gboolean delete);
+gboolean autocmd_in_use(AuEvent event);
 gboolean autocmd_run(AuEvent event, const char *uri, const char *group);
 gboolean autocmd_fill_group_completion(GtkListStore *store, const char *input);
 gboolean autocmd_fill_event_completion(GtkListStore *store, const char *input);