Created
February 23, 2021 07:33
-
-
Save wiedzmin/a4b627ec0c9069029988e290be540704 to your computer and use it in GitHub Desktop.
timestamp yasnippet for emacs, with ✨ extra bloat ✨
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defvar il/timestamp-map '((year "%Y") | |
(month "%02m") | |
(day "%02d") | |
(nameofday "%A") | |
(time "%H:%M")) | |
"Mapping of the components for `il/timestamp'") | |
(defun il/timestamp (&optional component) | |
"Inserts components for timestamps. | |
Components are mapped in the variable `il/timestamp-map'." | |
(interactive "*P") | |
(let* ((timestamp (nth 0 (alist-get component il/timestamp-map)))) | |
(when timestamp (format-time-string timestamp)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: snippet -*- | |
# name: timestamp | |
# key: ts | |
# description: creates a timestamp | |
# expand-env: ((re-confirm "[yY]$")) | |
# -- | |
`(il/timestamp 'year)`${1:sep?}`(il/timestamp 'month)`${1:$(if (string= "sep?" yas-text) "" yas-text)}`(il/timestamp 'day)``"" | |
`${2: name of day?$(cond ((string= " name of day?" yas-text) " name of day?") | |
((string-match re-confirm yas-text) (prog1 (concat " " (il/timestamp 'nameofday)) (yas-next-field))) | |
(t (prog1 "" (yas-next-field))))}`"" | |
`${3: time?$(cond ((string= " time?" yas-text) " time?") | |
((string-match re-confirm yas-text) (prog1 (concat " " (il/timestamp 'time)) (yas-next-field))) | |
(t (prog1 "" (yas-next-field))))}$0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment