summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsh-ow <sh-ow@users.noreply.github.com>2016-04-13 21:16:10 +0200
committersh-ow <sh-ow@users.noreply.github.com>2016-04-13 21:16:10 +0200
commit6652d252883d4fed79678ec4bcc86d61be8f413b (patch)
treeb53b36ab30b62c27813c5515abe4f1911d5a95e0
parenteb0290b3181fd424adae92f077e02447ccf82320 (diff)
add two generic comment snippets for prog-mode
-rw-r--r--prog-mode/commentblock9
-rw-r--r--prog-mode/commentline7
2 files changed, 16 insertions, 0 deletions
diff --git a/prog-mode/commentblock b/prog-mode/commentblock
new file mode 100644
index 0000000..06d607c
--- /dev/null
+++ b/prog-mode/commentblock
@@ -0,0 +1,9 @@
+# -*- mode: snippet -*-
+# contributor: sh-ow <sh-ow@users.noreply.github.com>
+# name: commentblock
+# key: com
+# --
+${1:$(let* ((col (current-column)) (lastcom (dolist (ch (append (reverse comment-start) nil)) (unless (or (eq ch nil) (eq ch 32)) (return (string ch))))) (str "") (start (substring comment-start 0 (dotimes (i (length comment-start)) (unless (or (eq (aref (reverse comment-start) i) nil) (eq (aref (reverse comment-start) i) 32)) (return (- (length comment-start) i)))))) (end (if (eq (length comment-end) 0) (reverse start) (substring comment-end (dotimes (i (length comment-end)) (unless (or (eq (aref comment-end i) nil) (eq (aref comment-end i) 32)) (return i)))))) (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 (substring comment-start 0 (dotimes (i (length comment-start)) (unless (or (eq (aref (reverse comment-start) i) nil) (eq (aref (reverse comment-start) i) 32)) (return (- (length comment-start) i)))))) (end (if (eq (length comment-end) 0) (reverse start) (substring comment-end (dotimes (i (length comment-end)) (unless (or (eq (aref comment-end i) nil) (eq (aref comment-end i) 32)) (return i))))))) (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 (substring comment-start 0 (dotimes (i (length comment-start)) (unless (or (eq (aref (reverse comment-start) i) nil) (eq (aref (reverse comment-start) i) 32)) (return (- (length comment-start) i)))))) (end (if (eq (length comment-end) 0) (reverse start) (substring comment-end (dotimes (i (length comment-end)) (unless (or (eq (aref comment-end i) nil) (eq (aref comment-end i) 32)) (return i))))))) (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)) (lastcom (dolist (ch (append (reverse comment-start) nil)) (unless (or (eq ch nil) (eq ch 32)) (return (string ch))))) (str "") (start (substring comment-start 0 (dotimes (i (length comment-start)) (unless (or (eq (aref (reverse comment-start) i) nil) (eq (aref (reverse comment-start) i) 32)) (return (- (length comment-start) i)))))) (end (if (eq (length comment-end) 0) (reverse start) (substring comment-end (dotimes (i (length comment-end)) (unless (or (eq (aref comment-end i) nil) (eq (aref comment-end i) 32)) (return i)))))) (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
diff --git a/prog-mode/commentline b/prog-mode/commentline
new file mode 100644
index 0000000..aa789e6
--- /dev/null
+++ b/prog-mode/commentline
@@ -0,0 +1,7 @@
+# -*- mode: snippet -*-
+# contributor: sh-ow <sh-ow@users.noreply.github.com>
+# name: commentline
+# key: co
+# --
+${1:$(let* ((start (substring comment-start 0 (dotimes (i (length comment-start)) (unless (or (eq (aref (reverse comment-start) i) nil) (eq (aref (reverse comment-start) i) 32)) (return (- (length comment-start) i))))))) start)} ${1:comment} ${1:$(let* ((str "") (curr (current-column)) (start (substring comment-start 0 (dotimes (i (length comment-start)) (unless (or (eq (aref (reverse comment-start) i) nil) (eq (aref (reverse comment-start) i) 32)) (return (- (length comment-start) i)))))) (lastcom (substring start -1)) (end (if (eq (length comment-end) 0) (reverse start) (substring comment-end (dotimes (i (length comment-end)) (unless (or (eq (aref comment-end i) nil) (eq (aref comment-end i) 32)) (return i))))))) (while (< (length str) (- 79 (+ curr (length end)))) (setq str (concat str lastcom))) (concat str end))}
+$0