From 99a83ca18f21e25fa8c6c914906a07deac83df02 Mon Sep 17 00:00:00 2001 From: Sam Whitlock <433170+samwhitlock@users.noreply.github.com> Date: Sun, 13 Dec 2020 15:36:56 +0100 Subject: [PATCH] A workaround for formatting org mode If point is in a source block, format that source block. Else don't try to format the buffer. format-all-buffer does not support org mode. --- modules/editor/format/autoload/format.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/editor/format/autoload/format.el b/modules/editor/format/autoload/format.el index 9e1020b50..6565b7c7d 100644 --- a/modules/editor/format/autoload/format.el +++ b/modules/editor/format/autoload/format.el @@ -225,9 +225,9 @@ If nil, BEG and/or END will default to the boundaries of the src block at point. (defun +format/buffer () "Reformat the current buffer using LSP or `format-all-buffer'." (interactive) - (if (and (eq major-mode 'org-mode) - (org-in-src-block-p t)) - (+format--org-region nil nil) + (if (eq major-mode 'org-mode) + (when (org-in-src-block-p t) + (+format--org-region nil nil)) (call-interactively (cond ((and +format-with-lsp (bound-and-true-p lsp-mode)