compat: remove obsolete hacks

This commit is contained in:
Kiana Sheibani 2025-04-03 06:37:37 -04:00
parent cdf9ae55fb
commit 8dc0ec35e1
Signed by: toki
GPG key ID: 6CB106C25E86A9F7

View file

@ -2865,37 +2865,6 @@ There are a few useful functions Doom doesn't bind by default, so let's add them
"v" (lookup-key org-mode-map (kbd "C-c C-v"))) "v" (lookup-key org-mode-map (kbd "C-c C-v")))
#+end_src #+end_src
**** YASnippet
By default, snippet expansion doesn't work in Org mode; when =TAB= is pressed to move to the next placeholder, headline visibility cycling is triggered instead. This is because in ~org-mode-map~ =TAB= is unconditionally bound to ~org-cycle~, and for some reason this has a higher precedence than YAS's keymaps.
While this is a complex problem, the solution is actually rather simple: just remove the ~org-mode-map~ binding. The ~org-cycle~ command will still be triggered on =TAB= when in normal mode, as it is bound in ~evil-org-mode-map~, but when in insert mode (as one generally is during snippet expansion) the binding will fall through both maps and be handled by YASnippet.
#+begin_src emacs-lisp
(map! :after org
:map org-mode-map
"TAB" nil
"<tab>" nil
:i "TAB" nil
:i "<tab>" nil)
#+end_src
This also means we don't need ~org-cycle~ to emulate indentation, which is nice. Unfortunately, this breaks something else: ~org-cycle~ not only handles visibility cycling, but also navigating inside tables. If ~org-cycle~ isn't being called when in insert mode, then we can't use =TAB= to move fields. This means that we need a little extra binding configuration:
#+begin_src emacs-lisp
(let ((item
`(menu-item nil org-table-next-field
:filter ,(lambda (cmd)
(when (org-table-p)
cmd)))))
(map! :after org
:map evil-org-mode-map
:i "TAB" item
:i "<tab>" item))
#+end_src
This makes it so that we only let tab keypresses fall through if we aren't in a table. (We'll just assume that we aren't going to be expanding any snippets while we're in a table.)
*** Project Links *** Project Links
It's sometimes nice to be able to click a link in an Org file that takes me to one of my projects. It's sometimes nice to be able to click a link in an Org file that takes me to one of my projects.