From 84aba5216ff21fb61482e000e3f6dadc1b3b2bd6 Mon Sep 17 00:00:00 2001 From: Lucien Cartier-Tilet Date: Wed, 2 Sep 2020 13:26:50 +0200 Subject: [PATCH] [Emacs] Yasnippet snippets are now tangled from spacemacs.org Since all my snippets are now contained in my spacemacs.org file, this commit removes all my snippets files from this repository. --- .../emacs/private/snippets/org-mode/attr_html | 5 - .../private/snippets/org-mode/attr_latex | 5 - .../emacs/private/snippets/org-mode/caption | 5 - .../private/snippets/org-mode/comment_block | 7 - .../private/snippets/org-mode/emacs-lisp | 7 - .../emacs/private/snippets/org-mode/header | 11 - .config/emacs/private/snippets/org-mode/name | 5 - .config/emacs/private/snippets/org-mode/nyqy | 6 - .config/emacs/private/snippets/org-mode/phon | 5 - .../emacs/private/snippets/org-mode/python | 8 - .config/emacs/private/snippets/org-mode/src | 7 - .config/emacs/private/snippets/rust-mode/new | 10 - .../emacs/private/snippets/rust-mode/println | 5 - org/config/spacemacs.org | 197 +++++++++++++++++- 14 files changed, 190 insertions(+), 93 deletions(-) delete mode 100644 .config/emacs/private/snippets/org-mode/attr_html delete mode 100644 .config/emacs/private/snippets/org-mode/attr_latex delete mode 100644 .config/emacs/private/snippets/org-mode/caption delete mode 100644 .config/emacs/private/snippets/org-mode/comment_block delete mode 100644 .config/emacs/private/snippets/org-mode/emacs-lisp delete mode 100644 .config/emacs/private/snippets/org-mode/header delete mode 100644 .config/emacs/private/snippets/org-mode/name delete mode 100644 .config/emacs/private/snippets/org-mode/nyqy delete mode 100644 .config/emacs/private/snippets/org-mode/phon delete mode 100644 .config/emacs/private/snippets/org-mode/python delete mode 100644 .config/emacs/private/snippets/org-mode/src delete mode 100644 .config/emacs/private/snippets/rust-mode/new delete mode 100644 .config/emacs/private/snippets/rust-mode/println diff --git a/.config/emacs/private/snippets/org-mode/attr_html b/.config/emacs/private/snippets/org-mode/attr_html deleted file mode 100644 index 4731c7b..0000000 --- a/.config/emacs/private/snippets/org-mode/attr_html +++ /dev/null @@ -1,5 +0,0 @@ -# -*- mode: snippet -*- -# name: ATTR HTML -# key: Self { - $0 - Self { - ${1:$(phundrak/yas-rust-new-assignments yas-text)} - } -} \ No newline at end of file diff --git a/.config/emacs/private/snippets/rust-mode/println b/.config/emacs/private/snippets/rust-mode/println deleted file mode 100644 index f3c6fff..0000000 --- a/.config/emacs/private/snippets/rust-mode/println +++ /dev/null @@ -1,5 +0,0 @@ -# -*- mode: snippet -*- -# name: println!("{}", value); -# key: pln -# -- -println!("${1:{}}", $2); \ No newline at end of file diff --git a/org/config/spacemacs.org b/org/config/spacemacs.org index 578c49b..b4596b9 100644 --- a/org/config/spacemacs.org +++ b/org/config/spacemacs.org @@ -3683,21 +3683,57 @@ ** Snippets :PROPERTIES: :CUSTOM_ID: User_Configuration-Snippets-67a32065 - :HEADER-ARGS:snippet: :padline no + :HEADER-ARGS:snippet: :padline no :mkdir yes :END: Yasnippet’s snippets tool is extremely powerful and allows me to write very quickly code. For now, we have snippets for two modes. The files you’ll see below are exported to ~$HOME/.config/emacs/private/snippets/~ and to their respective mode directory. For instance, my ~caption~ snippet for org-mode - will be exported to ~$HOME/.config/emacs/private/snippets/org-mode/caption~ + will be exported to ~$HOME/.config/emacs/private/snippets/org-mode/caption~. -*** org-mode snippets + Be aware that on top of these custom snippets, I also use the package + [[file:awesome.org::#Autostart-f2cf42fe][yasnippet-snippets]] which provide plenty of already made snippets. +*** Rust snippets :PROPERTIES: - :CUSTOM_ID: User_Configuration-Snippets-org-mode_snippets-f213e34d + :CUSTOM_ID: User_Configuration-Snippets-Rust_snippets-b106fad4 :END: - The first two snippets are used to add HTML or LaTeX attributes to elements - in org-mode. - #+BEGIN_SRC snippet :mkdir yes :tangle ~/.config/emacs/private/snippets/org-mode/attr_html + I have so far two snippets, the first one is actually just a convenience to + make it easier to type a ~println!~ macro than the default snippet. + #+BEGIN_SRC snippet :tangle ~/.config/emacs/private/snippets/rust-mode/println + # -*- mode: snippet -*- + # name: println + # key: pln + # -- + println!("${1:{}}", $2); + #+END_SRC + + The second one is more interesting: it is used to create a ~new~ method for + a struct, and it will try to create a function that will assign each + argument passed to the method to members of the struct. It relies on the + custom function [[#User_Configuration-Custom_functions-phundrakyas-rust-new-assignments-10f73456][I wrote here]]. + #+BEGIN_SRC snippet :tangle ~/.config/emacs/private/snippets/rust-mode/new + # -*- mode: snippet -*- + # name: new + # key: _new + # -- + fn new(${1:args}) -> Self { + $0 + Self { + ${1:$(phundrak/yas-rust-new-assignments yas-text)} + } + } + #+END_SRC + + +*** Org headers + :PROPERTIES: + :CUSTOM_ID: User_Configuration-Snippets-org-mode_snippets-Org_headers-ed14fbac + :END: + The first two snippets are used to add HTML or LaTeX attributes to elements + in org-mode. The third also has a similar usage, inserting a ~#+CAPTION~ + header before an element, as well as the fourth which inserts a ~#+NAME~ + header. + #+BEGIN_SRC snippet :tangle ~/.config/emacs/private/snippets/org-mode/attr_html # -*- mode: snippet -*- # name: ATTR HTML # key: