Search code examples
emacsorg-mode

Open 4 agendas in separate windows (Eisenhower Matrix... book: Seven Habits of Highly Effective People)


How can I open the Emacs Agenda sections in a way that it separates the tasks in categories urgent-important like the Eisenhower Matrix... book: Seven Habits of Highly Effective People.

enter image description here

We want:

  • the tasks with #A priority stays in the 1o quadrant
  • the tasks with #B priority stays in the 2o quadrant
  • the tasks with #C priority stays in the 3o quadrant
  • the tasks with #D priority or without priority stays in the 4o quadrant

with a single keyboard stroke command?


Solution

  • I made it!:

    (add-to-list 'org-agenda-custom-commands
                 '("1" "Eisenhower matrix"
                   ((tags-todo
                     "+PRIORITY=\"A\""
                     ((org-agenda-overriding-header "Urgent and important"))))
                  nil))
    
    (add-to-list 'org-agenda-custom-commands
                 '("2" "Eisenhower matrix"
                   ((tags-todo
                     "+PRIORITY=\"B\""
                     ((org-agenda-overriding-header "Important but not urgent"))))
                  nil))
    
    (add-to-list 'org-agenda-custom-commands
                 '("3" "Eisenhower matrix"
                   ((tags-todo
                     "+PRIORITY=\"C\""
                     ((org-agenda-overriding-header "Urgent but not important"))))
                   nil))
    
    (add-to-list 'org-agenda-custom-commands
                 '("4" "Eisenhower matrix"
                   ((tags-todo
             "+PRIORITY=0-PRIORITY=\"A\"-PRIORITY=\"B\"-PRIORITY=\"C\""
                     ((org-agenda-overriding-header "Neither important nor urgent"))))
                  nil))
    
    (setq org-lowest-priority ?E)
    (setq org-default-priority ?E)
    
    (add-to-list 'org-agenda-custom-commands
                 '("1" "Eisenhower matrix"
                   ((tags-todo
                     "+PRIORITY=\"A\""
                     ((org-agenda-overriding-header "Urgent and important"))))
                  nil))
    
    
    (add-to-list 'org-agenda-custom-commands
                 '("2" "Eisenhower matrix"
                   ((tags-todo
                     "+PRIORITY=\"B\""
                     ((org-agenda-overriding-header "Important but not urgent"))))
                  nil))
    
    
    
    (add-to-list 'org-agenda-custom-commands
                 '("3" "Eisenhower matrix"
                   ((tags-todo
                     "+PRIORITY=\"C\""
                     ((org-agenda-overriding-header "Urgent but not important"))))
                   nil))
    
    
    
    (add-to-list 'org-agenda-custom-commands
                 '("4" "Eisenhower matrix"
                   ((tags-todo
             "+PRIORITY=0-PRIORITY=\"A\"-PRIORITY=\"B\"-PRIORITY=\"C\""
                     ((org-agenda-overriding-header "Neither important nor urgent"))))
                  nil))
    
    
    ;-----------------------------------------------------------
    
    ;(org-toggle-sticky-agenda) ;generate differens agendas buffers in separated windows
    (setq org-agenda-sticky t)  ;generate differens agendas buffers in separated windows
    
    (defun myAgenda1 ()
      (interactive)
      (org-agenda nil "1"))
    
    ;(global-set-key (kbd "C-c C-x C-d") 'myAgenda1) 
    
    
    (defun myAgenda2 ()
      (interactive)
      (org-agenda nil "2"))
    
    ;(global-set-key (kbd "C-c C-x C-l") 'myAgenda2) 
    
    (defun myAgenda3 ()
      (interactive)
      (org-agenda nil "3"))
    
    ;(global-set-key (kbd "C-c C-x C-r") 'myAgenda3) 
    
    
    (defun myAgenda4 ()
      (interactive)
      (org-agenda nil "4"))
    
    ;(global-set-key (kbd "C-c C-x C-p") 'myAgenda4) 
    
    
    (defun split-4-ways ()
      (interactive)
      (delete-other-windows)
      (split-window-right)
      (split-window-below)
      (windmove-right)
      (split-window-below)
      (windmove-left))
    ;(global-set-key (kbd "C-c C-x C-u") 'split-4-ways) 
    
    
    (defun makeAgendas ()
     (interactive)
      (myAgenda1)
      (myAgenda2)
      (myAgenda3)
      (myAgenda4)
      )
    ;(global-set-key (kbd "C-c C-x C-t") 'makeAgendas) 
    
    (defun makeMatrix ()
     (interactive)
     (makeAgendas) ;it opens: *Org Agenda(1)*, *Org Agenda(2)*, *Org Agenda(3)*, *Org Agenda(4)*
     (split-4-ways)  ;make the 4 quadrant windows
     (switch-to-buffer  "*Org Agenda(1)*")  ;put the Agenda(1) in the left, up quadrant
     (windmove-right)
     (switch-to-buffer  "*Org Agenda(2)*")  ;put the Agenda(2) in the right, up quadrant
     (windmove-down)
     (switch-to-buffer  "*Org Agenda(4)*")  ;put the Agenda(3) in the left, down quadrant
     (windmove-left)
     (switch-to-buffer  "*Org Agenda(3)*")  ;put the Agenda(4) in the right, down quadrant
     )
    
    (global-set-key (kbd "<f5>") 'makeMatrix) 
    

    With the org file:

    * TODO [#A] Task 1
    * TODO [#A] Task 2
    * TODO [#B] Task 3
    * TODO [#D] Task 4
    * TODO [#C] Task 5
    * TODO [#A] Task 6
    * TODO [#C] Task 7
    * TODO [#D] Task 8
    * TODO Task 9
    * TODO [#B] Task 10
    * TODO [#B] Task 11 
    * TODO [#C] Task 12
    * TODO Task 13
    

    I get: enter image description here