emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/php-mode 77083924b1 1/2: Add php-format-disable-async-form


From: ELPA Syncer
Subject: [nongnu] elpa/php-mode 77083924b1 1/2: Add php-format-disable-async-format-buffer-has-modified
Date: Wed, 8 Mar 2023 09:01:39 -0500 (EST)

branch: elpa/php-mode
commit 77083924b121c436ae3fa0c5183b54b92a605df2
Author: USAMI Kenta <tadsan@zonu.me>
Commit: USAMI Kenta <tadsan@zonu.me>

    Add php-format-disable-async-format-buffer-has-modified
---
 lisp/php-format.el | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/lisp/php-format.el b/lisp/php-format.el
index 3aafc27885..f3a7886926 100644
--- a/lisp/php-format.el
+++ b/lisp/php-format.el
@@ -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)
@@ -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
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]