mirror of
https://github.com/vale981/apheleia
synced 2025-03-04 17:11:40 -05:00
Disable automatically for remote files
This commit is contained in:
parent
49568bb166
commit
e28a264989
2 changed files with 32 additions and 18 deletions
|
@ -89,6 +89,9 @@ the configured formatter for the current buffer. Running with a prefix
|
|||
argument will cause the command to prompt you for which formatter to
|
||||
run.
|
||||
|
||||
Apheleia does not currently support TRAMP, and is therefore
|
||||
automatically disabled for remote files.
|
||||
|
||||
The following user options are also available:
|
||||
|
||||
* `apheleia-post-format-hook`: Normal hook run after Apheleia formats
|
||||
|
|
17
apheleia.el
17
apheleia.el
|
@ -513,6 +513,11 @@ even if a formatter is configured."
|
|||
(defvar apheleia--buffer-hash nil
|
||||
"Return value of `buffer-hash' when formatter started running.")
|
||||
|
||||
(defun apheleia--disallowed-p ()
|
||||
"Return an error message if Apheleia cannot be run, else nil."
|
||||
(when (and buffer-file-name (file-remote-p buffer-file-name))
|
||||
"Apheleia does not support remote files"))
|
||||
|
||||
;;;###autoload
|
||||
(defun apheleia-format-buffer (command &optional callback)
|
||||
"Run code formatter asynchronously on current buffer, preserving point.
|
||||
|
@ -550,10 +555,16 @@ aborted.
|
|||
If the formatter actually finishes running and the buffer is
|
||||
successfully updated (even if the formatter has not made any
|
||||
changes), CALLBACK, if provided, is invoked with no arguments."
|
||||
(interactive (list (apheleia--get-formatter-command
|
||||
(interactive (progn
|
||||
(when-let ((err (apheleia--disallowed-p)))
|
||||
(user-error err))
|
||||
(list (apheleia--get-formatter-command
|
||||
(if current-prefix-arg
|
||||
'prompt
|
||||
'interactive))))
|
||||
'interactive)))))
|
||||
;; Fail silently if disallowed, since we don't want to throw an
|
||||
;; error on `post-command-hook'.
|
||||
(unless (apheleia--disallowed-p)
|
||||
(setq-local apheleia--buffer-hash (apheleia--buffer-hash))
|
||||
(apheleia--run-formatter
|
||||
command
|
||||
|
@ -567,7 +578,7 @@ changes), CALLBACK, if provided, is invoked with no arguments."
|
|||
(apheleia--apply-rcs-patch
|
||||
(current-buffer) patch-buffer)
|
||||
(when callback
|
||||
(funcall callback)))))))))
|
||||
(funcall callback))))))))))
|
||||
|
||||
(defcustom apheleia-post-format-hook nil
|
||||
"Normal hook run after Apheleia formats a buffer."
|
||||
|
|
Loading…
Add table
Reference in a new issue