This commit is contained in:
2024-04-30 07:08:23 +02:00
commit a711247971
2043 changed files with 16874 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
(require 'yasnippet)
;; 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)))

View File

@@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# contributor: sh-ow <sh-ow@users.noreply.github.com>
# name: comment
# key: co
# --
`(yas-trimmed-comment-start)` ${1:comment}`(unless (eq (length comment-end) 0) (concat " " (yas-trimmed-comment-end)))`$0

View File

@@ -0,0 +1,36 @@
# -*- mode: snippet -*-
# contributor: sh-ow <sh-ow@users.noreply.github.com>
# 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

View File

@@ -0,0 +1,11 @@
# -*- mode: snippet -*-
# contributor: sh-ow <sh-ow@users.noreply.github.com>
# name: commentline
# key: col
# --
`(yas-trimmed-comment-start)` ${1:comment} ${1:$(let* ((start (yas-trimmed-comment-start))
(lastcom (aref start (1- (length start))))
(end (yas-trimmed-comment-end))
(endpadlen (- 79 (+ (current-column) (length end)))))
(concat (make-string (max endpadlen 0) lastcom)
end))}$0

6
snippets/prog-mode/fixme Normal file
View File

@@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: fixme
# key: fi
# condition: (not (eq major-mode 'sh-mode))
# --
`comment-start`FIXME: $0`comment-end`

5
snippets/prog-mode/todo Normal file
View File

@@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: todo
# key: t
# --
`comment-start`TODO: $0`comment-end`

5
snippets/prog-mode/xxx Normal file
View File

@@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: xxx
# key: x
# --
`comment-start`XXX: $0`comment-end`