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 +++++++++++++++++++++++++++++ .emacs.d/snippets/prog-mode/comment | 6 +++++ .emacs.d/snippets/prog-mode/commentblock | 36 ++++++++++++++++++++++++++++ .emacs.d/snippets/prog-mode/commentline | 13 ++++++++++ .emacs.d/snippets/python-mode/.yas-setup.el | 1 + .emacs.d/snippets/python-mode/scls | 7 ++++++ 6 files changed, 100 insertions(+) create mode 100644 .emacs.d/snippets/prog-mode/comment create mode 100644 .emacs.d/snippets/prog-mode/commentblock create mode 100644 .emacs.d/snippets/prog-mode/commentline create mode 100644 .emacs.d/snippets/python-mode/scls (limited to '.emacs.d/snippets') 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))) diff --git a/.emacs.d/snippets/prog-mode/comment b/.emacs.d/snippets/prog-mode/comment new file mode 100644 index 0000000..edd53e9 --- /dev/null +++ b/.emacs.d/snippets/prog-mode/comment @@ -0,0 +1,6 @@ +# -*- mode: snippet -*- +# contributor: sh-ow +# name: comment +# key: co +# -- +${1:$(yas-trimmed-comment-start)} ${1:comment}${1:$(unless (eq (length comment-end) 0) (concat " " (yas-trimmed-comment-end)))}$0 \ No newline at end of file diff --git a/.emacs.d/snippets/prog-mode/commentblock b/.emacs.d/snippets/prog-mode/commentblock new file mode 100644 index 0000000..ba61f61 --- /dev/null +++ b/.emacs.d/snippets/prog-mode/commentblock @@ -0,0 +1,36 @@ +# -*- mode: snippet -*- +# contributor: sh-ow +# name: commentblock +# key: cob +# -- +${1:$(let* ((col (current-column)) + (str "") + (lastcom (substring (yas-trimmed-comment-start) -1)) + (start (yas-trimmed-comment-start)) + (end (yas-trimmed-comment-end)) + (over (- (+ (string-width yas-text) (length start) (length end) col) 77))) + (while (< (length str) (+ (- 79 (length start) (length end) col) (if (> over 0) over 0))) + (setq str (concat str lastcom))) + (concat start str end))} +${1:$(let* ((col (current-column)) + (str "") + (start (yas-trimmed-comment-start)) + (end (yas-trimmed-comment-end))) + (while (< (length str) (ffloor (/ (- 78.0 (+ col (length start) (string-width yas-text) (length end))) 2.0))) + (setq str (concat str " "))) + (concat start str))} ${1:comment} ${1:$(let* ((col (current-column)) + (str "") + (start (yas-trimmed-comment-start)) + (end (yas-trimmed-comment-end))) + (while (< (length str) (- 79.0 (if (eq (mod (string-width yas-text) 2) 1) (- col 1) col) (length end))) + (setq str (concat str " "))) + (concat str end))} +${1:$(let* ((col (current-column)) + (str "") + (lastcom (substring (yas-trimmed-comment-start) -1)) + (start (yas-trimmed-comment-start)) + (end (yas-trimmed-comment-end)) + (over (- (+ (string-width yas-text) (length start) (length end) col) 77))) + (while (< (length str) (+ (- 79 (length start) (length end) col) (if (> over 0) over 0))) + (setq str (concat str lastcom))) + (concat start str end))}$0 \ No newline at end of file diff --git a/.emacs.d/snippets/prog-mode/commentline b/.emacs.d/snippets/prog-mode/commentline new file mode 100644 index 0000000..0b0edff --- /dev/null +++ b/.emacs.d/snippets/prog-mode/commentline @@ -0,0 +1,13 @@ +# -*- mode: snippet -*- +# contributor: sh-ow +# name: commentline +# key: col +# -- +${1:$(yas-trimmed-comment-start)} ${1:comment} ${1:$(let* ((str "") + (curr (current-column)) + (start (yas-trimmed-comment-start)) + (lastcom (substring start -1)) + (end (yas-trimmed-comment-end))) + (while (< (length str) (- 79 (+ curr (length end)))) + (setq str (concat str lastcom))) + (concat str end))}$0 \ No newline at end of file diff --git a/.emacs.d/snippets/python-mode/.yas-setup.el b/.emacs.d/snippets/python-mode/.yas-setup.el index 3f57d15..cd46717 100644 --- a/.emacs.d/snippets/python-mode/.yas-setup.el +++ b/.emacs.d/snippets/python-mode/.yas-setup.el @@ -1,3 +1,4 @@ +(require 'yasnippet) (defvar yas-text) (defun python-split-args (arg-string) diff --git a/.emacs.d/snippets/python-mode/scls b/.emacs.d/snippets/python-mode/scls new file mode 100644 index 0000000..4a10e28 --- /dev/null +++ b/.emacs.d/snippets/python-mode/scls @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: subclass +# key: scls +# group: object oriented +# -- +class ${1:class}(${2:super-class}): + $0 -- cgit v1.3