Better title heuristic for org template

Uses a stripped version of s-titleized-words, to not add s.el as a dependency.
This commit is contained in:
yoavm448 2020-02-28 20:45:00 +02:00
parent 56cba7828c
commit ad89f79926

View file

@ -1,6 +1,20 @@
# -*- mode: snippet -*-
# name: Org template
# --
#+TITLE: ${1:`(file-name-base buffer-file-name)`}
#+TITLE: ${1:`
(string-join
(mapcar #'capitalize
;; Replace -,_... with space
(split-string
(let (case-fold-search)
;; Seperating lower from upper: hello|World
(replace-regexp-in-string
"\\([[:lower:]]\\)\\([[:upper:]]\\)" "\\1 \\2"
;; Separating upper from (upper and lower): HTTP|Server
(replace-regexp-in-string "\\([[:upper:]]\\)\\([[:upper:]][0-9[:lower:]]\\)"
"\\1 \\2" (file-name-base buffer-file-name))))
"[^[:word:]0-9]+"
)) " " )
`}
$0