diff options
| author | Radon Rosborough <radon.neon@gmail.com> | 2019-07-15 22:43:30 -0700 |
|---|---|---|
| committer | Radon Rosborough <radon.neon@gmail.com> | 2019-07-15 22:44:22 -0700 |
| commit | 1258aa6a441726a3516206837cefb67e68cc4917 (patch) | |
| tree | 3615394c5f83f4b5dd8e811e2ad0211c75ecac89 | |
| parent | ad5f79f5b324ba37d81b2f3032b454ac7f14e25e (diff) | |
Allow let-binding apheleia-mode to nil
| -rw-r--r-- | apheleia.el | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/apheleia.el b/apheleia.el index a5c1b0f..2645426 100644 --- a/apheleia.el +++ b/apheleia.el @@ -565,19 +565,23 @@ changes), CALLBACK, if provided, is invoked with no arguments." (when callback (funcall callback))))))))) +;; Handle recursive references. +(defvar apheleia-mode) + ;; Autoload because the user may enable `apheleia-mode' without ;; loading Apheleia; thus this function may be invoked as an autoload. ;;;###autoload (defun apheleia--format-after-save () "Run code formatter for current buffer if any configured, then save." - (when-let ((command (apheleia--get-formatter-command))) - (apheleia-format-buffer - command - (lambda () - (ignore-errors - (let ((after-save-hook - (remq #'apheleia--format-after-save after-save-hook))) - (apheleia--write-file-silently buffer-file-name))))))) + (when apheleia-mode + (when-let ((command (apheleia--get-formatter-command))) + (apheleia-format-buffer + command + (lambda () + (ignore-errors + (let ((after-save-hook + (remq #'apheleia--format-after-save after-save-hook))) + (apheleia--write-file-silently buffer-file-name)))))))) ;; Use `progn' to force the entire minor mode definition to be copied ;; into the autoloads file, so that the minor mode can be enabled |
