These gists are no longer updated because gists cannot handle directories.
Last active
July 22, 2018 11:02
-
-
Save thunderrabbit/453c1e1c4a959f113d10 to your computer and use it in GitHub Desktop.
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
(fset 'rn-00-redact-emails-in-comments | |
[?\C-s ?c ?o ?m ?m ?e ?n ?t return return ?\C-s ?@ return ?\C-k ? ?* ?r ?e ?d ?a ?c ?t ?e ?d ?* escape ?b escape ?b return ?< ?p ?> ?< ?b ?> ?E ?m ?a ?i ?l ?: ?< ?/ ?b ?> ? ?\C-a ?\C-p ?\C-k ?\C-k ?\C-x ?\C-s ?\C-x ?k return ?n]) | |
(fset 'rn-01-embed-comments | |
[?\C-s ?. ?c ?o ?m ?m ?e ?n ?t return return ?\C- escape ?> ?\C-w ?\C-x ?\C-s ?\C-x ?k return ?p return escape ?> escape ?> return ?# ?# ?# ?c ?o ?m ?m ?e ?n ?t ?s return ?\C-y ?\C-x ?\C-s ?\C-x ?k return ?n ?n]) | |
(fset 'rn-02-create-yaml-files | |
[?\C- ?\C-e escape ?w ?\C-x ?\C-f ?\C-y ?. ?y ?a ?m ?l return ?\C-y return ?\C-x ?i ?~ ?/ ?j ?o ?u ?r ?n ?a ?l ?. backspace ?- ?r ?n ?. ?c ?o ?m ?/ ?y ?a ?m tab return ?\C-p ?\C-f ?\C-f ?\C-k backspace backspace ?\C-d ?\C-n ?\C-e ?\C-y backspace backspace backspace backspace backspace ?\C-n ?\C-n ?\C-n ?\C-x ?\C-s ?\C-x ?b ?* ?M ?e ?s ?s ?a ?g ?e ?s tab return ?\C-p ?\C-s ?. ?c ?o ?m ?\C-s return ?\C-f ?\C- ?\C-f ?\C-f ?\C-f ?\C-f ?\C-f ?\C-f ?\C-f ?\C-f ?\C-f ?\C-f escape ?w ?\C-x ?k return ?\C-y ?\C-b ?\C-b backspace ?- ?\C-b ?\C-b ?\C-b backspace ?- escape ?< escape ?x ?r ?e ?p ?l tab ?s ?t tab return ?_ return ? return ?\C-a ?\C-x ?\C-s ?\C-x ?k return ?n]) | |
(fset 'rn-03-add-dream-tags | |
[?\C-s ?d ?r ?e ?a ?m return ?\C-s ?y ?a ?m ?l return return ?\C-n ?\C-n ?\C-e ?d ?r ?e ?a ?m ?\C-x ?\C-s ?\C-x ?k return ?g ?n ?n]) | |
(fset 'rn-04-add-sleepy-tags | |
[?\C-s ?z ?z ?z return ?\C-s ?y ?a ?m ?l return return ?\C-n ?\C-n ?\C-e ?s ?l ?e ?e ?p ?y ?\C-x ?\C-s ?\C-x ?k return ?g ?n ?n]) | |
(fset 'rn-05-prepare-to-merge-yaml-files | |
[?g ?~ ?x ?y ?e ?s return]) | |
(fset 'rn-06-merge-yaml-files | |
[?\C- ?\C-e escape ?w return return ?\C-p ?\C-x ?i ?\C-y ?. ?y tab return ?\C-x ?\C-s ?\C-x ?k return ?R ?\C-y backspace backspace backspace backspace ?m ?d return ?n ?d]) |
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
;;; journal.el --- Convenience functions for working with journal. | |
;; | |
;;; Commentary: | |
;; Convenience functions for working with journal. | |
;;; Code: | |
(defvar journal-site-location "~/journal/" | |
"The location of the journal files.") | |
(defvar location-journal-template-files "~/.emacs.d/personal/hakyll/templates/" | |
"The location of templates used in this file") | |
(defun journal-insert-image (alt-text) | |
"Insert an image from /images/yyyy/mm to current buffer /posts/yyyy/mm/dd/....md" | |
(interactive "sAltText: ") | |
(let ((yyyymm (substring buffer-file-name 35 42))) | |
(insert | |
(format "![%s](/images/%s/thumbs/" | |
alt-text | |
yyyymm | |
)) | |
) | |
) | |
(fset 'ruby-tag-create-region | |
"\C-w<ruby><rb>\C-y</rb><rt></rt></ruby>\C-b\C-b\C-b\C-b\C-b\C-b\C-b\C-b\C-b\C-b\C-b\C-b") | |
(fset 'hugo-youtube | |
[?\C-e escape ?\C-r ?/ ?\\ ?| ?= return right ?\C-k ?\C-a ?\{ ?\{ ?< ? ?y ?o ?u ?t ?u ?b ?e ? ?\C-y ? ?> ?\} ?\} ?\C-k right]) | |
(defun journal-new-dream-post (title tags yyyy mm dd) | |
"Create a new journal post for today with TITLE and TAGS." | |
(interactive (list | |
(read-string (format "Title: (%s):" "Dream") nil nil "Dream") | |
(journal-read-tags nil) | |
(read-string (format "Year (%s): " (format-time-string "%Y")) nil nil (format-time-string "%Y")) | |
(read-string (format "Month (%s): " (format-time-string "%m")) nil nil (format-time-string "%m")) | |
(read-string (format "Date (%s): " (format-time-string "%d")) nil nil (format-time-string "%d")) | |
) | |
) | |
(let ( | |
(file-name (journal-post-title dd title)) | |
(file-path (journal-post-path title yyyy mm dd)) | |
) | |
(set-buffer (get-buffer-create file-path)) | |
(insert | |
(format "---\ntitle: \"%s\"\ntags: [ %s ]\nauthor: Rob Nugen\ndate: %s-%s-%sT%s\n---\n\n%s\n\n" | |
title | |
(mapconcat (lambda (x) (format "\"%s\"" (downcase x))) | |
tags ", ") | |
yyyy | |
mm | |
dd | |
(format-time-string "%H:%M:%S+09:00") | |
(format-time-string "## %H:%M %A %d %B %Y %Z") | |
)) | |
(write-file | |
(expand-file-name file-path (concat journal-site-location ""))) | |
(switch-to-buffer file-name) | |
(auto-fill-mode) | |
) | |
) | |
(defun journal-new-japanese-post (title tags yyyy mm dd) | |
"Create a new journal post for today with TITLE and TAGS." | |
(interactive (list | |
(read-string (format "Title: (%s):" "日本語を勉強しました") nil nil "日本語を勉強しました") | |
(journal-read-tags nil) | |
(read-string (format "Year (%s): " (format-time-string "%Y")) nil nil (format-time-string "%Y")) | |
(read-string (format "Month (%s): " (format-time-string "%m")) nil nil (format-time-string "%m")) | |
(read-string (format "Date (%s): " (format-time-string "%d")) nil nil (format-time-string "%d")) | |
) | |
) | |
(let ( | |
(file-name (journal-post-title dd "studied japanese")) | |
(file-path (journal-post-path "studied japanese" yyyy mm dd)) | |
) | |
(set-buffer (get-buffer-create file-path)) | |
(insert | |
(format "---\ntitle: \"%s\"\ntags: [ %s ]\nauthor: Rob Nugen\ndate: %s-%s-%sT%s\n---\n\n%s\n\n### There are probably errors in the Japanese notes below!\n\n" | |
title | |
(mapconcat (lambda (x) (format "\"%s\"" (downcase x))) | |
tags ", ") | |
yyyy | |
mm | |
dd | |
(format-time-string "%H:%M:%S+09:00") | |
(format-time-string "## %H:%M %A %d %B %Y %Z") | |
)) | |
(write-file | |
(expand-file-name file-path (concat journal-site-location ""))) | |
(switch-to-buffer file-name) | |
(auto-fill-mode) | |
) | |
) | |
(defun journal-new-post (title tags yyyy mm dd) | |
"Create a new journal post for today with TITLE and TAG." | |
(interactive (list | |
(read-string "Title: ") | |
(journal-read-tags nil) | |
(read-string (format "Year (%s): " (format-time-string "%Y")) nil nil (format-time-string "%Y")) | |
(read-string (format "Month (%s): " (format-time-string "%m")) nil nil (format-time-string "%m")) | |
(read-string (format "Date (%s): " (format-time-string "%d")) nil nil (format-time-string "%d")) | |
) | |
) | |
(let ( | |
(file-name (journal-post-title dd title)) | |
(file-path (journal-post-path title yyyy mm dd)) | |
) | |
(set-buffer (get-buffer-create file-path)) | |
(insert | |
(format "---\ntitle: \"%s\"\ntags: [ %s ]\nauthor: Rob Nugen\ndate: %s-%s-%sT%s\n---\n\n%s\n\n" | |
title | |
(mapconcat (lambda (x) (format "\"%s\"" (downcase x))) | |
tags ", ") | |
yyyy | |
mm | |
dd | |
(format-time-string "%H:%M:%S+09:00") | |
(format-time-string "## %H:%M %A %d %B %Y %Z") | |
)) | |
(write-file | |
(expand-file-name file-path (concat journal-site-location ""))) | |
(switch-to-buffer file-name) | |
(auto-fill-mode) | |
) | |
) | |
(defun my-test (title tags) | |
(interactive (list (read-string "Title: ") (journal-read-tags))) | |
(message "%s: %s" title | |
(mapconcat (lambda (x) (format "'%s'" x)) | |
tags ", ") | |
)) | |
(defun get-string-from-file (filePath) | |
"Return filePath's file content." | |
(with-temp-buffer | |
(insert-file-contents filePath) | |
(buffer-string))) | |
;; thanks to “Pascal J Bourguignon” and “TheFlyingDutchman 〔zzbba…@aol.com〕”. 2010-09-02 | |
;; via http://ergoemacs.org/emacs/elisp_read_file_content.html 2018-07-21 | |
(defun journal-read-tags (tags) | |
(let (tag done) | |
(while (not done) | |
(setq tag (read-string "Tag: ")) | |
(if (= (length tag) 0) | |
(setq done t) | |
(push tag tags))) | |
(nreverse tags))) | |
;;; http://stackoverflow.com/a/251922 | |
(defvar current-date-time-format "## %H:%M %A %d %B %Y %Z" | |
"Format of date to insert with `insert-current-date-time' func | |
See help of `format-time-string' for possible replacements") | |
(defvar current-time-format "## %H:%M" | |
"Format of date to insert with `insert-current-time' func. | |
Note the weekly scope of the command's precision.") | |
(defun markdown-timestamp-full () | |
"Insert the current date and time into current buffer. Uses `current-date-time-format' for the formatting the date/time." | |
(interactive) | |
(insert (format-time-string current-date-time-format (current-time))) | |
(insert "\n") | |
) | |
(defun markdown-timestamp-short () | |
"Insert the current time (1-week scope) into the current buffer." | |
(interactive) | |
(insert (format-time-string current-time-format (current-time))) | |
(insert "\n") | |
) | |
(defun journal-new-note (title) | |
"Create a new Note with TITLE." | |
(interactive "sTitle: ") | |
(let ((file-name (journal-note-title title))) | |
(set-buffer (get-buffer-create file-name)) | |
(insert (format "---\ntitle: %s\ndescription: \n---\n\n" title)) | |
(write-file | |
(expand-file-name file-name (concat journal-site-location "notes"))) | |
(switch-to-buffer file-path))) | |
(defun journal-post-title (dd title) | |
"Return a file name based on TITLE for the post." | |
(concat dd | |
(url-safe-string title) | |
".md")) | |
(defun journal-post-path (title yyyy mm dd) | |
"Return a file path based on TITLE and date." | |
(concat | |
yyyy "/" mm "/" dd | |
(url-safe-string title) | |
".md")) | |
(defun journal-note-title (title) | |
"Return a file name based on TITLE for the note." | |
(concat | |
(url-safe-string title) | |
".md")) | |
(defun url-safe-string (title) | |
"Return a URL-safe title based on TITLE." | |
(replace-regexp-in-string "[:!']" "" | |
(replace-regexp-in-string " " "-" (downcase title)) | |
) | |
) | |
(provide 'journal) | |
;;; hakyll.el ends here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment