Open rpglover64 opened 9 years ago
@rpglover64 C-c C-c
in normal mode can repair the table alignment, right ?
Using the advice feature , something like this should re-align the table after you've deleted a character in it with x
:
(advice-add 'evil-delete-char
:after '(lambda (beg end type register)
(interactive)
(org-ctrl-c-ctrl-c)
))
@rpglover64 bump ^^ , would this fit your use-case ?
It seems like the wrong way to accomplish it, but it also seems like it would work. I worry, though, how it would act when you switch out of org-mode.
@rpglover64 yeah, you're right, this should only work while in org-mode.
how about this ?
(require 'advice)
(advice-add 'evil-delete-char
:after '(lambda (&rest args)
(when (and
(string-equal "org-mode" major-mode)
(string-match "^table.*$"
(symbol-name
(car
(car
(org-element-at-point (point)))))))
(org-ctrl-c-ctrl-c)
)))
Why not
(evil-define-operator evil-org-delete-char (beg end type register)
"Delete next character."
:motion evil-forward-char
(interactive "<R><x>")
(evil-delete beg end type register)
(org-fix-tags-on-the-fly))
(evil-define-operator evil-org-delete-backward-char (beg end type register)
"Delete previous character."
:motion evil-backward-char
(interactive "<R><x>")
(evil-delete beg end type register)
(org-fix-tags-on-the-fly))
and then rebind x and Backspace?
I'm not sure if it's quite right, but that's what I got skimming evil-delete-char
and org-delete-char
.
In particular, Backspace in insert state and x in normal state; otherwise, table alignment gets screwed up until something repairs it.