diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..d637867
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,20 @@
+---
+# Global Options Go Here
+IndentWidth: 2
+ColumnLimit: 100
+---
+Language: Cpp
+BasedOnStyle: GNU
+AllowShortIfStatementsOnASingleLine: false
+AllowShortLoopsOnASingleLine: false
+AlignConsecutiveMacros: true
+ForEachMacros: []
+IndentWidth: 2
+AlignConsecutiveAssignments: Consecutive
+AlignConsecutiveBitFields: Consecutive
+AlignEscapedNewlines: Left
+AlwaysBreakTemplateDeclarations: Yes
+IncludeBlocks: Regroup
+SortIncludes: true
+SortUsingDeclarations: true
+...
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 0000000..304454c
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,31 @@
+# Apply to all files without commiting:
+# pre-commit run --all-files
+# Update this file:
+# pre-commit autoupdate
+fail_fast: false
+repos:
+ - repo: https://github.com/pre-commit/pre-commit-hooks
+ rev: v4.3.0
+ hooks:
+ - id: check-added-large-files
+ - id: check-symlinks
+ - id: check-byte-order-marker
+ - id: check-case-conflict
+ - id: check-docstring-first
+ - id: check-executables-have-shebangs
+ - id: forbid-new-submodules
+ - id: end-of-file-fixer
+ - id: trailing-whitespace
+ - id: mixed-line-ending
+
+ - repo: https://github.com/pocc/pre-commit-hooks
+ rev: v1.3.5
+ hooks:
+ - id: clang-format
+ - id: cppcheck
+ args: ['--project=compile_commands.json']
+ - repo: https://github.com/detailyang/pre-commit-shell
+ rev: 1.0.5
+ hooks:
+ - id: shell-lint
+ args: ['-x']
diff --git a/src/feynman.c b/src/feynman.c
index a50c3c4..e813b0d 100644
--- a/src/feynman.c
+++ b/src/feynman.c
@@ -16,6 +16,7 @@
* along with this program. If not, see .
*/
#include "export.h"
+
#include
/* Declare mandatory GPL symbol. */
@@ -23,45 +24,52 @@ FEYNMAN_EXPORT int plugin_is_GPL_compatible = 0;
/* New emacs lisp function. All function exposed to Emacs must have this
* prototype. */
-static emacs_value feynman_init(emacs_env *env, ptrdiff_t nargs,
- emacs_value args[], void *data) {
+static emacs_value
+feynman_init (emacs_env *env, ptrdiff_t nargs, emacs_value args[], void *data)
+{
(void)nargs;
(void)args;
(void)data;
- return env->make_integer(env, 42);
+ return env->make_integer (env, 42);
}
/* Bind NAME to FUN. */
-static void bind_function(emacs_env *env, const char *name, emacs_value Sfun) {
+static 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);
+ emacs_value Qfset = env->intern (env, "fset");
+ emacs_value Qsym = env->intern (env, name);
/* Prepare the arguments array */
- emacs_value args[] = {Qsym, Sfun};
+ emacs_value args[] = { Qsym, Sfun };
/* Make the call (2 == nb of arguments) */
- env->funcall(env, Qfset, 2, args);
+ env->funcall (env, Qfset, 2, args);
}
/* Provide FEATURE to Emacs. */
-static void provide(emacs_env *env, const char *feature) {
+static 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};
+ 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, args);
}
-FEYNMAN_EXPORT int emacs_module_init(struct emacs_runtime *ert) {
- emacs_env *env = ert->get_environment(ert);
+FEYNMAN_EXPORT int
+emacs_module_init (struct emacs_runtime *ert)
+{
+ emacs_env *env = ert->get_environment (ert);
/* create a lambda (returns an emacs_value) */
- emacs_value fun = env->make_function(
+ emacs_value fun = env->make_function (
env, 0, /* min. number of arguments */
0, /* max. number of arguments */
feynman_init, /* actual function pointer */
@@ -69,7 +77,7 @@ FEYNMAN_EXPORT int emacs_module_init(struct emacs_runtime *ert) {
NULL /* user pointer of your choice (data param in feynman_init) */
);
- bind_function(env, "feynman/init", fun);
- provide(env, "feynman");
+ bind_function (env, "feynman/init", fun);
+ provide (env, "feynman");
return 0;
}