1
tempel-templates/c++.eld

121 lines
3.1 KiB
Plaintext

;;; c++.eld --- Tempel template definitions file -*- lexical-binding: t; -*-
;; Author: Jessie Hildebrandt <jessieh.net>
;; Homepage: https://gitlab.com/jessieh/tempel-templates
;; This file is not part of GNU Emacs.
;;; Commentary:
;; This file provides Tempel template definitions.
;;; License:
;; 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 2, 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; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.
;;; Code:
c++-mode c++-ts-mode
;; ---------------------------------- ;;
;; Section header
;; ---------------------------------- ;;
(sec
> "/* -----------------------------------------------------------------------------" >
n> " *" >
n> " * " (r "Section title" title) >
n> " *" >
n> " * -------------------------------------------------------------------------- */" >
n)
;; ---------------------------------- ;;
;; Subsection header
;; ---------------------------------- ;;
(sub
> "/* -------------------------------------" >
n> " * " (r "Subsection title" title) >
n> " * ---------------------------------- */" >
n)
;; ---------------------------------- ;;
;; Subdivision header
;; ---------------------------------- ;;
(div
> "/* --- " (r "Subdivision title" title) " --- */" >
n)
;; ---------------------------------- ;;
;; Doc comment
;; ---------------------------------- ;;
(doc
> "/**" >
n> " * " (r "TODO: Doc me!") >
n> " */" >)
;; ---------------------------------- ;;
;; File doc comment
;; ---------------------------------- ;;
(file
> "/**" >
n> " * @file " (or (file-relative-name buffer-file-name
(project-root (project-current)))
(file-name-nondirectory (buffer-file-name))) >
n> " * @brief " (p "Brief description of file") >
n> " */" >
n)
;; ---------------------------------- ;;
;; Function header
;; ---------------------------------- ;;
(fn
> (i doc) >
n> (p "void") " " (p "fn_name") "(" p ")" >
n> "{" >
n> r> >
n> "}" >
n)
;; ---------------------------------- ;;
;; Module declarations
;; ---------------------------------- ;;
(module
> (i sec (title "Global module fragment")) >
n> "module;" >
n
n> (i sec (title "Module declaration")) >
n> "/**" >
n> " * @module " (p (file-name-base (or (buffer-file-name) "module_name")) module-name) >
n> " * @brief " (p "Brief description of module") >
n> " */" >
n> "export module " module-name ";" >
n
n> (i sec (title (concat namespace-name "::"))) >
n> "namespace " (p module-name namespace-name) " {" >
n
n> (i sub (title "Exports and prototypes"))
n> "export {}" >
n
n> r> >
n
n> "}" >)