lang/org: major refactor & add org-fancy-priorities package
- Fixes an issue where evil bindings weren't working in org-mode - Significantly slims down on unnecessary keybinds - Remove +org-init-keybinds-for-evil-h hook and reli more on our new evil-org fork, which has upstreamed some of our changes. - Documents undocumented functions, remove unnused ones, and reorganize org's autoload libraries by convention. - Adds org-fancy-priorities for more elegant (and subtle) priority display than ugly [#A] tags.
This commit is contained in:
parent
9f8277b2c4
commit
5f00db871e
12 changed files with 600 additions and 601 deletions
97
modules/lang/org/autoload/org-tables.el
Normal file
97
modules/lang/org/autoload/org-tables.el
Normal file
|
@ -0,0 +1,97 @@
|
|||
;;; lang/org/autoload/org-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 left 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))
|
||||
|
||||
|
||||
;;
|
||||
;;; Hooks
|
||||
|
||||
;;;###autoload
|
||||
(defun +org-realign-table-maybe-h ()
|
||||
"Auto-align table under cursor and re-calculate formulas."
|
||||
(when (and (org-at-table-p) org-table-may-need-update)
|
||||
(let ((pt (point))
|
||||
(inhibit-message t))
|
||||
(org-table-recalculate)
|
||||
(if org-table-may-need-update (org-table-align))
|
||||
(goto-char pt))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org-enable-auto-reformat-tables-h ()
|
||||
"Realign tables & update formulas when exiting insert mode (`evil-mode').
|
||||
Meant for `org-mode-hook'."
|
||||
(when (featurep 'evil)
|
||||
(add-hook 'evil-insert-state-exit-hook #'+org-realign-table-maybe-h nil t)
|
||||
(add-hook 'evil-replace-state-exit-hook #'+org-realign-table-maybe-h nil t)
|
||||
(advice-add #'evil-replace :after #'+org-realign-table-maybe-a)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org-delete-backward-char-and-realign-table-maybe-h ()
|
||||
"Ensure deleting characters with backspace doesn't deform the table cell."
|
||||
(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-p "|" (buffer-substring (point-at-bol) (point)))
|
||||
(looking-at-p ".*?|"))
|
||||
(let ((pos (point))
|
||||
(noalign (looking-at-p "[^|\n\r]* |"))
|
||||
(c org-table-may-need-update))
|
||||
(delete-char -1)
|
||||
(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))))
|
||||
|
||||
|
||||
;;
|
||||
;;; Advice
|
||||
|
||||
;;;###autoload
|
||||
(defun +org-realign-table-maybe-a (&rest _)
|
||||
"Auto-align table under cursor and re-calculate formulas."
|
||||
(when (eq major-mode 'org-mode)
|
||||
(+org-realign-table-maybe-h)))
|
Loading…
Add table
Add a link
Reference in a new issue