feat(format): add +format/org-block-in-region

Also updates `+org/reformat-at-point` to call
`+format/org-block-in-region` if selection is active.

Fix: #7936
This commit is contained in:
Henrik Lissner 2024-07-14 01:48:11 -04:00
parent 378d0b8db6
commit 7543b04e15
No known key found for this signature in database
GPG key ID: B60957CA074D39A3
4 changed files with 91 additions and 27 deletions

View file

@ -344,7 +344,19 @@ If in an org table, realign the cells with `org-table-align'.
Otherwise, falls back to `org-fill-paragraph' to reflow paragraphs."
(interactive)
(let ((element (org-element-at-point)))
(cond ((org-in-src-block-p nil element)
(cond ((doom-region-active-p)
;; TODO Perform additional formatting?
;; (save-restriction
;; (narrow-to-region beg end)
;; (org-table-recalculate t)
;; (org-table-map-tables #'org-table-align)
;; (org-align-tags t)
;; (org-update-statistics-cookies t)
;; ...)
(if (modulep! :editor format)
(call-interactively #'+format/org-block-in-region)
(message ":editor format is disabled, skipping reformatting of org-blocks")))
((org-in-src-block-p nil element)
(unless (modulep! :editor format)
(user-error ":editor format module is disabled, ignoring reformat..."))
(call-interactively #'+format/org-block))