summaryrefslogtreecommitdiff
path: root/.config
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-09-09 15:35:35 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-09-09 15:35:35 +0200
commite3236fe7cdbb6bc35f3d567345ca4c5421c1c491 (patch)
tree4566148b3b5cd046be9641e874fc645f5c21c61b /.config
parent85b6636d1a297f2c1b768ca869ad70b6fa058e8f (diff)
emacs: Add tempel templates
Diffstat (limited to '.config')
-rw-r--r--.config/emacs/templates21
1 files changed, 21 insertions, 0 deletions
diff --git a/.config/emacs/templates b/.config/emacs/templates
new file mode 100644
index 0000000..edd8461
--- /dev/null
+++ b/.config/emacs/templates
@@ -0,0 +1,21 @@
+;; NOTE: https://github.com/minad/tempel/issues/23
+
+c-mode c-ts-mode c++-mode c++-ts-mode
+
+(guard
+ "#ifndef "
+ (p
+ (thread-last
+ (file-name-base (or (buffer-file-name)
+ (buffer-name)))
+ (concat (if-let ((project (project-current)))
+ (concat (project-name project) "_")))
+ (upcase)
+ (string-replace "-" "_")
+ (replace-regexp-in-string "^[0-9]+" "_\\&")
+ (replace-regexp-in-string "[^A-Z0-9_]+" "")
+ (format "%s_H"))
+ header)
+ n
+ "#define " header n n r n n
+ "#endif /* !" header " */")