lang/org: fix evil coupling #457

And use fix backspace not keeping tables aligned.
This commit is contained in:
Henrik Lissner 2018-03-12 12:44:44 -04:00
parent 686ce7b26e
commit d563d133ff
No known key found for this signature in database
GPG Key ID: 5F6C0EA160557395
2 changed files with 31 additions and 6 deletions

View File

@ -281,6 +281,28 @@ with `org-cycle'). Also:
;; Hooks
;;
;;;###autoload
(defun +org|delete-backward-char ()
(when (eq major-mode 'org-mode)
(org-check-before-invisible-edit 'delete-backward)
(save-match-data
(when (and (org-at-table-p)
(not (org-region-active-p))
(string-match "|" (buffer-substring (point-at-bol) (point)))
(looking-at ".*?|"))
(let ((pos (point))
(noalign (looking-at "[^|\n\r]* |"))
(c org-table-may-need-update))
(delete-char n)
(unless overwrite-mode
(skip-chars-forward "^|")
(insert " ")
(goto-char (1- pos)))
;; noalign: if there were two spaces at the end, this field
;; does not determine the width of the column.
(when noalign (setq org-table-may-need-update c)))
t))))
;;;###autoload
(defun +org|indent-maybe ()
"Indent the current item (header or item), if possible. Made for

View File

@ -32,6 +32,9 @@
(def-package! evil-org
:when (featurep! :feature evil)
:commands evil-org-mode
:init
(add-hook 'org-load-hook #'+org|setup-evil)
(add-hook 'org-mode-hook #'evil-org-mode)
:config
(evil-org-set-key-theme '(navigation insert textobjects))
(after! org-agenda
@ -56,7 +59,6 @@
org-indent-mode ; margin-based indentation
toc-org-enable ; auto-table of contents
visual-line-mode ; line wrapping
evil-org-mode ; evil-mode integration
+org|enable-auto-reformat-tables
+org|enable-auto-update-cookies
@ -230,16 +232,17 @@ between the two."
(add-hook! 'org-tab-first-hook #'(+org|indent-maybe +org|yas-expand-maybe))
(require 'evil-org)
(map! :map org-mode-map
"C-c C-S-l" #'+org/remove-link
"C-c C-i" #'org-toggle-inline-images
[remap doom/backward-to-bol-or-indent] #'org-beginning-of-line
[remap doom/forward-to-last-non-comment-or-eol] #'org-end-of-line
[remap doom/forward-to-last-non-comment-or-eol] #'org-end-of-line))
:map evil-org-mode-map
:i [backtab] #'+org/dedent
:i [backspace] #'evil-org-delete-backward-char
(defun +org|setup-evil ()
(require 'evil-org)
(add-hook 'doom-delete-backward-functions #'+org|delete-backward-char)
(map! :map evil-org-mode-map
:i [backtab] #'+org/dedent
;; navigate table cells (from insert-mode)
:i "C-l" #'+org/table-next-field
:i "C-h" #'+org/table-previous-field