diff --git a/config.org b/config.org index 3bee68b..4f6743b 100644 --- a/config.org +++ b/config.org @@ -202,6 +202,25 @@ (ido-mode t)))) #+end_src +** Snippets + YASnippet is the de facto snippet engine. There are two packages + for it: one for the engine itself and one with a library of + snippets: + + #+begin_src emacs-lisp + (use-package yasnippet) + (use-package yasnippet-snippets) + #+end_src + + I don't want it enabled all the time, only in certain modes. The + [[help:yas-minor-mode][yas-minor-mode]] function is provided for this, but it requires that + the snippet tables are loaded beforehand, so that has to be done + now. + + #+begin_src emacs-lisp + (yas-reload-all) + #+end_src + * Calendar / Diary Weeks start on Sunday by default, this can be changed to start on Monday by setting [[help:calendar-week-start-day][calendar-week-start-day]] to 1: @@ -677,6 +696,13 @@ (smart-tabs-insinuate 'c) #+end_src + There's a lot of boilerplate in C, so I want YASnippet enabled. + + #+begin_src emacs-lisp + (add-hook 'c-mode-hook (lambda () + (yas-minor-mode))) + #+end_src + ** C++ Essentially the same story as for C. diff --git a/snippets/c-mode/header-guard b/snippets/c-mode/header-guard new file mode 100644 index 0000000..be8c1c5 --- /dev/null +++ b/snippets/c-mode/header-guard @@ -0,0 +1,11 @@ +# -*- mode: snippet -*- +# name: header-guard +# binding: C-c C-k C-l +# key: hdr +# -- +#ifndef ${1:`(upcase (file-name-nondirectory (file-name-sans-extension (buffer-file-name))))`_H} +#define $1 + +$0 + +#endif diff --git a/snippets/c-mode/spdx-license-comment b/snippets/c-mode/spdx-license-comment new file mode 100644 index 0000000..a0a8475 --- /dev/null +++ b/snippets/c-mode/spdx-license-comment @@ -0,0 +1,11 @@ +# -*- mode: snippet -*- +# name: spdx-license-comment +# binding: C-c C-k C-l +# key: spdx +# -- +/* + * SPDX-License-Identifier: $1 + * Copyright (c) Camden Dixie O'Brien + */ + +$0