From bb2973405f757864f15fbcaa4c19ac2ff096caba Mon Sep 17 00:00:00 2001 From: contrapunctus Date: Tue, 1 Jun 2021 11:03:22 +0530 Subject: [PATCH] cleanup: remove diary-view code (obsoleted by chronometrist-details) --- elisp/chronometrist-diary-view.el | 102 ------------------------------ 1 file changed, 102 deletions(-) delete mode 100644 elisp/chronometrist-diary-view.el diff --git a/elisp/chronometrist-diary-view.el b/elisp/chronometrist-diary-view.el deleted file mode 100644 index 4cbace3..0000000 --- a/elisp/chronometrist-diary-view.el +++ /dev/null @@ -1,102 +0,0 @@ -;;; chronometrist-diary-view.el --- A diary-like view for Chronometrist -*- lexical-binding: t; -*- - -;; Author: contrapunctus - -;; This is free and unencumbered software released into the public domain. -;; -;; Anyone is free to copy, modify, publish, use, compile, sell, or -;; distribute this software, either in source code form or as a compiled -;; binary, for any purpose, commercial or non-commercial, and by any -;; means. -;; -;; For more information, please refer to - -;;; Commentary: -;; TODO - add forward/backward, current date display (and don't scroll -;; past the actual data) - -;; TODO - when the reason is "-", add that interval to the next reason - -;; TODO - permit switching between time formats -;; - hours and minutes - "X hours, Y minutes" -;; - minutes only - "80 minutes" -;; - relaxed - "(almost|slightly over) 1 hour" -;; - strict time periods (using `chronometrist-seconds-to-hms') -;; - period start/end ("HH:MM to HH:MM") -;; Add variable to store format functions as list (first one is -;; default), command to cycle between them - -;;; Code: -(require 'chronometrist) - -(defvar chronometrist-diary-buffer-name "*Chronometrist-Diary*" - "Name for the buffer created by `chronometrist-diary'.") - -(defvar chronometrist-diary--current-date nil - "Stores the date for the buffer.") - -(defun chronometrist-intervals-on (date) - "Return a list of all time intervals on DATE. - -DATE should be a list in the form \"YYYY-MM-DD\" - -Each time interval is a string as returned by `chronometrist-seconds-to-hms'." - (->> (gethash date chronometrist-events) - (chronometrist-events->ts-pairs) - ;; Why were we calling `-partition' here? - ;; (-partition 2) - (--map (time-subtract (cadr it) (car it))) - (--map (chronometrist-seconds-to-hms (cadr it))))) - -;; "X minutes on TASK (REASON)" - -;; TODO - think of a better way to show details concisely, ideally -;; combining tags and key-values -(defun chronometrist-diary-tasks-reasons-on (date) - "Return a list of tasks and reasons on DATE." - (mapcar (lambda (plist) - (let ((task (plist-get plist :name)) - (reason (or (plist-get plist :comment) ""))) - (concat " on " task - (unless (equal reason "") - (concat " (" reason ")")) - "\n"))) - (gethash date chronometrist-events))) - -(defun chronometrist-diary-refresh (&optional _ignore-auto _noconfirm date) - "Refresh the `chronometrist-diary' buffer. - -This does not re-read `chronometrist-file'. - -Optional argument DATE should be a list in the form -\"YYYY-MM-DD\". If not supplied, today's date is used. - -The optional arguments _IGNORE-AUTO and _NOCONFIRM are ignored, -and are present solely for the sake of using this function as a -value of `revert-buffer-function'." - (let* ((date (if date date (chronometrist-date))) - (intervals (->> (chronometrist-intervals-on date) - (mapcar #'chronometrist-format-time))) - (tasks-reasons (chronometrist-diary-tasks-reasons-on date)) - (inhibit-read-only t)) - (setq chronometrist-diary--current-date date) - (chronometrist-common-clear-buffer chronometrist-diary-buffer-name) - (seq-mapn #'insert intervals tasks-reasons))) - -(define-derived-mode chronometrist-diary-view-mode special-mode "Chronometrist-Diary" - "A mode to view your activity today like a diary." - (setq revert-buffer-function #'chronometrist-diary-refresh)) - -(defun chronometrist-diary-view (&optional date) - "Display today's Chronometrist data in a diary-like view. -If DATE is supplied, show data for that date. DATE should be an -ISO-8601 date string (\"YYYY-MM-DD\")." - (interactive) - (switch-to-buffer - (get-buffer-create chronometrist-diary-buffer-name)) - (chronometrist-diary-view-mode) - (chronometrist-diary-refresh nil nil date)) - -(provide 'chronometrist-diary-view) - -;;; chronometrist-diary-view.el ends here