Move some functions to org-init

This commit is contained in:
Tom Willemse 2015-12-17 01:50:46 +01:00
parent bdf984607e
commit fc977b29f0
2 changed files with 38 additions and 38 deletions

View file

@ -141,30 +141,6 @@ MODE1 is enabled and vice-versa."
"Set the `disabled' property for each item in FUNCTIONS to nil." "Set the `disabled' property for each item in FUNCTIONS to nil."
(mapc #'(lambda (f) (put f 'disabled nil)) functions)) (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 () (defun oni:mode-line-current-song ()
"Extract current song information from a path. "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)))
(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) (defun oni:scuttle-formatter (plist)
"Format RSS items from Scuttle as org tasks. "Format RSS items from Scuttle as org tasks.

View file

@ -53,6 +53,44 @@
"Generate a hex color by taking the first 6 characters of OBJECT's MD5 sum." "Generate a hex color by taking the first 6 characters of OBJECT's MD5 sum."
(format "#%s" (substring (md5 object) 0 6))) (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) (defun oni:org-colors-for (names)
"Create an alist for NAMES with corresponding colors." "Create an alist for NAMES with corresponding colors."
(mapcar (lambda (name) (cons name (oni:color-for name))) names)) (mapcar (lambda (name) (cons name (oni:color-for name))) names))