From fc977b29f03a784f13510a0625cf2e16b38c7af2 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Thu, 17 Dec 2015 01:50:46 +0100 Subject: [PATCH] Move some functions to org-init --- emacs/.emacs.d/init.el | 38 ---------------------------- emacs/.emacs.d/site-lisp/org-init.el | 38 ++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/emacs/.emacs.d/init.el b/emacs/.emacs.d/init.el index 8bd0916..62036f4 100644 --- a/emacs/.emacs.d/init.el +++ b/emacs/.emacs.d/init.el @@ -141,30 +141,6 @@ MODE1 is enabled and vice-versa." "Set the `disabled' property for each item in FUNCTIONS to nil." (mapc #'(lambda (f) (put f 'disabled nil)) functions)) -(defun oni:mini-fix-timestamp-string (date-string) - "A minimal version of Xah Lee's `fix-timestamp-string'. -Turn DATE-STRING into something else that can be worked with in -code. Found at http://xahlee.org/emacs/elisp_parse_time.html" - (setq date-string (replace-regexp-in-string "Jan" "01" date-string) - date-string (replace-regexp-in-string "Feb" "02" date-string) - date-string (replace-regexp-in-string "Mar" "03" date-string) - date-string (replace-regexp-in-string "Apr" "04" date-string) - date-string (replace-regexp-in-string "May" "05" date-string) - date-string (replace-regexp-in-string "Jun" "06" date-string) - date-string (replace-regexp-in-string "Jul" "07" date-string) - date-string (replace-regexp-in-string "Aug" "08" date-string) - date-string (replace-regexp-in-string "Sep" "09" date-string) - date-string (replace-regexp-in-string "Oct" "10" date-string) - date-string (replace-regexp-in-string "Nov" "11" date-string) - date-string (replace-regexp-in-string "Dec" "12" date-string)) - (string-match - "^\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{4\\}\\)$" - date-string) - (format "%s-%s-%s" - (match-string 3 date-string) - (match-string 2 date-string) - (match-string 1 date-string))) - (defun oni:mode-line-current-song () "Extract current song information from a path. @@ -203,20 +179,6 @@ extracts the parts I want to know about." (end-of-line))) (end-of-line)))) -(defun oni:myepisodes-formatter (plist) - "Format RSS items from MyEpisodes as org tasks. -PLIST contains all the pertinent information." - (let ((str (plist-get plist :title))) - (string-match - "^\\[ \\([^\]]+\\) \\]\\[ \\([^\]]+\\) \\]\\[ \\([^\]]+\\) \\]\\[ \\([^\]]+\\) \\]$" - str) - (let* ((title (match-string 1 str)) - (episode (match-string 2 str)) - (name (match-string 3 str)) - (date (oni:mini-fix-timestamp-string (match-string 4 str)))) - (format "* ACQUIRE %s %s - %s \n SCHEDULED: <%s>" - title episode name date)))) - (defun oni:scuttle-formatter (plist) "Format RSS items from Scuttle as org tasks. diff --git a/emacs/.emacs.d/site-lisp/org-init.el b/emacs/.emacs.d/site-lisp/org-init.el index 79755e1..bd35f41 100644 --- a/emacs/.emacs.d/site-lisp/org-init.el +++ b/emacs/.emacs.d/site-lisp/org-init.el @@ -53,6 +53,44 @@ "Generate a hex color by taking the first 6 characters of OBJECT's MD5 sum." (format "#%s" (substring (md5 object) 0 6))) +(defun oni:mini-fix-timestamp-string (date-string) + "A minimal version of Xah Lee's `fix-timestamp-string'. +Turn DATE-STRING into something else that can be worked with in +code. Found at http://xahlee.org/emacs/elisp_parse_time.html" + (setq date-string (replace-regexp-in-string "Jan" "01" date-string) + date-string (replace-regexp-in-string "Feb" "02" date-string) + date-string (replace-regexp-in-string "Mar" "03" date-string) + date-string (replace-regexp-in-string "Apr" "04" date-string) + date-string (replace-regexp-in-string "May" "05" date-string) + date-string (replace-regexp-in-string "Jun" "06" date-string) + date-string (replace-regexp-in-string "Jul" "07" date-string) + date-string (replace-regexp-in-string "Aug" "08" date-string) + date-string (replace-regexp-in-string "Sep" "09" date-string) + date-string (replace-regexp-in-string "Oct" "10" date-string) + date-string (replace-regexp-in-string "Nov" "11" date-string) + date-string (replace-regexp-in-string "Dec" "12" date-string)) + (string-match + "^\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{4\\}\\)$" + date-string) + (format "%s-%s-%s" + (match-string 3 date-string) + (match-string 2 date-string) + (match-string 1 date-string))) + +(defun oni:myepisodes-formatter (plist) + "Format RSS items from MyEpisodes as org tasks. +PLIST contains all the pertinent information." + (let ((str (plist-get plist :title))) + (string-match + "^\\[ \\([^\]]+\\) \\]\\[ \\([^\]]+\\) \\]\\[ \\([^\]]+\\) \\]\\[ \\([^\]]+\\) \\]$" + str) + (let* ((title (match-string 1 str)) + (episode (match-string 2 str)) + (name (match-string 3 str)) + (date (oni:mini-fix-timestamp-string (match-string 4 str)))) + (format "* ACQUIRE %s %s - %s \n SCHEDULED: <%s>" + title episode name date)))) + (defun oni:org-colors-for (names) "Create an alist for NAMES with corresponding colors." (mapcar (lambda (name) (cons name (oni:color-for name))) names))