Configure YASnippet
This commit is contained in:
parent
1211a0404d
commit
dec4206e70
26
config.org
26
config.org
@ -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.
|
||||||
|
|
||||||
|
11
snippets/c-mode/header-guard
Normal file
11
snippets/c-mode/header-guard
Normal 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
|
11
snippets/c-mode/spdx-license-comment
Normal file
11
snippets/c-mode/spdx-license-comment
Normal 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
|
Loading…
x
Reference in New Issue
Block a user