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
This commit is contained in:
Henrik Lissner 2019-04-04 18:47:40 -04:00
parent 3a47c27dd6
commit 6084b774b8
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
3 changed files with 106 additions and 73 deletions

View file

@ -361,8 +361,8 @@ another level of headings on each invocation."
;;;###autoload
(defun +org|indent-maybe ()
"Indent the current item (header or item), if possible. Made for
`org-tab-first-hook' in evil-mode."
"Indent the current item (header or item), if possible.
Made for `org-tab-first-hook' in evil-mode."
(interactive)
(cond ((or (not (bound-and-true-p evil-mode))
(not (eq evil-state 'insert)))

View file

@ -1,12 +1,7 @@
;;; org/org/autoload/tables.el -*- lexical-binding: t; -*-
;;;###autoload
(defun +org/table-next-row ()
"Go to the next row (same column) in the current table."
(interactive)
(if (org-at-table-p)
(org-table-next-row)
(org-down-element)))
;;
;;; Row/Column traversal
;;;###autoload
(defun +org/table-previous-row ()
@ -14,41 +9,37 @@
re-align the table if necessary. (Necessary because org-mode has a
`org-table-next-row', but not `org-table-previous-row')"
(interactive)
(if (org-at-table-p)
(progn
(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))))
(org-up-element)))
(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-next-field ()
(defun +org/table-insert-column-left ()
"Insert a new column right of the current column."
(interactive)
(if (org-at-table-p) (org-table-next-field) (org-end-of-line)))
(org-table-insert-column)
(org-table-move-column-left))
;;;###autoload
(defun +org/table-previous-field ()
(defun +org/table-insert-row-below ()
"Insert a new row below the current row."
(interactive)
(if (org-at-table-p) (org-table-previous-field) (org-beginning-of-line)))
(org-table-insert-row 'below))
;;;###autoload
(defalias '+org/table-append-field-or-shift-right #'org-shiftmetaright)
;;;###autoload
(defun +org/table-prepend-field-or-shift-left ()
"TODO"
(interactive)
(if (org-at-table-p)
(progn
(org-shiftmetaright)
(org-table-move-column-left))
(org-shiftmetaleft)))
(defalias '+org/table-insert-row-above #'org-table-insert-row
"Insert a new row above the current row.")