From 012b759e987f3221ac21a74758c406a67a2fca65 Mon Sep 17 00:00:00 2001 From: Ralf Beckmann Date: Mon, 14 Jun 2021 23:52:16 +0200 Subject: [PATCH] Fix #5128: No format-on-save by lsp-formatters A call to `format-all--formatter-executable` with the formatter being equal to `'lsp` or `'eglot` will return `nil`. Therefore, `funcall` was never called in those cases. --- modules/editor/format/config.el | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/modules/editor/format/config.el b/modules/editor/format/config.el index 6b39582b84f..9ce07183ce9 100644 --- a/modules/editor/format/config.el +++ b/modules/editor/format/config.el @@ -74,11 +74,13 @@ This is controlled by `+format-on-save-enabled-modes'." (defadvice! +format--all-buffer-from-hook-a (orig-fn &rest args) :around #'format-all-buffer--from-hook (letf! (defun format-all-buffer--with (formatter mode-result) - (and (condition-case-unless-debug e - (format-all--formatter-executable formatter) - (error - (message "Warning: cannot reformat buffer because %S isn't installed" - (gethash formatter format-all--executable-table)) - nil)) - (funcall format-all-buffer--with formatter mode-result))) + (when (or (eq formatter 'lsp) + (eq formatter 'eglot) + (condition-case-unless-debug e + (format-all--formatter-executable formatter) + (error + (message "Warning: cannot reformat buffer because %S isn't installed" + (gethash formatter format-all--executable-table)) + nil))) + (funcall format-all-buffer--with formatter mode-result))) (apply orig-fn args)))