Change the coding style to GNU

This commit is contained in:
Sameer Rahmani 2022-08-07 11:06:50 +01:00
parent 5d108d7f95
commit 61764bc1f5
3 changed files with 77 additions and 18 deletions

20
.clang-format Normal file
View File

@ -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
...

31
.pre-commit-config.yaml Normal file
View File

@ -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']

View File

@ -16,6 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "export.h"
#include <emacs-module.h>
/* Declare mandatory GPL symbol. */
@ -23,8 +24,9 @@ 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;
@ -32,7 +34,9 @@ static emacs_value feynman_init(emacs_env *env, ptrdiff_t nargs,
}
/* 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. */
@ -48,7 +52,9 @@ static void bind_function(emacs_env *env, const char *name, emacs_value Sfun) {
}
/* 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);
@ -58,7 +64,9 @@ static void provide(emacs_env *env, const char *feature) {
env->funcall (env, Qprovide, 1, args);
}
FEYNMAN_EXPORT int emacs_module_init(struct emacs_runtime *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 (