aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Fürmetz <fuermetz@mailbox.org>2017-11-21 13:56:00 +0100
committerLukas Fürmetz <fuermetz@mailbox.org>2017-11-21 21:38:32 +0100
commit40a8656c8749f3f2fc213f8358fd0deda0154ea5 (patch)
treefe00b5c07999730124161a106693b3256af499df
parentef64d79097af35f5d3669b792dd5ef2832e75a26 (diff)
Cleanup elisp.c and elisp.h
-rw-r--r--elisp.c35
-rw-r--r--elisp.h2
2 files changed, 10 insertions, 27 deletions
diff --git a/elisp.c b/elisp.c
index 41c1299..900289b 100644
--- a/elisp.c
+++ b/elisp.c
@@ -1,31 +1,21 @@
#include "elisp.h"
#include <stdio.h>
-/* Bind NAME to FUN. */
+/* Set the function cell of the symbol named NAME to SFUN using
+ the 'fset' function. */
void bind_function(emacs_env *env, const char *name, emacs_value Sfun) {
- /* Set the function cell of the symbol named NAME to SFUN using
- the 'fset' function. */
-
- /* Convert the strings to symbols by interning them */
emacs_value Qfset = env->intern(env, "fset");
emacs_value Qsym = env->intern(env, name);
- /* Prepare the arguments array */
- emacs_value args[] = {Qsym, Sfun};
-
- /* Make the call (2 == nb of arguments) */
- env->funcall(env, Qfset, 2, args);
+ env->funcall(env, Qfset, 2, (emacs_value[]){Qsym, Sfun});
}
/* Provide FEATURE to Emacs. */
void provide(emacs_env *env, const char *feature) {
- /* call 'provide' with FEATURE converted to a symbol */
-
emacs_value Qfeat = env->intern(env, feature);
emacs_value Qprovide = env->intern(env, "provide");
- emacs_value args[] = {Qfeat};
- env->funcall(env, Qprovide, 1, args);
+ env->funcall(env, Qprovide, 1, (emacs_value[]){Qfeat});
}
int string_bytes(emacs_env *env, emacs_value string) {
@@ -42,8 +32,8 @@ emacs_value list(emacs_env *env, emacs_value *elements, ptrdiff_t len) {
return env->funcall(env, Flist, len, elements);
}
-void put_text_property(emacs_env *env, emacs_value string,
- emacs_value property, emacs_value value) {
+void put_text_property(emacs_env *env, emacs_value string, emacs_value property,
+ emacs_value value) {
emacs_value start = env->make_integer(env, 0);
emacs_value end = string_length(env, string);
@@ -51,11 +41,8 @@ void put_text_property(emacs_env *env, emacs_value string,
(emacs_value[]){start, end, property, value, string});
}
-/*
- * Color must be a string #RGB
- */
emacs_value render_text(emacs_env *env, char *buffer, int len,
- VTermScreenCell *cell) {
+ VTermScreenCell *cell) {
emacs_value text = env->make_string(env, buffer, len);
emacs_value foreground = color_to_rgb_string(env, cell->fg);
@@ -79,9 +66,7 @@ emacs_value render_text(emacs_env *env, char *buffer, int len,
return text;
}
-void byte_to_hex(uint8_t byte, char *hex) {
- snprintf(hex, 3, "%.2X", byte);
-}
+void byte_to_hex(uint8_t byte, char *hex) { snprintf(hex, 3, "%.2X", byte); }
emacs_value color_to_rgb_string(emacs_env *env, VTermColor color) {
char buffer[8];
@@ -94,9 +79,7 @@ emacs_value color_to_rgb_string(emacs_env *env, VTermColor color) {
return env->make_string(env, buffer, 7);
};
-void erase_buffer(emacs_env *env) {
- env->funcall(env, Ferase_buffer, 0, NULL);
-}
+void erase_buffer(emacs_env *env) { env->funcall(env, Ferase_buffer, 0, NULL); }
void insert(emacs_env *env, emacs_value string) {
env->funcall(env, Finsert, 1, (emacs_value[]){string});
diff --git a/elisp.h b/elisp.h
index 826a855..026db90 100644
--- a/elisp.h
+++ b/elisp.h
@@ -1,5 +1,5 @@
-#include <emacs-module.h>
#include "vterm.h"
+#include <emacs-module.h>
// Emacs symbols
emacs_value Qt;