alphapapa / org-super-agenda

Supercharge your Org daily/weekly agenda by grouping items
GNU General Public License v3.0
1.37k stars 108 forks source link

Org-Super-Agenda interfering with emacs windows set-up #115

Closed oldenough closed 5 years ago

oldenough commented 5 years ago

I am using Emacs 26.3 and org-super-agenda 20190925.958, although the problem applies to older versions of each. I am running Windows 10.

I wanted to open emacs full screen with two windows, showing my todo.org on the left and my Agenda on the right. The following code in the init file accomplishes that.

(add-to-list 'default-frame-alist '(fullscreen . maximized))
(setq initial-buffer-choice "~/Org/todo.org")

(defun my-init-hook ()
  (split-window-right)
  (let ((org-agenda-window-setup 'other-window))
    (org-agenda nil "a")))

(add-hook 'window-setup-hook #'my-init-hook)

If I only add: (use-package org-super-agenda :config (org-super-agenda-mode)) to the init file the windows definition code continues to work correctly.

However, once I add in the code for the custom commands and formatting which I will include at the bottom of this, the windows definition code breaks and I wind up with the super-agenda view at the top, reaching across the entire Emacs window, and with two windows below that, divided vertically. Both of those windows show the todo.org file.

I set up the super-agenda formatting several years ago, and most of it is from the documentation examples although I'm not great at writing the stuff myself and wouldn't be surprised if I have added errors or non-functional items.

The question is what, in either super-agenda, or the formatting of it included in my init file, is breaking the setting up of the emacs windows and opening views, and is there anything that I can do about it?


Formatting code from init file. I have x'ed out some names and tags that contain personal information.

;; Start of Agenda Configurations
(use-package org-super-agenda :config (org-super-agenda-mode))

(let ((org-super-agenda-groups
       '((:auto-category t))))
  (org-agenda-list))
(setq org-agenda-custom-commands
      (quote (
;; A menu option to show all TODO's that aren't scheduled
        ("x" "Unscheduled TODO"
            ((todo ""
                    ((org-agenda-todo-ignore-scheduled "Unscheduled TODO")
                    )))
            nil
            nil)
;; Super Agenda formatting
        ("u" "SUPER Agenda"
                org-agenda-list ""
                ((org-agenda-span 'day)
                (org-agenda-prefix-format "*  %t") ; This turns on showing times in the time-grid
                 (org-super-agenda-groups
                  '((:name "Today's MIT"  ; Optionally specify section name
        :priority "A")
     (:name "Scheduled"
        :time-grid t )  ; Items that appear on the time grid
     (:name "xxx1"
        :tag "xxx1")
     (:name "xxx2"
        :tag "IFC")
     (:name "xxx3"
        :tag "xxx3a" :tag "xxx3b")
     (:name "Errands"
        :tag "Errand" :tag "errand" :tag "errands" :tag "Errands")
     (:name "Daily Grind"
        :tag "Habit" :tag "habit")
     (:todo "WAITING" :order 8)  ; Set order of this section
         (:todo ("SOMEDAY" "TO-READ" "CHECK" "TO-WATCH" "WATCHING")
                ;; Show this group at the end of the agenda (since it has the
                ;; highest number). If you specified this group last, items
                ;; with these todo keywords that e.g. have priority A would be
                ;; displayed in that group instead, because items are grouped
                ;; out in the order the groups are listed.
                :order 9)
         (:priority<= "B"
                      ;; Show this section after "Today" and "Important", because
                      ;; their order is unspecified, defaulting to 0. Sections
                      ;; are displayed lowest-number-first.
                      :order 1)
         ;; After the last group, the agenda will display items that didn't
         ;; match any of these groups, with the default order position of 99
         ))))
            ("N" "Notes" tags "NOTE"
               ((org-agenda-overriding-header "Notes")
                (org-tags-match-list-sublevels t)))
            ("h" "Habits" tags-todo "STYLE=\"habit\""
               ((org-agenda-overriding-header "Habits")
                (org-agenda-sorting-strategy
                 '(todo-state-down effort-up category-keep))))
            (" " "Agenda"
               ((agenda "" nil)
                (tags-todo "-INACTIVE/!")
                (tags "REFILE"
                      ((org-agenda-overriding-header "Tasks to Refile")
                       (org-tags-match-list-sublevels nil)))
                (tags-todo "-CANCELLED/!"
                           ((org-agenda-overriding-header "Stuck Projects")
                            (org-agenda-skip-function 'bh/skip-non-stuck-projects)
                            (org-agenda-sorting-strategy
                             '(category-keep))))
                (tags-todo "-HOLD-CANCELLED/!"
                           ((org-agenda-overriding-header "Projects")
                            (org-agenda-skip-function 'bh/skip-non-projects)
                            (org-tags-match-list-sublevels 'indented)
                            (org-agenda-sorting-strategy
                             '(category-keep))))
                (tags-todo "-CANCELLED/!NEXT"
                           ((org-agenda-overriding-header (concat "Project Next Tasks"
                                (if bh/hide-scheduled-and-waiting-next-tasks
                                    ""
                                    " (including WAITING and SCHEDULED tasks)")))
                            (org-agenda-skip-function 'bh/skip-projects-and-habits-and-single-tasks)
                            (org-tags-match-list-sublevels t)
                            (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
                            (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
                            (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
                            (org-agenda-sorting-strategy
                             '(todo-state-down effort-up category-keep))))
                (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
                           ((org-agenda-overriding-header (concat "Project Subtasks"
                                (if bh/hide-scheduled-and-waiting-next-tasks
                                    ""
                                    " (including WAITING and SCHEDULED tasks)")))
                            (org-agenda-skip-function 'bh/skip-non-project-tasks)
                            (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
                            (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
                            (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
                            (org-agenda-sorting-strategy
                             '(category-keep))))
                (tags-todo "-REFILE-CANCELLED-WAITING-HOLD/!"
                           ((org-agenda-overriding-header (concat "Standalone Tasks"
                                (if bh/hide-scheduled-and-waiting-next-tasks
                                    ""
                                    " (including WAITING and SCHEDULED tasks)")))
                            (org-agenda-skip-function 'bh/skip-project-tasks)
                            (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
                            (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)
                            (org-agenda-todo-ignore-with-date bh/hide-scheduled-and-waiting-next-tasks)
                            (org-agenda-sorting-strategy
                             '(category-keep))))
                (tags-todo "-CANCELLED+WAITING|HOLD/!"
                           ((org-agenda-overriding-header (concat "Waiting and Postponed Tasks"
                                (if bh/hide-scheduled-and-waiting-next-tasks
                                    ""
                                    " (including WAITING and SCHEDULED tasks)")))
                            (org-agenda-skip-function 'bh/skip-non-tasks)
                            (org-tags-match-list-sublevels nil)
                            (org-agenda-todo-ignore-scheduled bh/hide-scheduled-and-waiting-next-tasks)
                            (org-agenda-todo-ignore-deadlines bh/hide-scheduled-and-waiting-next-tasks)))
                (tags "-REFILE/"
                      ((org-agenda-overriding-header "Tasks to Archive")
                       (org-agenda-skip-function 'bh/skip-non-archivable-tasks)
                       (org-tags-match-list-sublevels nil))))
               nil))))
alphapapa commented 5 years ago

It's impossible for org-super-agenda to cause this issue, because all it does is filter the result of org-agenda-finalize-entries.

That is a lot of code to debug. Since it's not an issue with this package, please post it to somewhere like reddit.com/r/emacs or reddit.com/r/orgmode or the org-mode mailing list for help.

oldenough commented 5 years ago

A day's worth of testing later, in a very limited init file the following line is where the windows set-up breaks.

(let ((org-super-agenda-groups
       '((:auto-category t))))
  (org-agenda-list))

And removing that line from a very large init file and everything is fine. I'm not even sure that that line is necessary and may just be a historic artifact, but it will take more testing to be sure that I haven't lost something with that line removed.

alphapapa commented 5 years ago

Then this line alone would cause it:

(org-agenda-list)

That function causes the agenda to be displayed. So every time you start Emacs, you're displaying the agenda somewhere, which is creating an agenda buffer, which probably alters the behavior of subsequent agenda invocations. It's nothing to do with org-super-agenda.

Note this note from the readme:

Note: In order for groups to be automatically, persistently applied to all agenda buffers, the variable org-super-agenda-groups must be set in the global scope (e.g. with setq in your init file, or using the customization interface). Alternatively, it can be let-bound in lisp code that calls org-agenda commands, but in that case, the setting will not persist across agenda commands (so after refreshing an agenda buffer by pressing g, there will be no groups).

It appears that you copied the example let form into your config, which is only intended as an example for testing this package's behavior, rather than setting the org-super-agenda-groups variable with setq. This is a common mistake by users who aren't as familiar with Lisp, which I've had to answer here many times, and I don't know how to solve it. Emacs and Org sometimes require some minimal Lisp knowledge to configure properly.

oldenough commented 5 years ago

Since the problematic code appears right at the top of my org-super-agenda customization it was possibly part of some of my first experiments with the package (maybe 4 years ago?), which is the most important org package I use. That's why I think it's existence here is probably a historical artifact in my init file. I do use setq and org-super-agenda-groups clumsily but correctly a bit further down. The only time I do use Lisp is when I have to work on my init file, but I have been using org-mode for such a long time, I have learned to understand it a bit.