C-k
is bound to org-kill-line
by default (try with emacs -Q
), not to org-backward-heading-same-level
(which is bound to C-c C-b
by default).
One possibility is that somewhere in your init file, you rebind C-k
to org-backward-heading-same-level
but that has nothing to do with loading org
, so the eval-after-load
may trigger early, but you rebind it afterwards. You should check your init file(s) for such a setting and just expunge it.
[Feel free to stop reading here and try to fix your problem. Afterwards and if you are curious, read the following, although I don't think it has anything to do with your immediate problem; but it may be useful in various obscure situations in the future.]
There is an additional wrinkle with C-k
in particular however, that might be worth knowing (although it's firmly in the advanced category). C-k
is normally bound to kill-line
in most modes. Org mode redefines it but not by setting C-k
in the keymap, but by remapping the kill-line
command to org-kill-line
- see org-keys.el:
(org-remap org-mode-map
'self-insert-command 'org-self-insert-command
'delete-char 'org-delete-char
'delete-backward-char 'org-delete-backward-char
'kill-line 'org-kill-line
...
You can undefine such remappings, but you have to use something like the following:
(define-key org-mode-map [remap kill-line] nil)
although you should think through the implications.
And even after you do this, C-k
is still bound in the global map to kill-line
, so if you really want to make it do nothing, you will need to undefine it there as well. That is something I would NOT recommend however.
As I mentioned above, this is probably NOT the problem you are having; it is something to keep in the back of your mind for future reference. The moral of the story is that keymap handling can be a complicated subject in Emacs.
emacs -Q
, you are correct the command is different. However, I have no place where i assign this function to a key. Looking deeper,C-h k
says the following:It is bound to C-c C-b, C-k, g k, <normal-state> C-k, <normal-state> g k, <menu-bar> <org> <Navigate Headings> <Previous Same Level>.
– Vinn Mar 31 '23 at 18:12org-mode-map
, i can see its only assigned to one key. – Vinn Mar 31 '23 at 18:13emacs -Q
does not show the bindings, then your init file(s) (or maybe the init files that the distro adds - what exactly are you running both in terms of Emacs and in terms of an OS?) are the culprit: there is no other way for the keybindings to happen. So bisect it (them) to figure out what's doing this. See How do I troubleshoot Emacs problems? for some methods. – NickD Mar 31 '23 at 19:42C-h w org-backward-heading-same-level
gives me two bindings:C-c C-b
and the menu binding<menu-bar> <org> <Navigate Headings> <Previous Same Level>
. I found https://lists.gnu.org/archive/html/emacs-orgmode/2017-04/msg00082.html wheregk
is an Evil keybinding that's added. NoC-k
though. – NickD Mar 31 '23 at 20:10