doomemacs/modules/lang/org/autoload/tables.el
Henrik Lissner 6084b774b8
lang/org: refactor and add keybinds for org tables
This update focuses on improving the key UX of org tables.

- Adds new table localleader keys under `SPC m s'
- Adds new localleader keybinds
  - New `s` prefix for table commands
  - New `f`/`F` keybinds for footnotes
  - New `'` keybind for `org-edit-special`
  - New `r` keybind for `org-refile`
- Bind localleader keys for both evil and non-evil users
- Refactors org table API
- For evil users:
  - Adds `zi` to toggle inline images
  - Finalize insert-mode keybind scheme for evil users (ala excel/gdocs)
    - C-{h,j,k,l} = move cursor between cells
    - C-M-{h,j,k,l} = insert cells in direction
    - C-M-S-{h,j,k,l} = swap cells in direction
2019-04-04 18:52:25 -04:00

45 lines
1.3 KiB
EmacsLisp

;;; org/org/autoload/tables.el -*- lexical-binding: t; -*-
;;
;;; Row/Column traversal
;;;###autoload
(defun +org/table-previous-row ()
"Go to the previous row (same column) in the current table. Before doing so,
re-align the table if necessary. (Necessary because org-mode has a
`org-table-next-row', but not `org-table-previous-row')"
(interactive)
(org-table-maybe-eval-formula)
(org-table-maybe-recalculate-line)
(if (and org-table-automatic-realign
org-table-may-need-update)
(org-table-align))
(let ((col (org-table-current-column)))
(beginning-of-line 0)
(when (or (not (org-at-table-p)) (org-at-table-hline-p))
(beginning-of-line))
(org-table-goto-column col)
(skip-chars-backward "^|\n\r")
(when (org-looking-at-p " ")
(forward-char))))
;;
;;; Row/Column insertion
;;;###autoload
(defun +org/table-insert-column-left ()
"Insert a new column right of the current column."
(interactive)
(org-table-insert-column)
(org-table-move-column-left))
;;;###autoload
(defun +org/table-insert-row-below ()
"Insert a new row below the current row."
(interactive)
(org-table-insert-row 'below))
;;;###autoload
(defalias '+org/table-insert-row-above #'org-table-insert-row
"Insert a new row above the current row.")