lang/org: fix evil coupling #457
And use fix backspace not keeping tables aligned.
This commit is contained in:
parent
686ce7b26e
commit
d563d133ff
2 changed files with 31 additions and 6 deletions
|
@ -281,6 +281,28 @@ with `org-cycle'). Also:
|
||||||
;; Hooks
|
;; 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
|
;;;###autoload
|
||||||
(defun +org|indent-maybe ()
|
(defun +org|indent-maybe ()
|
||||||
"Indent the current item (header or item), if possible. Made for
|
"Indent the current item (header or item), if possible. Made for
|
||||||
|
|
|
@ -32,6 +32,9 @@
|
||||||
(def-package! evil-org
|
(def-package! evil-org
|
||||||
:when (featurep! :feature evil)
|
:when (featurep! :feature evil)
|
||||||
:commands evil-org-mode
|
:commands evil-org-mode
|
||||||
|
:init
|
||||||
|
(add-hook 'org-load-hook #'+org|setup-evil)
|
||||||
|
(add-hook 'org-mode-hook #'evil-org-mode)
|
||||||
:config
|
:config
|
||||||
(evil-org-set-key-theme '(navigation insert textobjects))
|
(evil-org-set-key-theme '(navigation insert textobjects))
|
||||||
(after! org-agenda
|
(after! org-agenda
|
||||||
|
@ -56,7 +59,6 @@
|
||||||
org-indent-mode ; margin-based indentation
|
org-indent-mode ; margin-based indentation
|
||||||
toc-org-enable ; auto-table of contents
|
toc-org-enable ; auto-table of contents
|
||||||
visual-line-mode ; line wrapping
|
visual-line-mode ; line wrapping
|
||||||
evil-org-mode ; evil-mode integration
|
|
||||||
|
|
||||||
+org|enable-auto-reformat-tables
|
+org|enable-auto-reformat-tables
|
||||||
+org|enable-auto-update-cookies
|
+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))
|
(add-hook! 'org-tab-first-hook #'(+org|indent-maybe +org|yas-expand-maybe))
|
||||||
|
|
||||||
(require 'evil-org)
|
|
||||||
(map! :map org-mode-map
|
(map! :map org-mode-map
|
||||||
"C-c C-S-l" #'+org/remove-link
|
"C-c C-S-l" #'+org/remove-link
|
||||||
"C-c C-i" #'org-toggle-inline-images
|
"C-c C-i" #'org-toggle-inline-images
|
||||||
[remap doom/backward-to-bol-or-indent] #'org-beginning-of-line
|
[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
|
(defun +org|setup-evil ()
|
||||||
:i [backtab] #'+org/dedent
|
(require 'evil-org)
|
||||||
:i [backspace] #'evil-org-delete-backward-char
|
(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)
|
;; navigate table cells (from insert-mode)
|
||||||
:i "C-l" #'+org/table-next-field
|
:i "C-l" #'+org/table-next-field
|
||||||
:i "C-h" #'+org/table-previous-field
|
:i "C-h" #'+org/table-previous-field
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue