alphapapa/org-super-agenda

Some keybindings not working at heading

yiufung opened this issue ยท 17 comments

First of all, thanks for coming up with this gorgeous package! Has
helped me a lot in organizing my daily priorities and tracking tasks,
I love using it.

In org-agenda, I normally move around using n, p, which invokes
org-agenda-next-line etc. Somehow, when I place my cursor on
headings of org-super-agenda groups, e.g, the Schedule below:

Day-agenda (W37):
Tuesday    11 September 2018

 |Schedule
               8:00...... ----------------
              10:00...... ----------------

then the keybindings for n and p becomes self-insert-command
instead, and echo area shows "Buffer is read-only: #<buffer *Org Agenda(a)*>. In the describe-mode, I can see it's still Org-Agenda Day Ddl mode. I can also see that n, C-n and <down> are mapped
to org-agenda-next-line, and the other two keybindings still work.

Not sure if it happens to others?

M-x emacs-info: GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30) of 2018-08-30

    ;; org-super-agenda
    (setq org-super-agenda-groups
          '((:log t)
            (:name "Schedule"
                   :time-grid t)
            (:name "Today"
                   :scheduled today)

            (:name "Due today"
                   :deadline today)
            (:name "Overdue"
                   :deadline past)
            (:name "Due soon"
                   :deadline future)

            (:habit t)
            (:name "Unimportant"
                   :todo ("SOMEDAY" "MAYBE" "CHECK" "TO-READ" "TO-WATCH")
                   :order 100)
            (:name "Waiting..."
                   :todo "WAITING"
                   :order 98)
            (:name "Scheduled earlier"
                   :scheduled past)))
    (org-super-agenda-mode)

    (setq org-agenda-sticky t)

Hmm, it seems that all keybindings under org-agenda-mode-map are shadowed. For example, w for org-agenda-week-view, x for org-agenda-exit, o for delete-other-windows etc.

Hi,

Thanks for reporting this. I changed the header map to copy org-agenda-mode-map, which should fix it.

Runs like butter! Thanks.

Sure, will check it out. Thanks for contributing so many wonderful packages!

Thanks for this useful package!

But it seems this fix breaks my evil normal mode keybindings for org-super-agenda-map.

I've binded j/k to org-agenda-next-line before, but after this fix, pressing j under a header becomes org-agenda-goto-date

Here is my keybinding for org-agenda-mode-map with general.el:

(nmap
   :keymaps '(org-agenda-keymap)
   "<tab>" #'org-agenda-switch-to
   "<return>" #'org-agenda-switch-to
   "i" #'org-agenda-clock-in
   "s" #'org-agenda-schedule
   "d" #'org-agenda-deadline
   "t" #'org-agenda-todo
   "j" #'org-agenda-next-line
   "k" #'org-agenda-previous-line
   "L" #'org-agenda-log-mode
   "q" #'org-agenda-quit
   "f" #'org-agenda-later
   "b" #'org-agenda-earlier
   "gr" #'org-agenda-redo
   "R" #'org-agenda-clockreport-mode
   "gj" #'org-agenda-next-line
   "gk" #'org-agenda-previous-line)

Hi Yiming,

Sorry, I don't quite understand. There is no org-super-agenda-map. I see you're modifying org-agenda-keymap, which is an obsolete alias for org-agenda-mode-map, but this fix doesn't modify that map, so this fix shouldn't have affected anything in your code.

Sorry, my mistake. It's org-super-agenda-header-map.

It doesn't affect org-agenda-mode-map, but the keybinding behavior over my org-super-agenda header does changed to the default org-agenda-mode-map due to this fix.

From the doc for copy-keymap:

After performing copy-keymap, the copy starts out with the same definitions
of KEYMAP, but changing either the copy or KEYMAP does not affect the other.
Any key definitions that are subkeymaps are recursively copied.
However, a key definition which is a symbol whose definition is a keymap
is not copied.

I thought it was because my nmap call was after the copy-keymap call. But when I checked the copied org-super-agenda-header-map, it was the same as my org-agenda-mode-map.

@dsdshcym I'm a bit confused now. As you said, your mapping made after the copy-keymap call should override the copied keymap. If this is not the case, it's probably a configuration problem. But if you think there is still a bug overriding your keymap, feel free to open a new bug report.

Unfortunately, I still have this problem with evil-org. I get some unexpected (default?) keybindings when point is on some heading. Seems to work fine on non-headings.

As a workaround I've disabled org-super-agenda-header-map:

(setq org-super-agenda-header-map (make-sparse-keymap))

@wedens I don't use evil-org, so I can't help there, at least not without more specific information. If you can find some specific conflicts in the keymaps, maybe they can be fixed here or in evil-org. For example, you could try describe-text-properties or describe-char to investigate the properties of text in headers.

I think it's not uncommon for EVIL keybindings to conflict with ones in other packages. Maybe it should be filed as a separate bug.

I see this issue as well.

Should I create a new issue for it?

I've attempted to take the relevant pieces from describe-text-properties output and pasted it below:

(keymap
 (75 . org-habit-toggle-display-in-agenda)
 (motion-state keymap "Auxiliary keymap for Motion state"
	       (76 . org-agenda-log-mode)
	       (68 . org-agenda-day-view))
 (override-state keymap "Auxiliary keymap for override state"
		 (76 . org-agenda-log-mode)
		 (68 . org-agenda-day-view))
 (normal-state keymap "Auxiliary keymap for Normal state"
	       ... snip ...
	       (118 keymap
		    (99 . org-agenda-show-clocking-issues)
		    (100 . org-agenda-day-view)
		    (108 . org-agenda-log-mode)
		    (119 . org-agenda-week-view)
		    (97 . org-agenda-archives-mode)
		    (116 . org-agenda-toggle-time-grid))
	       (107 . org-agenda-previous-line)
	       (106 . org-agenda-next-line)
	       ... snip ..
	       (83 . org-save-all-org-buffers)
	       (103 keymap
		    (92 . org-agenda-filter-by-tag-refine)
		    (118 . org-agenda-view-mode-dispatch)
		    (104 . org-agenda-holiday)
		    (47 . org-agenda-filter-by-tag)
		    (111 . org-agenda-open-link)
		    (74 . org-agenda-clock-goto)
		    (106 . org-agenda-goto-date)
		    (114 . org-agenda-refile))
	       (114 . org-agenda-redo)
	       (36 . org-agenda-archive)
	       (113 . org-agenda-quit)
	       (13 . org-agenda-switch-to)
	       (76 . org-agenda-recenter)
	       (68 . org-agenda-day-view))
 ... snip ...
 (106 . org-agenda-goto-date)
 ... snip ... 
 (24 keymap
     (19 . org-save-all-org-buffers)
     (23 . org-agenda-write)
     (117 . org-agenda-undo)))

I can't provide support for evil-org or other evil packages. Maybe you could use evil-collection.

As dsdshcym mentioned, I think this change introduced a new error for those using evil mode (doom emacs, etc) where the key map reverts to the standard org-agenda map when focused on a header generated by org-super-agenda. I was able to fix this for myself by adding the following to my config:

(setq org-super-agenda-header-map evil-org-agenda-mode-map)

Note that I'm running Doom Emacs version 2.0.9, so you may need to tweak this a bit if your environment is different.

Unfortunately, I still have this problem with evil-org. I get some unexpected (default?) keybindings when point is on some heading. Seems to work fine on non-headings.

As a workaround I've disabled org-super-agenda-header-map:

(setq org-super-agenda-header-map (make-sparse-keymap))

This also fixed my issue with org-super-agenda on Doom Emacs 2.0.9

Same problem here, running vanilla emacs on linux with evil.
As mentioned above this following fixes the problem:

(setq org-super-agenda-header-map (make-sparse-keymap))

Thanks