Last active
December 15, 2015 07:19
-
-
Save ngn999/5222100 to your computer and use it in GitHub Desktop.
周报模板
This file contains hidden or 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
定义一个 markdown-mode下的 snippet | |
<pre> | |
# -*- mode: snippet -*- | |
# name: zhoubao | |
# key: zhoubao | |
# binding: C-c C-n | |
# -- | |
## ${1:#你的名字#}周报 | |
`(concat "__" (yesterday-is 1) " ~ " (tommorow-is 5) "__")` | |
### 本周 | |
***** | |
#### ${2:#项目名字1#} | |
1. $0 | |
### 下周 | |
***** | |
#### $2 | |
1. bla~bla~ | |
</pre> | |
***** | |
用到的两个函数: | |
```Emacs-lisp | |
;;; used for zhoubao snippet | |
(defun yesterday-is (day) | |
"" | |
(let* ((cur (current-time)) | |
(seconds (+ (lsh (car cur) 16) (cadr cur)))) | |
(while (/= day (what-day-is-today seconds)) | |
(setq seconds (- seconds (* 24 60 60)))) | |
;;; return %Y-%m-%d | |
(format-time-string "%Y-%m-%d" (cons (lsh seconds -16) (logand seconds #xFFFF))) | |
)) | |
(defun tommorow-is (day) | |
"" | |
(let* ((cur (current-time)) | |
(seconds (+ (lsh (car cur) 16) (cadr cur)))) | |
(while (/= day (what-day-is-today seconds)) | |
(setq seconds (+ seconds (* 24 60 60)))) | |
;;; return %Y-%m-%d | |
(format-time-string "%Y-%m-%d" (cons (lsh seconds -16) (logand seconds #xFFFF))) | |
)) | |
(defun what-day-is-today (seconds) | |
(nth 6 (decode-time (cons (lsh seconds -16) (logand seconds #xFFFF))))) | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment