From 6a3efe35bf8b20b0900dbbf7747b8b8d0d19bd04 Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Tue, 6 Sep 2016 07:39:30 +0200 Subject: Upgrade ports --- .emacs.d/snippets/prog-mode/.yas-setup.el | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to '.emacs.d/snippets/prog-mode/.yas-setup.el') diff --git a/.emacs.d/snippets/prog-mode/.yas-setup.el b/.emacs.d/snippets/prog-mode/.yas-setup.el index 03d07cf..22a8168 100644 --- a/.emacs.d/snippets/prog-mode/.yas-setup.el +++ b/.emacs.d/snippets/prog-mode/.yas-setup.el @@ -1,2 +1,39 @@ +(require 'yasnippet) + (defun yas-with-comment (str) (format "%s%s%s" comment-start str comment-end)) + +;; whitespace removing functions from Magnar Sveen ;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(defun yas-s-trim-left (s) + "Remove whitespace at the beginning of S." + (if (string-match "\\`[ \t\n\r]+" s) + (replace-match "" t t s) + s)) + +(defun yas-s-trim-right (s) + "Remove whitespace at the end of S." + (if (string-match "[ \t\n\r]+\\'" s) + (replace-match "" t t s) + s)) + +(defun yas-s-trim (s) + "Remove whitespace at the beginning and end of S." + (yas-s-trim-left (yas-s-trim-right s))) + + +(defun yas-string-reverse (str) + "Reverse a string STR manually to be compatible with emacs versions < 25." + (apply #'string + (reverse + (string-to-list str)))) + +(defun yas-trimmed-comment-start () + "This function returns `comment-start' trimmed by whitespaces." + (yas-s-trim comment-start)) + +(defun yas-trimmed-comment-end () + "This function returns `comment-end' trimmed by whitespaces if `comment-end' is not empty. +Otherwise the reversed output of function `yas-trimmed-comment-start' is returned." + (if (eq (length comment-end) 0) + (yas-string-reverse (yas-trimmed-comment-start)) + (yas-s-trim comment-end))) -- cgit v1.3