summaryrefslogtreecommitdiffstats
path: root/emacsconf.el
diff options
context:
space:
mode:
authorSacha Chua <sacha@sachachua.com>2022-10-02 19:36:26 -0400
committerSacha Chua <sacha@sachachua.com>2022-10-02 19:36:26 -0400
commite00be6120c606582a0fa1b6ac74d9b218c663a52 (patch)
tree06523de26ae27dcae4e7871e0739cd55c4e3c29c /emacsconf.el
parent5a1deece01a57849e672716c5af3ecbe4bca92c5 (diff)
downloademacsconf-el-e00be6120c606582a0fa1b6ac74d9b218c663a52.tar.xz
emacsconf-el-e00be6120c606582a0fa1b6ac74d9b218c663a52.zip
Refactor emacsconf-schedule
Diffstat (limited to 'emacsconf.el')
-rw-r--r--emacsconf.el194
1 files changed, 0 insertions, 194 deletions
diff --git a/emacsconf.el b/emacsconf.el
index 9010bb8..9628872 100644
--- a/emacsconf.el
+++ b/emacsconf.el
@@ -479,91 +479,6 @@
(defun emacsconf-public-talks (info)
(seq-filter (lambda (f) (plist-get f :public)) info))
-;;; Schedule summary
-
-(defun emacsconf-round-start-to-five ()
- (let* ((start-time (org-get-scheduled-time (point)))
- (decoded-time (decode-time start-time "America/Toronto"))
- (duration (* (string-to-number (org-entry-get (point) "TIME")) 60))
- (minutes (elt decoded-time 1))
- offset end-time)
- (unless (= (mod minutes 5) 0)
- (setq offset (seconds-to-time (* 60 (- 5 (mod minutes 5))))
- end-time (time-add start-time (time-to-seconds duration)))
- (org-set-property "SCHEDULED" (format "%s-%s" (format-time-string "%Y-%m-%d %H:%M" (time-add start-time offset))
- (format-time-string "%H:%M" (time-add end-time offset)))))))
-
-;(emacsconf-update-schedules #'emacsconf-round-start-to-five)
-(defvar emacsconf-default-buffer-minutes-for-live-q-and-a 15)
-(defvar emacsconf-default-buffer-minutes 5)
-(defun emacsconf-allocate-buffer-time (o)
- (when (plist-get o :slug)
- (plist-put o :buffer
- (number-to-string
- (if (string-match "live" (plist-get o :q-and-a))
- emacsconf-default-buffer-minutes-for-live-q-and-a
- emacsconf-default-buffer-minutes))))
- o)
-
-(defun emacsconf-allocate-max-time (o)
- (when (plist-get o :max-time)
- (plist-put o :time (plist-get o :max-time)))
- o)
-
-(defvar emacsconf-tweaked-allocations nil "Alist of slug . time")
-(defun emacsconf-tweak-allocations (o)
- (let ((talk-times emacsconf-tweaked-allocations))
- (when (assoc (plist-get o :slug) emacsconf-tweaked-allocations)
- (plist-put o :time
- (number-to-string
- (assoc-default (plist-get o :slug) emacsconf-tweaked-allocations)))))
- o)
-
-
-
-(defun emacsconf-schedule-based-on-info (info)
- (let (current-time end-time duration)
- (mapcar
- (lambda (talk)
- (when (plist-get talk :fixed-time)
- (setq current-time (plist-get talk :start-time)))
- (when (and (plist-get talk :time)
- (not (string= (plist-get talk :status) "CANCELLED")))
- (setq duration (* (string-to-number (plist-get talk :time)) 60)
- end-time (time-add current-time (seconds-to-time duration)))
- (plist-put talk :scheduled
- (format "<%s-%s>" (format-time-string "%Y-%m-%d %a %H:%M" current-time)
- (format-time-string "%H:%M" end-time)))
- (plist-put talk :start-time current-time)
- (plist-put talk :end-time end-time)
- (setq current-time (time-add end-time (* (string-to-number (or (plist-get talk :buffer) "0")) 60))))
- talk)
- info)))
-
-(defun emacsconf-update-schedules (&optional modify-func)
- "Schedule the talks based on TIME and BUFFER.
-Talks with a FIXED_TIME property are not moved."
- (interactive)
- (save-excursion
- (org-with-wide-buffer
- (let (current-time end-time duration)
- (org-map-entries
- (lambda ()
- (when (or (org-entry-get (point) "TIME") (org-entry-get (point) "FIXED_TIME"))
- (let ((talk (emacsconf-get-talk-info-for-subtree)))
- (when (org-entry-get (point) "FIXED_TIME")
- (setq current-time (plist-get talk :start-time)))
- (when (and (plist-get talk :time)
- (not (string= (plist-get talk :status) "CANCELLED")))
- (setq duration (* (string-to-number (plist-get talk :time)) 60)
- end-time (time-add current-time (seconds-to-time duration)))
- (org-set-property "SCHEDULED" (format "%s-%s" (format-time-string "%Y-%m-%d %H:%M" current-time)
- (format-time-string "%H:%M" end-time)))
- (when (functionp modify-func)
- (funcall modify-func))
- (setq end-time (time-add (org-get-scheduled-time (point)) (seconds-to-time duration)))
- (setq current-time (time-add end-time (* (string-to-number (or (plist-get talk :buffer) "0")) 60))))))))))))
-
(defun emacsconf-format-short-time (string &optional omit-end-time)
(if (stringp string) (setq string (org-timestamp-from-string string)))
(downcase
@@ -579,115 +494,6 @@ Talks with a FIXED_TIME property are not moved."
(defvar emacsconf-focus 'time "'time or 'status")
-(defun emacsconf-format-schedule-summary-row (o)
- (pcase emacsconf-focus
- ('status
- (list
- (plist-get o :status)
- (if (plist-get o :slug)
- (org-link-make-string (concat "https://emacsconf.org/" emacsconf-year "/talks/"
- (plist-get o :slug))
- (plist-get o :slug))
- "")
- (if (plist-get o :scheduled)
- (emacsconf-format-short-time (plist-get o :scheduled))
- "")
- (or (plist-get o :time) "")
- (or (plist-get o :buffer) "")
- (org-link-make-string (org-link-heading-search-string (plist-get o :title))
- (plist-get o :title))
- (or (plist-get o :speakers) "")
- (or (plist-get o :q-and-a) "")
- (or (plist-get o :availability) "")))
- ('time
- (list
- (if (plist-get o :slug)
- (org-link-make-string (concat "https://emacsconf.org/" emacsconf-year "/talks/"
- (plist-get o :slug))
- (plist-get o :slug))
- "------")
- (if (and (plist-get o :scheduled)
- (not (plist-get o :fixed-time)))
- (emacsconf-format-short-time (plist-get o :scheduled) t)
- "")
- (or (plist-get o :time) "")
- (or (plist-get o :buffer) "")
- (if (< (string-to-number (or (plist-get o :time) ""))
- (string-to-number (or (plist-get o :max-time) "")))
- (plist-get o :max-time)
- "")
- (org-link-make-string (org-link-heading-search-string (plist-get o :title))
- (plist-get o :title))
- (if (plist-get o :scheduled) ; time is here twice so we can easily check it against availability
- (emacsconf-format-short-time (plist-get o :scheduled))
- "")
- (or (plist-get o :availability) "")))))
-
-(defun emacsconf-summarize-schedule (&optional info)
- (cons
- (if (eq emacsconf-focus 'time)
- (list "Slug" "Schedule" "Time" "Buffer" "Max" "Title" "Time" "Availability")
- (list "Status" "Slug" "Schedule" "Time" "Buffer" "Title" "Name" "Q&A" "Availability"))
- (mapcar #'emacsconf-format-schedule-summary-row (or info (emacsconf-get-talk-info)))))
-
-(defun emacsconf-summarize-track-as-svg (svg base-x base-y width height start-time end-time info &optional vertical)
- (let ((scale (/ (if vertical height width)
- (float-time (time-subtract end-time start-time)))))
- (mapc
- (lambda (o)
- (let* ((offset (floor (* scale (float-time (time-subtract (plist-get o :start-time) start-time)))))
- (size (floor (* scale (float-time (time-subtract (plist-get o :end-time) (plist-get o :start-time))))))
- (x (if vertical base-x (+ base-x offset)))
- (y (if vertical (+ base-y offset) base-y)))
- (svg-rectangle
- svg
- x
- y
- (if vertical width size)
- (1- (if vertical size height))
- :stroke "white"
- :fill (if (plist-get o :invalid) "red" "gray"))
- (dom-append-child
- svg
- (dom-node
- 'g
- `((transform . ,(format "translate(%d,%d)"
- (+ x (if vertical width size) -2) (+ y (if vertical size height) -2))))
- (dom-node
- 'text
- '((fill . "white")
- (x . 0)
- (y . 0)
- (font-size . 10)
- (transform . "rotate(-90)"))
- (svg--encode-text (or (plist-get o :slug) (plist-get o :title))))))))
- (emacsconf-filter-talks info))))
-
-(defun emacsconf-summarize-schedule-as-svg (width height start end tracks &optional vertical)
- (let* ((svg (svg-create width height))
- (track-width (if vertical (/ width (length tracks)) width))
- (track-height (if vertical height (/ height (length tracks))))
- (x 0) (y 0))
- (mapc (lambda (track)
- (emacsconf-summarize-track-as-svg
- svg x y track-width track-height
- start end track vertical)
- (if vertical
- (setq x (+ x track-width))
- (setq y (+ y track-height))))
- tracks)
- svg))
-
-(defun emacsconf-schedule-get-subsequence (info start &optional end)
- "START and END are regexps to match against the title in INFO."
- (seq-subseq info
- (1+ (seq-position info start
- (lambda (o match) (string-match match (plist-get o :title)))))
- (if end
- (seq-position info end
- (lambda (o match) (string-match match (plist-get o :title))))
- (length info))))
-
;;; Embark
(defun emacsconf-embark-finder ()
(when (and (derived-mode-p 'org-mode)