Skip to content
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