Skip to content

Add php-format-disable-async-format-buffer-has-modified #733

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lisp/php-format.el
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@
:type '(alist :key-type function
:value-type symbol)
:group 'php-format)

(defcustom php-format-disable-async-format-buffer-has-modified t
"When non-NIL, disable asynchronous formatting if the buffer has modified (not saved)."
:tag "PHP Format Disable Async Format Buffer Has Modified"
:type 'boolean
:group 'php-format)

;; Internal functions
(defsubst php-format--register-timer (sec command-args)
Expand Down Expand Up @@ -182,8 +188,10 @@
"Asynchronously execute PHP format with COMMAND-ARGS in DIR."
(setq php-format--idle-timer nil)
(let ((default-directory dir))
(apply #'call-process-shell-command (car command-args) nil nil nil
(append (cdr command-args) (list "&")))))
(when (not (and php-format-disable-async-format-buffer-has-modified
(buffer-modified-p)))
(apply #'call-process-shell-command (car command-args) nil nil nil
(append (cdr command-args) (list "&"))))))

;; Public functions and minor mode

Expand Down