[agenda] Improve day view

master
Jacopo De Simoi 3 months ago
parent 4872b7ada0
commit 760ec5d2c9
  1. 132
      global.org

@ -1436,6 +1436,13 @@
#+begin_src emacs-lisp
(setq org-use-speed-commands t)
#+end_src
#+begin_src emacs-lisp
(setq org-agenda-sorting-strategy
'((agenda habit-down deadline-up time-up scheduled-up priority-down category-keep)
(todo priority-down category-keep)
(tags priority-down category-keep)
(search category-keep)))
#+end_src
Customize the agenda interface a bit
- add a newline before habits
#+begin_src emacs-lisp
@ -1483,18 +1490,26 @@
(setq list (org-agenda-limit-entries list 'org-hd-marker max-entries)))
(when (and org-agenda-dim-blocked-tasks org-blocker-hook)
(setq list (mapcar #'org-agenda--mark-blocked-entry list)))
; this bit adds a blank line before the first habit
; the bit below adds a blank line before the first habit
(setq list
(wilder/insert-before-first #'(lambda (string)
(get-text-property 0 'org-habit-p string))
"" list))
; the bit below adds a blank line before the first scheduled item
(setq list
(wilder/insert-before-first #'(lambda (string)
(string= "scheduled" (get-text-property 0 'type string)))
"" list))
(mapconcat #'identity list "\n")))
#+end_src
- Sleeker time-grid
#+begin_src emacs-lisp
(setq org-agenda-time-grid '((daily today require-timed remove-match)
(setq org-agenda-sort-notime-is-late nil)
#+end_src
#+begin_src emacs-lisp
(setq org-agenda-time-grid '((daily today remove-match)
(800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000)
" ······· " "───────────────")
org-agenda-current-time-string "····· now ·····"
@ -1519,28 +1534,55 @@
(defun figlet-digit (digit row)
(aref (aref figlet-lean row) digit))
(defun figlet-num (number row)
(defun figlet-num (number row &optional padding)
(let ((n number)
(padding (or padding 0))
(d (list)))
(while (> n 0)
(setq d (append (list (mod n 10)) d))
(setq n (/ n 10)))
(while (or (> padding 0) (> n 0))
(setq padding (- padding 1)
d (append (list (mod n 10)) d)
n (/ n 10)))
(string-join (mapcar
(lambda (digit) (concat (figlet-digit digit row) " "))
d))))
(lambda (digit) (concat (figlet-digit digit row)))
d) " ")))
(defun org-agenda-format-date-aligned (date)
"Format a DATE string for display in the daily/weekly agenda.
This function makes sure that dates are aligned for easy reading."
(require 'cal-iso)
(let* ((dayname (calendar-day-name date))
(day (cadr date))
(day-of-week (calendar-day-of-week date))
(month (car date))
(monthname (calendar-month-name month))
(year (nth 2 date))
(iso-week (org-days-to-iso-week
(calendar-absolute-from-gregorian date)))
;; (weekyear (cond ((and (= month 1) (>= iso-week 52))
;; (1- year))
;; ((and (= month 12) (<= iso-week 1))
;; (1+ year))
;; (t year)))
(weekstring (format " W%02d" iso-week)
))
(format "%s%s - %4d·%02d·%02d"
dayname weekstring year month day)))
(defun org-agenda-format-date-figlet (date)
"Format a DATE string for display in the daily/weekly agenda.
This function makes sure that dates are aligned for easy reading."
;(require 'cal-iso)
This function makes sure that dates are aligned for easy reading."
(if (not (eq 'day org-agenda-current-span))
(concat "\n" (org-agenda-format-date-aligned date)
" ────────────────────────────────────────────────────\n")
(let ((date-string (org-agenda-format-date-aligned date)))
(concat "\n" date-string " "
(make-string (- (window-body-width) 1 (length date-string)) ?─
"\n")))
(let* ((dayname (calendar-day-name date))
(day (cadr date))
(day-of-week (calendar-day-of-week date))
(month (car date))
(monthname (calendar-month-name month))
(year (nth 2 date))nf
(year (nth 2 date))
(iso-week (org-days-to-iso-week
(calendar-absolute-from-gregorian date)))
(weekyear (cond ((and (= month 1) (>= iso-week 52))
@ -1548,21 +1590,51 @@
((and (= month 12) (<= iso-week 1))
(1+ year))
(t year)))
(weekstring (if (= day-of-week 1)
(format " W%02d" iso-week)
"")))
(format (concat "\n"
"%9s %s %4d%s\n"
"%9s \n"
"%9s %-10s\n"
"%9s \n"
"%9s %s\n")
(figlet-num day 0) monthname year weekstring
(figlet-num day 1)
(figlet-num day 2) dayname
(figlet-num day 3)
(figlet-num day 4) (sunrise-sunset)))))
(weekstring (format " W%02d" iso-week)))
;; (format (concat "\n"
;; "%9s %s %4d%s\n"
;; "%9s \n"
;; "%9s %-10s\n"
;; "%9s \n"
;; "%9s %s\n")
;; (figlet-num day 0) monthname year weekstring
;; (figlet-num day 1)
;; (figlet-num day 2) dayname
;; (figlet-num day 3)
;; (figlet-num day 4) (sunrise-sunset))
(let ((solar-info (solar-sunrise-sunset-string-list (calendar-current-date))))
(concat
(left-right-align "" (format "%18s %9s %7s" (figlet-num year 0) (figlet-num month 0 2) (figlet-num day 0 2)))
(left-right-align (format "%s%s" dayname weekstring) (format "%18s %9s %8s" (figlet-num year 1) (figlet-num month 1 2) (figlet-num day 1 2)))
(left-right-align (car solar-info) (format "%18s·%9s·%8s" (figlet-num year 2) (figlet-num month 2 2) (figlet-num day 2 2)))
(left-right-align (cadr solar-info) (format "%18s %9s %8s" (figlet-num year 3) (figlet-num month 3 2) (figlet-num day 3 2)))
(left-right-align (caddr solar-info) (format "%18s %9s %8s" (figlet-num year 4) (figlet-num month 4 2) (figlet-num day 4 2)))
)))))
(require 'solar)
(defun solar-sunrise-sunset-string-list (date &optional nolocation)
"String of *local* times of sunrise, sunset, and daylight on Gregorian DATE.
Optional NOLOCATION non-nil means do not print the location."
(let ((l (solar-sunrise-sunset date)))
(list
(if (car l)
(concat "Sunrise " (apply #'solar-time-string (car l)))
"No sunrise")
(if (cadr l)
(concat "Sunset " (apply #'solar-time-string (cadr l)))
"no sunset")
(format "%s hours daylight"
(nth 2 l)))))
(solar-sunrise-sunset-string-list (calendar-current-date))
(defun left-right-align (s1 s2)
(concat s1 (make-string (- (window-body-width) (length s1) (length s2)) ?\ ) s2 "\n"))
(setq calendar-time-display-form
'(24-hours ":" minutes
(if time-zone " (") time-zone (if time-zone ")")))
(setq org-agenda-format-date #'org-agenda-format-date-figlet)
(setq org-agenda-prefix-format
@ -1576,7 +1648,7 @@
"Only show habits on day wiew, not on week view"
(let ((org-habit-show-habits
(with-current-buffer org-agenda-buffer (eq org-agenda-current-span 'day))))
(apply orig-fun args))))
(apply orig-fun args))))
#+end_src
- Add a whiteline after the header Now, this is a horrible hack:
the string that forms the header is obtained by constructing

Loading…
Cancel
Save