Merge pull request #2630 from yoavm448/org-file-template

Title-capitalization for title in org file template
This commit is contained in:
Henrik Lissner 2020-02-28 22:27:12 -05:00 committed by GitHub
commit 02eedac45e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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