5

In Spacemacs with evil and org-mode, the letter 't' is assigned to two functions:

  • org-todo (don't need this because I use shift-arrow to cycle through todo states)
  • evil-find-char-to (I need this)

When in org-mode, 't' only works for org-todo. How to assign 't' to only evil-find-char-to?

This solution by Bernardo Brik worked for Daniel Yang:

(add-hook 'org-mode-hook ((define-key evil-normal-state-map (kbd "t") 'evil-find-char-to)))

But when I try it:

add-hook: Invalid function: (define-key evil-normal-state-map (kbd "t") (quote evil-find-char-to))

I am using Emacs 25.2.1 with Evil Spacemacs and org-mode on Linux.

2 Answers 2

4

Hooks are functions, so for the above to work you'd need to wrap your code into an anonymous function instead of an extra set of parens:

(add-hook 'org-mode-hook (lambda () (define-key evil-normal-state-map (kbd "t") 'evil-find-char-to)))

I typically use with-eval-after-load for this as it avoids creating the function yourself, provided you know what the feature is your code has to be loaded after:

(with-eval-after-load 'org
  (define-key evil-normal-state-map (kbd "t") 'evil-find-char-to))
5
  • 1
    I copy & paste the code in to my dotspacemacs/user-config () and restarted Spacemacs. But both times code did not changed the 't' behavior; 't' still cycles the heading's todo state.
    – wolfv
    Commented Aug 3, 2017 at 19:57
  • Then you'll have to figure out what code does it and change the hook/feature accordingly. I recommend using grep for this on the Spacemacs sources.
    – wasamasa
    Commented Aug 3, 2017 at 20:29
  • Thanks wasamasa. I am going to come back to this after I learn elisp and how emacs works.
    – wolfv
    Commented Aug 3, 2017 at 21:43
  • @wolfv did you find a solution? Commented Sep 5, 2022 at 7:43
  • No, I have not tried a solution.
    – wolfv
    Commented Sep 6, 2022 at 17:49
1

From the readme of the Org layer at the current tip of the ‘develop’ branch (r#c68fde7bebfb (“Apply conventions to multi-term keybinds”, 2019-04-05)):

If the layer variable =org-want-todo-bindings= is true, the following bindings
are also available.

| Key bindings | Description                         |
|--------------+-------------------------------------|
| ~t~          | Cycle TODO state of current heading |
| ~T~          | Insert new TODO heading             |
| ~M-t~        | Insert new TODO sub-heading         |

I infer from this that t will not be bound to org-todo if org-want-todo-bindings is set to nil. That is the default according to the config.el for that layer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.