branch: elpa/flymake-collection
commit d09afd32d47f13f2a578314090799b4031525244
Author: Mohsin Kaleem <mohk...@kisara.moe>
Commit: Mohsin Kaleem <mohk...@kisara.moe>

    (flymake-rest-define): Fix source-inplace doesn't cleanup
    
    Before source-inplace used to generate a non-unique file-name and didn't
    delete it on exit, now it does both although it'll disable a checker if
    the cwd doesn't exist (which is the case for buffers in newly made
    directories).
---
 flymake-rest-define.el | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/flymake-rest-define.el b/flymake-rest-define.el
index 2d5ce81fd7..a604571a43 100644
--- a/flymake-rest-define.el
+++ b/flymake-rest-define.el
@@ -111,9 +111,10 @@ diagnostics to parse this form should evaluate to nil."
          (proc-symb (intern "proc"))
          (source-symb (intern "fmqd-source"))
          (current-diags-symb (intern "diag"))
-         (cleanup-form (when (and (eq write-type 'file)
-                                  (not source-inplace))
-                         `((delete-directory ,temp-dir-symb t))))
+         (cleanup-form (when (eq write-type 'file)
+                         (if source-inplace
+                             `((delete-file ,temp-file-symb))
+                           `((delete-directory ,temp-dir-symb t)))))
          (not-obsolete-form `((eq ,proc-symb (plist-get (buffer-local-value 
'flymake-rest-define--procs ,source-symb) ',name)))))
     ;; Sanitise parsed inputs from `defs'.
     (unless (memq write-type '(file pipe nil))
@@ -126,19 +127,23 @@ diagnostics to parse this form should evaluate to nil."
               ,@(when (eq write-type 'file)
                   `((,temp-dir-symb
                      ,@(let ((forms (append (when source-inplace
-                                              `((when-let ((file 
(buffer-file-name)))
-                                                  (file-name-directory file))
-                                                default-directory))
+                                              `((when-let ((dir (or (when-let 
((file (buffer-file-name)))
+                                                                      
(file-name-directory file))
+                                                                    
default-directory)))
+                                                  (unless (file-exists-p dir)
+                                                    (error "Checker needs to 
be run in the cwd, but the cwd doesn't exist: %s" dir))
+                                                  dir)))
                                             '((make-temp-file "flymake-" t)))))
                          (if (> (length forms) 1)
                              `((or ,@forms))
                            forms)))
                     (,temp-file-symb
-                     (concat
-                      (file-name-as-directory ,temp-dir-symb)
-                      (concat ".flymake_"
-                              (file-name-nondirectory (or (buffer-file-name)
-                                                          (buffer-name))))))))
+                     (let ((temporary-file-directory ,temp-dir-symb)
+                           (basename (file-name-nondirectory (or 
(buffer-file-name)
+                                                                 
(buffer-name)))))
+                       (make-temp-file ".flymake_"
+                                       nil
+                                       (concat "_" basename))))))
               ,@(plist-get defs :pre-let))
          ;; With vars defined, do :pre-check.
          ,@(when-let ((pre-check (plist-get defs :pre-check)))

Reply via email to