emacs/templates

210 lines
6.6 KiB
Plaintext

;; -*- lisp-data -*-
fundamental-mode ;; Available everywhere
(today (format-time-string "%Y-%m-%d"))
prog-mode
(fixme (if (derived-mode-p 'emacs-lisp-mode) ";; " comment-start) "FIXME ")
(todo (if (derived-mode-p 'emacs-lisp-mode) ";; " comment-start) "TODO ")
(bug (if (derived-mode-p 'emacs-lisp-mode) ";; " comment-start) "BUG ")
(hack (if (derived-mode-p 'emacs-lisp-mode) ";; " comment-start) "HACK ")
latex-mode
(begin "\\begin{" (s env) "}" > n> r> "\\end{" (s env) "}")
(frac "\\frac{" p "}{" p "}")
(enumerate "\\begin{enumerate}\n\\item " r> n> "\\end{enumerate}")
(itemize "\\begin{itemize}\n\\item " r> n> "\\end{itemize}")
lisp-mode emacs-lisp-mode ;; Specify multiple modes
(lambda "(lambda (" p ")" n> r> ")")
emacs-lisp-mode
(lambda "(lambda (" p ")" n> r> ")")
(var "(defvar " p "\n \"" p "\")")
(const "(defconst " p "\n \"" p "\")")
(custom "(defcustom " p "\n \"" p "\"" n> ":type '" p ")")
(face "(defface " p " '((t :inherit " p "))\n \"" p "\")")
(group "(defgroup " p " nil\n \"" p "\"" n> ":group '" p n> ":prefix \"" p "-\")")
(macro "(defmacro " p " (" p ")\n \"" p "\"" n> r> ")")
(fun "(defun " p " (" p ")\n \"" p "\"" n> r> ")")
(let "(let (" p ")" n> r> ")")
(star "(let* (" p ")" n> r> ")")
(rec "(letrec (" p ")" n> r> ")")
(command "(defun " p " (" p ")\n \"" p "\"" n> "(interactive)" n> r> ")")
eshell-mode
(for "for " (p "i") " in " p " { " p " }")
(while "while { " p " } { " p " }")
(until "until { " p " } { " p " }")
(if "if { " p " } { " p " }")
(if-else "if { " p " } { " p " } { " p " }")
(unless "unless { " p " } { " p " }")
(unless-else "unless { " p " } { " p " } { " p " }")
text-mode
(cut "--8<---------------cut here---------------start------------->8---" n r n
"--8<---------------cut here---------------end--------------->8---" n)
(asciibox "+-" (make-string (length str) ?-) "-+" n
"| " (s str) " |" n
"+-" (make-string (length str) ?-) "-+" n)
(rot13 (p "plain text" text) n "----" n (rot13 text))
(calc (p "taylor(sin(x),x=0,3)" formula) n "----" n (format "%s" (calc-eval formula)))
rst-mode
(title (make-string (length title) ?=) n (p "Title: " title) n (make-string (length title) ?=) n)
java-mode
(class "public class " (p (file-name-base (or (buffer-file-name) (buffer-name)))) " {" n> r> n "}")
c-mode :condition (re-search-backward "^\\w*$" (line-beginning-position) 'noerror)
(inc "#include <" (p (concat (file-name-base (or (buffer-file-name) (buffer-name))) ".h")) ">")
(incc "#include \"" (p (concat (file-name-base (or (buffer-file-name) (buffer-name))) ".h")) "\"")
org-mode
(title "#+title: " p n "#+author: Chris Cochrun" n n)
(drawer ":" p ":" n r ":end:")
(begin "#+begin_" (s name) n> r> n "#+end_" name)
(quote "#+begin_quote" n> r> n> "#+end_quote")
(sidenote "#+begin_sidenote" n> r> n "#+end_sidenote")
(marginnote "#+begin_marginnote" n> r> n "#+end_marginnote")
(example "#+begin_example" n> r> n> "#+end_example")
(center "#+begin_center" n> r> n> "#+end_center")
(comment "#+begin_comment" n> r> n> "#+end_comment")
(verse "#+begin_verse" n> r> n> "#+end_verse")
(notes "#+begin_notes" n> r> n> "#+end_notes")
(src "#+begin_src " p n> r> n> "#+end_src")
(elisp "#+begin_src emacs-lisp" n r n "#+end_src"
:post (progn (org-edit-src-code)))
(nix "#+begin_src nix" n> r> n "#+end_src"
:post (progn (tempel-done) (org-edit-src-code)))
(hc "#+TITLE: " p n "#+DATE: " (p (format-time-string "%Y-%m-%d")) n "#+tags[]: " p n "#+featured_image: \"featured.jpg\"" n "#+description: " p n "#+summary: " p n "#+showAuthor: false
#+showAuthorsBadge: true
#+showTaxonomies: true
#+showReadingTime: true
#+showWordCount: true
#+showDate: true
#+layout: simple
#+showTableOfContents: false
#+HUGO_CUSTOM_FRONT_MATTER: :showAuthor false
")
(fade "#+ATTR_REVEAL: :frag (fade-right)")
(split "#+REVEAL: split")
(htat "#+ATTR_HTML: ")
(htr "#+ATTR_REVEAL: ")
(revid "**
:PROPERTIES:
:reveal_background:
:reveal_extra_attr: data-background-video=\""p"\" data-background-size=\"contain\"
:END:
")
(reimg "**
:PROPERTIES:
:reveal_background: "p"
:reveal_extra_attr: data-background-size=\"contain\"
:END:
")
(hugo-image "{{< figure src=" p " alt=\"" p "\" caption=\""p "\" >}}")
(hugo-carousel "{{< carousel images=\"" p "\" >}}")
web-mode
(div "<div class=\""p"\">" n> r> n> "</div>" n)
(input "<input type=\""p"\" id=\""p"\" name=\""p"\" class=\""p"\">")
(label "<label for=\""p"\" class=\""p"\">")
(button "<button class=\""p"\">" n> r> n "</button>" n)
c++-mode
(qprop "Q_PROPERTY(" (p "type") " " (p "name") " READ " (p "name") " WRITE set" (p "name") " NOTIFY " (p "name") "CHANGED)")
qml-mode
(rectangle "Rectangle {" n> "id: " r n "}">)
(item "Item {" n> "id: " r n "}">)
(row "RowLayout {" n> "id: " r n "}">)
(column "ColumnLayout {" n> "id: " r n "}">)
(grid "GridLayout {" n> "id: " r n "}">)
(component "Component {" n> "id: " r n "}">)
(filedialog "FileDialog {" n> "id: " r n "}">)
(label "Controls.Label {" n> "id: " r n "}">)
(cbutton "Controls.ToolButton {" n> "id: " r n "}">)
(toolbar "Controls.ToolBar {" n> "id: " r n "}">)
(toolsep "Controls.ToolSeparator {" n> "id: " r n "}">)
(popup "Controls.Popup {" n> "id: " r n "}">)
(combobox "Controls.ComboBox {" n> "id: " r n "}">)
(textfield "Controls.TextField {" n> "id: " r n "}">)
(textarea "Controls.TextArea {" n> "id: " r n "}">)
(sheet "Kirigami.OverlaySheet {" n> "id: " r n "}">)
(action "Kirigami.Action {" n> "id: " r n "}">)
(icon "Kirigami.Icon {" n> "id: " r n "}">)
(search "Kirigami.SearchField {" n> "id: " r n "}">)
nix-mode
(flake "{
description = " (s description) ";
inputs = {
nixpkgs.url = \"github:nixos/nixpkgs/nixos-unstable\";
flake-utils.url = \"github:numtide/flake-utils\";
};
outputs = inputs: with inputs;
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs {
inherit system;
};
in rec
{
devShell = pkgs.mkShell {
" p "
buildInputs = with pkgs; [
stdenv
gnumake
pkg-config
];
};
defaultPackage = pkgs.libsForQt5.callPackage ./default.nix { };
}
);
}")
ledger-mode
(contribution "2023-10-01 Contributions" n> "Income:Supporters:" (p "supporter") > n> "Assets:Core")
rustic-mode rust-mode rust-ts-mode
(if "if " p " {" n> q n> "}" q)
(el "if " p " {" n> p n> "} else {" n> p n> "}" q)
(elif "if " p " {" n> p n> "} else if " p " {" n> p n> "}" q)
(fn "fn " p "(" p ") {" n> p n "}" q)
(fnr "fn " p "(" p ") -> " p " {" n> p n "}" q)
(crt "extern crate " q ";")
(drv & "#[derive(" p ")]" q)
(d "dbg!(" p ")" q)
(lp "loop {" n> q n> "}" q)
(imd "impl Default for " p " {" n> n> "}")