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

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

[nongnu] elpa/php-mode 8e874a8fd8 2/2: Merge pull request #733 from emac


From: ELPA Syncer
Subject: [nongnu] elpa/php-mode 8e874a8fd8 2/2: Merge pull request #733 from emacs-php/feature/php-format-disable-async-format
Date: Wed, 8 Mar 2023 09:01:40 -0500 (EST)

branch: elpa/php-mode
commit 8e874a8fd8fbcf05fa7e6ddce2208514e90e7e81
Merge: e6e4ac5943 77083924b1
Author: USAMI Kenta <tadsan@pixiv.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #733 from 
emacs-php/feature/php-format-disable-async-format
    
    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]