org-super-agenda icon indicating copy to clipboard operation
org-super-agenda copied to clipboard

Origami example binds Tab incorrectly

Open garrison opened this issue 6 years ago • 11 comments

Hi there,

I've tried integrating with origami as described in 3b5e8faeec1333aca3cafbbaa350dacc95412086, but use-package does not like the :general symbol in its given position. Actually, it does not seem that use-package knows anything about either :general or :keymaps (I've grepped the source). I've also tried putting (define-key org-super-agenda-header-map (kbd "TAB") #'origami-toggle-node) in the :config section with no luck. Do you have any other ideas for getting the TAB keybinding to work? Running M-x origami-toggle-node on a header works, so the only issue is getting the keybinding to work reliably.

garrison avatar Oct 11 '18 02:10 garrison

You need to install the general package to use the :general keyword.

alphapapa avatar Oct 12 '18 07:10 alphapapa

Thanks! That's helpful. Action item # 1, then, will be documenting this in that example. I am still having difficulty getting the example to work (i.e., TAB still results in "Command not allowed on this line"), but will try to get debug this soon and will let you know what I figure out.

garrison avatar Oct 12 '18 07:10 garrison

I am still having difficulty getting the example to work (i.e., TAB still results in "Command not allowed on this line"), but will try to get debug this soon and will let you know what I figure out.

Be sure that the point is on the header line. If it is and still doesn't work, use describe-text-properties and see if the keymap is set to org-super-agenda-header-map. If it is, check org-super-agenda-header-map and see if TAB is bound to the command. If it is and still doesn't work, I don't know what the problem would be.

alphapapa avatar Oct 12 '18 13:10 alphapapa

I had to change "TAB" to "<tab>" to get it to work. This is on emacs 26.1. Before it was bound to key 9, whatever that is. Now it is bound to "tab".

garrison avatar Oct 12 '18 22:10 garrison

Guess you'd better refer to the Emacs manual for how to specify key bindings. :)

alphapapa avatar Oct 13 '18 18:10 alphapapa

Guess you'd better refer to the Emacs manual for how to specify key bindings. :)

I'm afraid I don't understand. I copy and pasted an example from examples.org, and it did not work without modification. Should this not be fixed? And 9 == 011, which is supposed to be tab, so I am doubly confused why it did not work.

In any case, I believe it should be documented that the general package is required, as this is not mentioned in examples.org or in the Emacs manual.

garrison avatar Oct 14 '18 00:10 garrison

And 9 == 011, which is supposed to be tab, so I am doubly confused why it did not work.

Well, there are at least three different ways to bind the Tab key, I think:

[tab]
"\t"
(kbd "<tab>")

See, e.g. https://www.gnu.org/software/emacs/manual/html_node/elisp/Key-Sequences.html.

I'm afraid I don't understand. I copy and pasted an example from examples.org, and it did not work without modification. In any case, I believe it should be documented that the general package is required, as this is not mentioned in examples.org or in the Emacs manual.

Ah, yes, I put TAB in the example when it should have been one of those other ways. Thanks. And I think I'll just remove general from the example.

alphapapa avatar Oct 14 '18 21:10 alphapapa

This is what worked for me:

(require 'use-package)
(require 'general)
(use-package origami
   :general (:keymaps 'org-super-agenda-header-map
                      "<tab>" #'origami-toggle-node)
   :config
   
   :hook ((org-agenda-mode . origami-mode)
	  ))

Just include this in your .emacs file.

baracunatana avatar Mar 26 '19 14:03 baracunatana

thanks, I got stuck on this same problem, and this helped me!

jave avatar Nov 23 '20 21:11 jave

Hi! for the ones using Doom Emacs, this worked for me:

(after! org-agenda
     (map!
       :map org-super-agenda-header-map
       :g [tab] #'origami-toggle-node))

This way you can avoid Doom from overriding the keybinding with its default. I was having the same problem than the OP You should include it in the config.el file

vicrdguez avatar Jan 13 '21 16:01 vicrdguez

I got it working with this snippet:

(use-package org-super-agenda
  :config
  (use-package origami
    :bind (:map org-super-agenda-header-map
		("<tab>" . origami-toggle-node))
    :hook ((org-agenda-mode . origami-mode))))

I was confused by :general (this hint makes sense), looked into use-package's documentation and substituted with :bind and :map. However, it seems folding does not work for all headlines now and I assume my substitutions are the reason (or my customised super-agenda setup). Calling origami-toggle-node manually works for e.g. super agenda's section titles.

Thanks @garrison with your comment on using <tab> further up!

funnyflowerpot avatar Apr 21 '21 08:04 funnyflowerpot