diff options
| author | Joel Rosdahl | 2019-08-28 21:00:00 +0200 |
|---|---|---|
| committer | Noam Postavsky | 2019-09-07 16:51:24 -0400 |
| commit | 8d588f09e91e315c715cf824a9819a538a85cd9c (patch) | |
| tree | f21f366b2b5517a3b706c8ab7689b885b08dcd03 | |
| parent | 14875443ff03d3c2b9cc63479e672957f99b730a (diff) | |
| download | emacs-8d588f09e91e315c715cf824a9819a538a85cd9c.tar.gz emacs-8d588f09e91e315c715cf824a9819a538a85cd9c.zip | |
Fix flymake-proc temporary file deletion bug
* list/progmodes/flymake-proc.el (flymake-proc-create-temp-inplace):
Include a time string part (hour + minute + second + nanosecond) in
the temporary name to make it unique enough.
(flymake-proc-legacy-flymake): Store temporary file names in the
process for usage in the sentinel.
(flymake-proc--process-sentinel): Bind values of temporary file names
dynamically to values stored in the process so that the cleanup
function will delete the correct temporary file(s).
Fixes bug#31981.
| -rw-r--r-- | lisp/progmodes/flymake-proc.el | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lisp/progmodes/flymake-proc.el b/lisp/progmodes/flymake-proc.el index 2d5a47a0797..f08ba2f3681 100644 --- a/lisp/progmodes/flymake-proc.el +++ b/lisp/progmodes/flymake-proc.el | |||
| @@ -654,7 +654,14 @@ Create parent directories as needed." | |||
| 654 | (let ((cleanup-f (flymake-proc--get-cleanup-function | 654 | (let ((cleanup-f (flymake-proc--get-cleanup-function |
| 655 | (buffer-file-name)))) | 655 | (buffer-file-name)))) |
| 656 | (flymake-log 3 "cleaning up using %s" cleanup-f) | 656 | (flymake-log 3 "cleaning up using %s" cleanup-f) |
| 657 | (funcall cleanup-f)))) | 657 | ;; Make cleanup-f see the temporary file names |
| 658 | ;; created by its corresponding init function | ||
| 659 | ;; (bug#31981). | ||
| 660 | (let ((flymake-proc--temp-source-file-name | ||
| 661 | (process-get proc 'flymake-proc--temp-source-file-name)) | ||
| 662 | (flymake-proc--temp-master-file-name | ||
| 663 | (process-get proc 'flymake-proc--temp-master-file-name))) | ||
| 664 | (funcall cleanup-f))))) | ||
| 658 | (kill-buffer output-buffer))))))) | 665 | (kill-buffer output-buffer))))))) |
| 659 | 666 | ||
| 660 | (defun flymake-proc--panic (problem explanation) | 667 | (defun flymake-proc--panic (problem explanation) |
| @@ -824,6 +831,10 @@ can also be executed interactively independently of | |||
| 824 | (process-put proc 'flymake-proc--output-buffer | 831 | (process-put proc 'flymake-proc--output-buffer |
| 825 | (generate-new-buffer | 832 | (generate-new-buffer |
| 826 | (format " *flymake output for %s*" (current-buffer)))) | 833 | (format " *flymake output for %s*" (current-buffer)))) |
| 834 | (process-put proc 'flymake-proc--temp-source-file-name | ||
| 835 | flymake-proc--temp-source-file-name) | ||
| 836 | (process-put proc 'flymake-proc--temp-master-file-name | ||
| 837 | flymake-proc--temp-master-file-name) | ||
| 827 | (setq flymake-proc--current-process proc) | 838 | (setq flymake-proc--current-process proc) |
| 828 | (flymake-log 2 "started process %d, command=%s, dir=%s" | 839 | (flymake-log 2 "started process %d, command=%s, dir=%s" |
| 829 | (process-id proc) (process-command proc) | 840 | (process-id proc) (process-command proc) |
| @@ -865,6 +876,7 @@ can also be executed interactively independently of | |||
| 865 | (let* ((ext (file-name-extension file-name)) | 876 | (let* ((ext (file-name-extension file-name)) |
| 866 | (temp-name (file-truename | 877 | (temp-name (file-truename |
| 867 | (concat (file-name-sans-extension file-name) | 878 | (concat (file-name-sans-extension file-name) |
| 879 | "_" (format-time-string "%H%M%S%N") | ||
| 868 | "_" prefix | 880 | "_" prefix |
| 869 | (and ext (concat "." ext)))))) | 881 | (and ext (concat "." ext)))))) |
| 870 | (flymake-log 3 "create-temp-inplace: file=%s temp=%s" file-name temp-name) | 882 | (flymake-log 3 "create-temp-inplace: file=%s temp=%s" file-name temp-name) |