emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] dynamic-modules db69d49 12/22: new module: elisp


From: Noah Friedman
Subject: [Emacs-diffs] dynamic-modules db69d49 12/22: new module: elisp
Date: Mon, 8 May 2017 19:46:14 -0400 (EDT)

branch: dynamic-modules
commit db69d495fe33829789e2ae767beb02f62060de51
Author: Aurélien Aptel <address@hidden>
Commit: Ted Zlatanov <address@hidden>

    new module: elisp
    
    The elisp module simply evaluates some code written in ELisp from C.
---
 modules/elisp/Makefile | 12 ++++++++++++
 modules/elisp/elisp.c  | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+)

diff --git a/modules/elisp/Makefile b/modules/elisp/Makefile
new file mode 100644
index 0000000..8df325e
--- /dev/null
+++ b/modules/elisp/Makefile
@@ -0,0 +1,12 @@
+ROOT = ../..
+
+all: elisp.so elisp.doc
+
+%.so: %.o
+       gcc -shared -o $@ $<
+
+%.o: %.c
+       gcc -ggdb3 -Wall -I$(ROOT)/src -I$(ROOT)/lib -fPIC -c $<
+
+%.doc: %.c
+       $(ROOT)/lib-src/make-docfile $< > $@
diff --git a/modules/elisp/elisp.c b/modules/elisp/elisp.c
new file mode 100644
index 0000000..cf61a74
--- /dev/null
+++ b/modules/elisp/elisp.c
@@ -0,0 +1,35 @@
+#include <string.h>
+#include <config.h>
+#include <lisp.h>
+
+int plugin_is_GPL_compatible;
+
+static Lisp_Object Qreplace_regexp_in_string;
+
+#define MAKE_STRING(s) (make_string (s, sizeof(s)-1))
+
+EXFUN (Felisp_test, 0);
+DEFUN ("elisp-test", Felisp_test, Selisp_test, 0, 0, 0,
+       doc: "Eval some lisp.")
+    (void)
+{
+    Lisp_Object string  = MAKE_STRING ("no-more-dash");
+    Lisp_Object regex   = MAKE_STRING ("[-]");
+    Lisp_Object replace = MAKE_STRING (" ");
+    Lisp_Object res;
+
+    struct gcpro gcpro1, gcpro2, gcpro3;
+    GCPRO3 (string, regex, replace);
+    res = call3 (Qreplace_regexp_in_string, regex, replace, string);
+    UNGCPRO;
+
+    return res;
+}
+
+
+void init ()
+{
+  DEFSYM (Qreplace_regexp_in_string, "replace-regexp-in-string");
+
+  defsubr (&Selisp_test);
+}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]