[Timeline] Add text properties to all fields

Actually, we add the text properties ‘marker’ and ‘entry’ to the whole line, but
the alinging of the table somehow removes the text properties between two
columns.  It is kept in the fields, though, and that is enough.
This commit is contained in:
Daniel - 2019-07-13 20:16:04 +02:00
parent af244b853b
commit 76999d9136
No known key found for this signature in database
GPG Key ID: 1C7071A75BB72D64
1 changed files with 23 additions and 25 deletions

View File

@ -485,14 +485,14 @@ archives."
(when (not (equal last-category current-category)) (when (not (equal last-category current-category))
(insert "|--|\n") (insert "|--|\n")
(setq last-category current-category)) (setq last-category current-category))
(insert (format "| %s | %s | %s | %s min | %s | \n" (insert
current-category (propertize (format "| %s | %s | %s | %s min | %s | \n"
(timeline-tools-format-entry-time line 'start) current-category
(timeline-tools-format-entry-time line 'end) (timeline-tools-format-entry-time line 'start)
(timeline-tools-entry-duration line) (timeline-tools-format-entry-time line 'end)
(propertize (timeline-tools-entry-headline line) (timeline-tools-entry-duration line) (timeline-tools-entry-headline line))
'marker (timeline-tools-entry-marker line) 'marker (timeline-tools-entry-marker line)
'entry line))))) 'entry line))))
(insert "|--|\n") (insert "|--|\n")
(org-table-align) (org-table-align)
(goto-char (point-min)) (goto-char (point-min))
@ -564,8 +564,8 @@ Interactively query for the exact value of \"short\"."
(unless (eq major-mode 'timeline-tools-mode) (unless (eq major-mode 'timeline-tools-mode)
(user-error "Not in Timeline buffer")) (user-error "Not in Timeline buffer"))
(let ((marker (save-mark-and-excursion (let ((marker (save-mark-and-excursion
(end-of-line) (beginning-of-line)
(org-table-previous-field) (org-table-next-field)
(get-text-property (point) 'marker)))) (get-text-property (point) 'marker))))
(unless marker (unless marker
(user-error "Not on headline to jump to")) (user-error "Not on headline to jump to"))
@ -579,21 +579,19 @@ Interactively query for the exact value of \"short\"."
(unless (eq major-mode 'timeline-tools-mode) (unless (eq major-mode 'timeline-tools-mode)
(user-error "Not in Timeline buffer")) (user-error "Not in Timeline buffer"))
(save-mark-and-excursion (save-mark-and-excursion
;; get actual entry from headline of line ;; get actual entry from headline of line
(beginning-of-line) (beginning-of-line)
(unless (looking-at "^| ") (unless (looking-at "^| ")
(user-error "Not in table")) (user-error "Not in table"))
;; Move 5 columns to find the actual entry (org-table-next-field)
(dotimes (_ 5) (let ((entry (get-text-property (point) 'entry)))
(org-table-next-field)) (unless entry
(let ((entry (get-text-property (point) 'entry))) (user-error "Not on valid row in timeline"))
(unless entry (unless (< 1 (length timeline-tools--current-timeline))
(user-error "Not on valid row in timeline")) (user-error "Cannot delete last line"))
(unless (< 1 (length timeline-tools--current-timeline)) (setq-local timeline-tools--current-timeline
(user-error "Cannot delete last line")) (timeline-tools-transform-timeline
(setq-local timeline-tools--current-timeline (delq entry timeline-tools--current-timeline)))))
(timeline-tools-transform-timeline
(delq entry timeline-tools--current-timeline)))))
;; the call to `erase-buffer in `timeline-tools-redraw-timeline somehow ;; the call to `erase-buffer in `timeline-tools-redraw-timeline somehow
;; makes `save-mark-and-excursion meaningless; thus we save the number of the ;; makes `save-mark-and-excursion meaningless; thus we save the number of the
;; current line by ourselves ;; current line by ourselves