[Timeline] Cleaning up as suggested by flycheck

This commit is contained in:
Daniel - 2018-11-28 16:58:13 +01:00
parent c8e9c6340e
commit 98f94be5f7
Signed by: dbo
GPG Key ID: 4F63DB96D45AA9C6
1 changed files with 15 additions and 14 deletions

View File

@ -75,7 +75,7 @@ Filter are applied in the order they are given in this list."
"Format of time used in the headline of a timeline.") "Format of time used in the headline of a timeline.")
(defvar timeline-tools-time-format "%Y-%m-%d %H:%M" (defvar timeline-tools-time-format "%Y-%m-%d %H:%M"
"Format of time used inside a timeline") "Format of time used inside a timeline.")
(defvar timeline-tools-mode-map (defvar timeline-tools-mode-map
(let ((map (make-sparse-keymap))) (let ((map (make-sparse-keymap)))
@ -115,17 +115,17 @@ Filter are applied in the order they are given in this list."
"Return a timeline entry made up of START-TIME, END-TIME, and MARKER. "Return a timeline entry made up of START-TIME, END-TIME, and MARKER.
MARKER must be a single marker." MARKER must be a single marker."
(unless (markerp marker) (unless (markerp marker)
(user-error "No marker given.")) (user-error "No marker given"))
(list start-time end-time marker)) (list start-time end-time marker))
(defun timeline-tools-entry-duration (entry) (defun timeline-tools-entry-duration (entry)
"Returns the duration of ENTRY, in minutes." "Return the duration of ENTRY, in minutes."
(floor (/ (- (timeline-tools-entry-end-time entry) (floor (/ (- (timeline-tools-entry-end-time entry)
(timeline-tools-entry-start-time entry)) (timeline-tools-entry-start-time entry))
60))) 60)))
(defun timeline-tools-entry-category (entry) (defun timeline-tools-entry-category (entry)
"Return ARCHIVE_CATEGORY or CATEGORY at position given by MARKER. "Return ARCHIVE_CATEGORY or CATEGORY at position given by marker of ENTRY.
Return whatever is found first." Return whatever is found first."
(let ((marker (timeline-tools-entry-marker entry))) (let ((marker (timeline-tools-entry-marker entry)))
(or (org-entry-get marker "ARCHIVE_CATEGORY") (or (org-entry-get marker "ARCHIVE_CATEGORY")
@ -323,7 +323,7 @@ function will throw an error."
(timeline-tools-make-entry (timeline-tools-make-entry
(timeline-tools-entry-start-time (-first-item cluster)) (timeline-tools-entry-start-time (-first-item cluster))
(timeline-tools-entry-end-time (-last-item cluster)) (timeline-tools-entry-end-time (-last-item cluster))
(timeline-tools-entry-markers (-first-item cluster)))) (timeline-tools-entry-marker (-first-item cluster))))
new-timeline))) new-timeline)))
(defun timeline-tools-remove-short-entries (timeline &optional threshold) (defun timeline-tools-remove-short-entries (timeline &optional threshold)
@ -376,8 +376,9 @@ This function destructively modifies its first argument."
(setf (timeline-tools-entry-start-time entry-2) middle)))))) (setf (timeline-tools-entry-start-time entry-2) middle))))))
(defun timeline-tools-transform-timeline (timeline) (defun timeline-tools-transform-timeline (timeline)
"Return timeline from files, after application of "Return result of filtering TIMELINE.
`timeline-tools-filter-functions." Filtering is done by applying all functions from
`timeline-tools-filter-functions, in order."
(-reduce-from (lambda (tl f) (-reduce-from (lambda (tl f)
(funcall f tl)) (funcall f tl))
timeline timeline
@ -429,7 +430,7 @@ archives."
;; Interactive functions ;; Interactive functions
(defun timeline-tools-redraw-timeline () (defun timeline-tools-redraw-timeline ()
"Redraw timeline of current buffer" "Redraw timeline of current buffer."
(interactive) (interactive)
(if (not (eq major-mode 'timeline-tools-mode)) (if (not (eq major-mode 'timeline-tools-mode))
(user-error "Not in Timeline buffer") (user-error "Not in Timeline buffer")
@ -461,7 +462,7 @@ archives."
(timeline-tools-next-line)))) (timeline-tools-next-line))))
(defun timeline-tools-reparse-timeline () (defun timeline-tools-reparse-timeline ()
"Parse timeline from files again and redraws current display "Parse timeline from files again and redraw current display.
Updates category properties before constructing the new timeline." Updates category properties before constructing the new timeline."
(interactive) (interactive)
(dolist (file timeline-tools--current-files) (dolist (file timeline-tools--current-files)
@ -543,14 +544,14 @@ Interactively query for the exact value of \"short\"."
(save-mark-and-excursion (save-mark-and-excursion
;; get actual entry from headline of line ;; get actual entry from headline of line
(end-of-line) (end-of-line)
(unless (looking-back " |$") (unless (looking-back " |$" nil)
(user-error "Not in table.")) (user-error "Not in table"))
(org-table-previous-field) (org-table-previous-field)
(let ((entry (get-text-property (point) 'entry))) (let ((entry (get-text-property (point) 'entry)))
(unless entry (unless entry
(user-error "Not on valid row in timeline.")) (user-error "Not on valid row in timeline"))
(unless (< 1 (length timeline-tools--current-timeline)) (unless (< 1 (length timeline-tools--current-timeline))
(user-error "Cannot delete last line.")) (user-error "Cannot delete last line"))
(setq-local timeline-tools--current-timeline (setq-local timeline-tools--current-timeline
(timeline-tools-transform-timeline (timeline-tools-transform-timeline
(delq entry timeline-tools--current-timeline))))) (delq entry timeline-tools--current-timeline)))))
@ -681,7 +682,7 @@ TARGET-ID are adapted accordingly."
(push (cdr clock-line) inverted-timeline) (push (cdr clock-line) inverted-timeline)
(push (car clock-line) inverted-timeline)) (push (car clock-line) inverted-timeline))
(setq inverted-timeline (-partition 2 (rest (reverse inverted-timeline)))) (setq inverted-timeline (-partition 2 (cl-rest (reverse inverted-timeline))))
;; This is inefficient, but see comment in ;; This is inefficient, but see comment in
;; `timeline-tools-copy-clocklines for rationale. ;; `timeline-tools-copy-clocklines for rationale.