elgantt icon indicating copy to clipboard operation
elgantt copied to clipboard

Void function `first` in elgantt--draw-overarching-headers` and `elgantt--add-year`

Open pabloaperezfernandez opened this issue 3 years ago • 0 comments

I got the code to work, but I had to replace function first with car in various places since I kept getting errors about first being void. Alas, I could not find it defined anywhere. Maybe, it is part of the one of the dependencies, but I could not find it defined anywhere. Found the problem in the following two functions. In both, I commented the original line with ;; and added my modification below it.

(defun elgantt--add-year (year)
  "Check to see if YEAR has already been displayed in the calendar.
If so, do nothing. If not, insert that year for all calendar lines
and all header lines in the calendar, and push the year onto 
`elgantt--date-range' so that any new entries will contain the 
proper number of years."
  (when (not (memq year elgantt--date-range))
    (cond ((not elgantt--date-range)
	   (cl-pushnew year elgantt--date-range)
	   (elgantt--insert-year year))
;;	  ((< year (first elgantt--date-range))
	  ((< year (car elgantt--date-range))	   
;;	   (let ((dif (- (first elgantt--date-range) year)))
	   (let ((dif (- (car elgantt--date-range) year)))
;;	     (setq year (first elgantt--date-range))
	     (setq year (car elgantt--date-range))
	     (dotimes (_ dif)
	       (setq year (1- year))
	       (cl-pushnew year elgantt--date-range)
	       (elgantt--insert-year year))))
	  ((> year (car (last elgantt--date-range)))
	   (let ((dif (- year (car (last elgantt--date-range)))))
	     (setq year (car (last elgantt--date-range)))
	     (dotimes (_ dif)
	       (setq year (1+ year))
	       (cl-pushnew year elgantt--date-range)
	       (elgantt--insert-year year t)))))
    (setq elgantt--date-range (sort elgantt--date-range #'<))))

and

(defun elgantt--draw-overarching-headers ()
  "If the current line has no dates, draw a bracket starting at the earliest
date and continuing until the latest date."
  (elgantt--scroll-to-beginning)
  (let ((inhibit-read-only t))
    (save-excursion 
      (goto-char (point-min))
      (forward-line 1)
      (cl-loop until (progn (save-excursion (end-of-line)
					    (eobp)))
	       do (forward-line 1)
	       if (elgantt--blank-header-line-p)
	       do (let ((first-date nil)
			(last-date nil)
			(point (point))
			(current-level (elgantt--get-level-at-point)))
		    (save-excursion
		      (forward-line 1)
		      ;; HACK
		      (cl-loop until (or (elgantt--empty-line-p)
					 (<= (elgantt--get-level-at-point)
					     current-level)
					 (eobp))
			       do (progn
				    (save-excursion
				      (goto-char (point-at-bol))
				      (while (re-search-forward elgantt-cell-entry-re (point-at-eol) t)
					(forward-char -1)
					(setq first-date
;;					      (first
					      (car
					       (elgantt--sort-dates
						(-flatten (list first-date
								(elgantt-get-prop-at-point :elgantt-scheduled)
								(elgantt-get-date-at-point))))))
					(forward-char 1)))
				    (save-excursion
				      (goto-char (point-at-eol))
				      (while (re-search-backward elgantt-cell-entry-re (point-at-bol) t)
					(setq last-date
					      (car
					       (last
						(elgantt--sort-dates
						 (-flatten (list last-date
								 (elgantt-get-prop-at-point :elgantt-scheduled)
								 (elgantt-get-date-at-point)))))))))
				    (forward-line 1))
			       finally (when (and first-date
						  last-date
						  (not (string= first-date last-date)))
					 (goto-char point)
					 (cl-loop with end = (1- (elgantt--goto-date last-date))
						  with start = (elgantt--goto-date first-date)
						  for x from start to end
						  if (= x start)
						  do (progn (when (not (looking-at "|"))
							      (elgantt--change-char elgantt-draw--top-left))
							    (forward-char 1))
						  else do (progn (when (not (looking-at "|"))
								   (elgantt--change-char elgantt-draw--horizontal-line))
								 (forward-char 1))
						  finally (elgantt--change-char  elgantt-draw--top-right))))))))))

pabloaperezfernandez avatar Aug 15 '21 15:08 pabloaperezfernandez