branch: elpa/yasnippet-snippets commit 9205da042a3338e304796ebddfa0b9bfce1bcca6 Author: a2379 <m...@antr.me> Commit: GitHub <nore...@github.com>
prog-mode: Add snippets for SPDX-* comments (#512) --- snippets/prog-mode/.yas-setup.el | 7 +++++++ snippets/prog-mode/spdxcopyright | 6 ++++++ snippets/prog-mode/spdxlicense | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/snippets/prog-mode/.yas-setup.el b/snippets/prog-mode/.yas-setup.el index 7d6127daab..9aebceb979 100644 --- a/snippets/prog-mode/.yas-setup.el +++ b/snippets/prog-mode/.yas-setup.el @@ -29,6 +29,13 @@ "This function returns `comment-start' trimmed by whitespaces." (yas-s-trim comment-start)) +(defun yas-trimmed-add-comment () + "This function returns `comment-start' trimmed by whitespaces. It uses +`comment-add' to determine how many comment symbols to insert." + (yas-s-trim (apply #'concat (mapcar (lambda (x) + comment-start) + (number-sequence 0 comment-add))))) + (defun yas-trimmed-comment-end () "This function returns `comment-end' trimmed by whitespaces if `comment-end' is not empty. Otherwise the reversed output of diff --git a/snippets/prog-mode/spdxcopyright b/snippets/prog-mode/spdxcopyright new file mode 100644 index 0000000000..e2869b53ab --- /dev/null +++ b/snippets/prog-mode/spdxcopyright @@ -0,0 +1,6 @@ +# -*- mode: snippet -*- +# contributor: Antero Mejr <m...@antr.me> +# name: spdxcopyright +# key: spc +# -- +`(yas-trimmed-add-comment)` SPDX-FileCopyrightText: $0`comment-end` \ No newline at end of file diff --git a/snippets/prog-mode/spdxlicense b/snippets/prog-mode/spdxlicense new file mode 100644 index 0000000000..0d802bd46a --- /dev/null +++ b/snippets/prog-mode/spdxlicense @@ -0,0 +1,6 @@ +# -*- mode: snippet -*- +# contributor: Antero Mejr <m...@antr.me> +# name: spdxlicense +# key: spl +# -- +`(yas-trimmed-add-comment)` SPDX-License-Identifier: $0`comment-end` \ No newline at end of file