summaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--templates/auto-insert/.yas-setup.el73
-rw-r--r--templates/auto-insert/template.c (renamed from auto-insert/template.c)0
-rw-r--r--templates/auto-insert/template.h16
l---------templates/snippets/c-mode/doxycomments (renamed from snippets/c-mode/doxycomments)0
-rw-r--r--templates/snippets/c-mode/headerDEF (renamed from snippets/c-mode/headerDEF)0
-rw-r--r--templates/snippets/clojure-mode/defn (renamed from snippets/clojure-mode/defn)0
-rw-r--r--templates/snippets/clojure-mode/let (renamed from snippets/clojure-mode/let)0
-rw-r--r--templates/snippets/doxygen/doxycomments (renamed from snippets/doxygen/doxycomments)0
-rw-r--r--templates/snippets/python-mode/import_from (renamed from snippets/python-mode/import_from)0
-rw-r--r--templates/snippets/python-mode/lambda (renamed from snippets/python-mode/lambda)0
-rw-r--r--templates/snippets/python-mode/print (renamed from snippets/python-mode/print)0
-rw-r--r--templates/snippets/python-mode/print format (renamed from snippets/python-mode/print format)0
-rw-r--r--templates/snippets/python-mode/script (renamed from snippets/python-mode/script)0
13 files changed, 89 insertions, 0 deletions
diff --git a/templates/auto-insert/.yas-setup.el b/templates/auto-insert/.yas-setup.el
new file mode 100644
index 0000000..ed5d6b9
--- /dev/null
+++ b/templates/auto-insert/.yas-setup.el
@@ -0,0 +1,73 @@
+;;; .yas-setup.el --- Utility functions for c-mode -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2018 Benj Bellon
+
+;; Author: Benj Bellon <benj@benj-ad1>
+;; Keywords: c
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; As description
+
+;;; Code:
+(require 'dash)
+
+(defun fetch-project-path (root-dir)
+ "Retrieve path from project's root-dir to file as list.
+NOTE: The closest parent root-dir is considered the root.
+ROOT-DIR: the root directory with no path delimiters."
+ (let* ((full-path (locate-dominating-file buffer-file-name root-dir)))
+ (if full-path
+ (let* ((proj-root-dir (nth 1 (reverse (split-string full-path "/"))))
+ (full-path-list (cons proj-root-dir
+ (-flatten (cdr (-split-on proj-root-dir (split-string buffer-file-name "/")))))))
+
+ ;; turn dashes into underscores
+ (mapcar (lambda (x) (replace-regexp-in-string "-" "_" x))
+ full-path-list))
+ nil)
+ ))
+
+(defun build-include-guard-header (root-dir)
+ "Create a full include guard header for c files.
+If the path cannot be found, just use the filename.
+ROOT-DIR: the root directory with no path delimiters.
+FORMAT: PROJDIR_FULL_PATH_TO_FILE_H"
+ (if (fetch-project-path root-dir)
+ (let* ((path-no-file (reverse (cdr (reverse (fetch-project-path root-dir)))))
+ (file-no-ext (car (split-string (car (reverse (fetch-project-path root-dir))) "\\." t))))
+ (concat
+ (mapconcat 'identity
+ (mapcar 'upcase
+ (reverse (cons file-no-ext (reverse path-no-file)))) "_")
+ "_H")
+ )
+ ;; no lazy evaluation, so just do it here
+ (concat
+ (upcase
+ (car (-filter (lambda (x) (not (s-blank? x)))
+ (split-string
+ (car (reverse (split-string buffer-file-name "/")))
+ "\\."))))
+ "_H")
+ ))
+
+(defun git-include-guard-path ()
+ "Build include guard headers for git projects."
+ (build-include-guard-header ".git"))
+
+(provide '.yas-setup)
+;;; .yas-setup.el ends here
diff --git a/auto-insert/template.c b/templates/auto-insert/template.c
index d9afc65..d9afc65 100644
--- a/auto-insert/template.c
+++ b/templates/auto-insert/template.c
diff --git a/templates/auto-insert/template.h b/templates/auto-insert/template.h
new file mode 100644
index 0000000..0f9cb8e
--- /dev/null
+++ b/templates/auto-insert/template.h
@@ -0,0 +1,16 @@
+/**
+ * @file `(buffer-name)`
+ * @brief $1
+ *
+ * $2
+ *
+ * @author MAGIT_USER or SYSTEM_USER
+ * @date `(format-time-string "%Y-%m-%d")`
+ */
+
+#ifndef `(git-include-guard-path)`
+#define `(git-include-guard-path)`
+
+$0
+
+#endif
diff --git a/snippets/c-mode/doxycomments b/templates/snippets/c-mode/doxycomments
index 62fd598..62fd598 120000
--- a/snippets/c-mode/doxycomments
+++ b/templates/snippets/c-mode/doxycomments
diff --git a/snippets/c-mode/headerDEF b/templates/snippets/c-mode/headerDEF
index a07587b..a07587b 100644
--- a/snippets/c-mode/headerDEF
+++ b/templates/snippets/c-mode/headerDEF
diff --git a/snippets/clojure-mode/defn b/templates/snippets/clojure-mode/defn
index 0907e4a..0907e4a 100644
--- a/snippets/clojure-mode/defn
+++ b/templates/snippets/clojure-mode/defn
diff --git a/snippets/clojure-mode/let b/templates/snippets/clojure-mode/let
index 426caa2..426caa2 100644
--- a/snippets/clojure-mode/let
+++ b/templates/snippets/clojure-mode/let
diff --git a/snippets/doxygen/doxycomments b/templates/snippets/doxygen/doxycomments
index 94209bc..94209bc 100644
--- a/snippets/doxygen/doxycomments
+++ b/templates/snippets/doxygen/doxycomments
diff --git a/snippets/python-mode/import_from b/templates/snippets/python-mode/import_from
index 767f344..767f344 100644
--- a/snippets/python-mode/import_from
+++ b/templates/snippets/python-mode/import_from
diff --git a/snippets/python-mode/lambda b/templates/snippets/python-mode/lambda
index 08b268b..08b268b 100644
--- a/snippets/python-mode/lambda
+++ b/templates/snippets/python-mode/lambda
diff --git a/snippets/python-mode/print b/templates/snippets/python-mode/print
index 2392fbd..2392fbd 100644
--- a/snippets/python-mode/print
+++ b/templates/snippets/python-mode/print
diff --git a/snippets/python-mode/print format b/templates/snippets/python-mode/print format
index 704cb53..704cb53 100644
--- a/snippets/python-mode/print format
+++ b/templates/snippets/python-mode/print format
diff --git a/snippets/python-mode/script b/templates/snippets/python-mode/script
index 3113da9..3113da9 100644
--- a/snippets/python-mode/script
+++ b/templates/snippets/python-mode/script