Config publishing: capitalize snippet names

This commit is contained in:
TEC 2021-03-21 15:39:40 +08:00
parent a4a04c28c4
commit 2652b52d95
Signed by: tec
GPG Key ID: 779591AFDB81F06C
1 changed files with 18 additions and 7 deletions

View File

@ -13,13 +13,24 @@
(defun rename (name)
(let ((out
(string-trim
(replace-regexp-in-string
"[-_]" " "
name))))
(cond
((string= "" out) "File Template")
(t out))))
(string-trim
(replace-regexp-in-string
"[-_]" " "
name))))
(if (string= "" out) "File template"
(let ((sentence (expand-text-abbrevs out)))
(concat (char-to-string (upcase (aref sentence 0)))
(substring sentence 1))))))
(defun expand-text-abbrevs (str)
(mapconcat
(lambda (word)
(cond
((string= word "src") "source")
((string-match-p "args?" word) (replace-regexp-in-string "arg" "argument" word))
(t word)))
(split-string str)
" "))
(princ
(concat