legalnonsense / elgantt

A Gantt Chart (Calendar) for Org Mode
GNU General Public License v3.0
402 stars 17 forks source link

Not seeing entries for the following year #14

Open jussiviinikka opened 4 years ago

jussiviinikka commented 4 years ago

Thanks for the very nice package. There's something I don't quite understand however: are you supposed to be able to see the entries for the following year? At the moment I only see entries up to the end of the year. Also the screenshots in the repository seem to extend only up to December.

There is the variable elgantt-start-date but I don't see anything comparable for end-date. Also, if I do have an org entry for 2021 the UI breaks down, making the package unusable. Not sure how this is related, but when that happens (have 2021 entry -> open elgantt -> see it break down) I get this message:

helm-M-x-execute-command: Symbol’s function definition is void: first.

EDIT: The helm message is due to launching elgantt with helm-M-x-execute-command obviously. When I start elgantt with M-: I get this:

`Debugger entered--Lisp error: (void-function first) first((2020)) elgantt--add-year(2021)

f(compiled-function (date) #<bytecode 0x1feb040f7fd9>)("2021-01-29")

mapc(#f(compiled-function (date) #<bytecode 0x1feb040f7fd9>) ("2021-01-29")) elgantt--insert-entry(( data for the 2021 entry )) mapc(elgantt--insert-entry (... ... ... ... ... ... ... ... ... ... ... ... ... ... ...)) elgantt--iterate() elgantt-mode() elgantt-open() eval((elgantt-open) t) eval-expression((elgantt-open) nil nil 127) funcall-interactively(eval-expression (elgantt-open) nil nil 127) call-interactively(eval-expression nil nil) command-execute(eval-expression) `

I'm using https://github.com/railwaycat/homebrew-emacsmacport/ .

legalnonsense commented 4 years ago

There's no way to control the end date; it should populate all dates found in elgantt-agenda-files and show all years found there. What happens if you open the test.org file, add a new heading at the end of the file with a date in 2021? For me, it displays both 2020 and 2021.

jussiviinikka commented 4 years ago

If I open the file without modifications this is what I see:

image

So the calendar ends in December and its impossible to see beyond that. Maybe this is intentional as there's no entries in 2021 at this point.

When I change "asdf" deadline to DEADLINE: <2021-01-01 Fri> and open elgantt (with helm-M-x-execute-command or M-:) I get this:

image

Emacs prints this:

Debugger entered--Lisp error: (void-function first)
  first((2020))
  elgantt--add-year(2021)
  #f(compiled-function (date) #<bytecode 0x1fe5fdb23e85>)("2021-01-01")
  mapc(#f(compiled-function (date) #<bytecode 0x1fe5fdb23e85>) ("2021-01-01"))
  elgantt--insert-entry((:elgantt-category "asdfasdf" :elgantt-headline "asdf" :elgantt-level 2 :elgantt-file "/Users/jussiviinikka/.emacs.d/straight/repos/elgan..." :elgantt-deadline "2021-01-01" :elgantt-scheduled nil :elgantt-todo nil :elgantt-marker #<marker at 3579 in test.org> :elgantt-timestamp nil :elgantt-timestamp-ia nil :elgantt-timestamp-range nil :elgantt-timestamp-range-ia nil :elgantt-hashtag nil :elgantt-alltags nil :elgantt-folded nil :elgantt-header "asdf" :elgantt-parent "asdf" :elgantt-parent-level 1 :elgantt-org-buffer #<buffer test.org> :elgantt-org-parent ("test" . "4b37aca5-a66e-4917-a904-8dfb1f1c69a5") :elgantt-outline-path (("test" . "4b37aca5-a66e-4917-a904-8dfb1f1c69a5")) :elgantt-date "2021-01-01" :elgantt-date-type deadline :elgantt-org-id "71536120-18eb-440f-a877-da07468e86da" :raw-value "asdf" ...))
  mapc(elgantt--insert-entry (... ... ... ... ... ... ... ... ... ... ... ... ... ... ...))
  elgantt--iterate()
  elgantt-mode()
  elgantt-open()
  eval((elgantt-open) t)
  eval-expression((elgantt-open) nil nil 127)
  funcall-interactively(eval-expression (elgantt-open) nil nil 127)
  call-interactively(eval-expression nil nil)
  command-execute(eval-expression)

I just did a git pull after this to make sure I was running the latest elgantt version. Apparently I am, just something in readme changed:

$ git pull
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 2), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (4/4), done.
From https://github.com/legalnonsense/elgantt
   47b1b2d..4f37eca  master     -> origin/master
Updating 47b1b2d..4f37eca
Fast-forward
 README.org | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

This is my elgantt setup:

(use-package org-ql)
(use-package ts)
(use-package s)
(use-package dash)

(use-package elgantt
  :straight (:host github :repo "legalnonsense/elgantt")
  )

(setq elgantt-user-set-color-priority-counter 0)

(elgantt-create-display-rule draw-scheduled-to-deadline
  :parser ((elgantt-color . ((when-let ((colors (org-entry-get (point) "ELGANTT-COLOR")))
                               (s-split " " colors)))))
  :args (elgantt-scheduled elgantt-color elgantt-org-id)
  :body ((when elgantt-scheduled
           (let ((point1 (point))
                 (point2 (save-excursion
                           (elgantt--goto-date elgantt-scheduled)
                           (point)))
                 (color1 (or (car elgantt-color)
                             "black"))
                 (color2 (or (cadr elgantt-color)
                             "red")))
             (when (/= point1 point2)
               (elgantt--draw-gradient 
                color1
                color2
                (if (< point1 point2) point1 point2) ;; Since cells are not necessarily linked in 
                (if (< point1 point2) point2 point1) ;; chronological order, make sure they are sorted
                nil
                `(priority ,(setq elgantt-user-set-color-priority-counter
                                  (1- elgantt-user-set-color-priority-counter))
                           ;; Decrease the priority so that earlier entries take
                           ;; precedence over later ones (note: it doesn’t matter if the number is negative)
                           :elgantt-user-overlay ,elgantt-org-id)))))))

(elgantt-create-display-rule user-set-color
  :parser ((elgantt-color . ((when-let ((colors (org-entry-get (point) "ELGANTT-COLOR")))
                           (s-split " " colors))))
           (elgantt-linked-to . ((org-entry-get (point) "ELGANTT-LINKED-TO"))))
  :args (elgantt-org-id)
  :body ((when elgantt-linked-to
           (save-excursion
             (when-let ((point1 (point))
                        (point2 (let (date) 
                        ;; Cells can be linked even if they are not 
                        ;; in the same header in the calendar. Therefore, 
                        ;; we have to get the date of the linked cell, and then
                        ;; move to that date in the current header
                                  (save-excursion (elgantt--goto-id elgantt-linked-to)
                                                  (setq date (elgantt-get-date-at-point)))
                                  (elgantt--goto-date date)
                                  (point)))
                        (color1 (car elgantt-color))
                        (color2 (cadr elgantt-color)))
               (when (/= point1 point2)
                 (elgantt--draw-gradient 
                  color1
                  color2
                  (if (< point1 point2) point1 point2) ;; Since cells are not necessarily linked in 
                  (if (< point1 point2) point2 point1) ;; chronological order, make sure they are sorted
                  nil
                  `(priority ,(setq elgantt-user-set-color-priority-counter
                                    (1- elgantt-user-set-color-priority-counter))
                              ;; Decrease the priority so that earlier entries take
                              ;; precedence over later ones
                    :elgantt-user-overlay ,elgantt-org-id))))))))

(elgantt-create-display-rule turn-todo-red
  :args (elgantt-todo) ;; Any argument listed here is available in the body
  :body ((when (string= "TODO" elgantt-todo)
           ;; `elgantt--create-overlay' is generally the easiest way to create an overlay
           (elgantt--create-overlay (point) (1+ (point))
                                '(face (:foreground "red")
                                       priority 99999)))))

(setq elgantt-header-column-offset 40)

(setq elgantt-exclusions my/elgantt-exclusions)
jussiviinikka commented 4 years ago

I found a fix from here https://github.com/emacs-lsp/dap-mode/issues/44 : (require 'cl) before opening elgantt solves the problem, though it does complain Package cl is deprecated. The other suggested command (require 'cl-lib) does not fix the problem.