Configure YASnippet

This commit is contained in:
Camden Dixie O'Brien 2023-07-14 15:52:48 +01:00
parent 1211a0404d
commit dec4206e70
3 changed files with 48 additions and 0 deletions

View File

@ -202,6 +202,25 @@
(ido-mode t)))) (ido-mode t))))
#+end_src #+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 * Calendar / Diary
Weeks start on Sunday by default, this can be changed to start on 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: Monday by setting [[help:calendar-week-start-day][calendar-week-start-day]] to 1:
@ -677,6 +696,13 @@
(smart-tabs-insinuate 'c) (smart-tabs-insinuate 'c)
#+end_src #+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++ ** C++
Essentially the same story as for C. Essentially the same story as for C.

View File

@ -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

View File

@ -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