[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master dee3d93e73 1/5: Ensure temp file is deleted in makefile overview
From: |
Stefan Kangas |
Subject: |
master dee3d93e73 1/5: Ensure temp file is deleted in makefile overview |
Date: |
Fri, 28 Oct 2022 16:29:35 -0400 (EDT) |
branch: master
commit dee3d93e73b2bb9b6805084fb784a536960c42e6
Author: Stefan Kangas <stefankangas@gmail.com>
Commit: Stefan Kangas <stefankangas@gmail.com>
Ensure temp file is deleted in makefile overview
* lisp/progmodes/make-mode.el (makefile-create-up-to-date-overview):
Ensure temp file is always deleted.
---
lisp/progmodes/make-mode.el | 65 ++++++++++++++++++++++-----------------------
1 file changed, 32 insertions(+), 33 deletions(-)
diff --git a/lisp/progmodes/make-mode.el b/lisp/progmodes/make-mode.el
index 5f26521299..92d8a739a5 100644
--- a/lisp/progmodes/make-mode.el
+++ b/lisp/progmodes/make-mode.el
@@ -1504,39 +1504,38 @@ dependency in the makefile."
;; writing the current contents of the makefile buffer.
;;
(let ((saved-target-table makefile-target-table)
- (this-buffer (current-buffer))
- (makefile-up-to-date-buffer
- (get-buffer-create makefile-up-to-date-buffer-name))
- (filename (makefile-save-temporary))
- ;;
- ;; Forget the target table because it may contain picked-up
filenames
- ;; that are not really targets in the current makefile.
- ;; We don't want to query these, so get a new target-table with
just the
- ;; targets that can be found in the makefile buffer.
- ;; The 'old' target table will be restored later.
- ;;
- (real-targets (progn
- (makefile-pickup-targets)
- makefile-target-table))
- (prereqs makefile-has-prereqs)
- )
-
- (set-buffer makefile-up-to-date-buffer)
- (setq buffer-read-only nil)
- (erase-buffer)
- (makefile-query-targets filename real-targets prereqs)
- (if (zerop (buffer-size)) ; if it did not get us anything
- (progn
- (kill-buffer (current-buffer))
- (message "No overview created!")))
- (set-buffer this-buffer)
- (setq makefile-target-table saved-target-table)
- (if (get-buffer makefile-up-to-date-buffer-name)
- (progn
- (pop-to-buffer (get-buffer makefile-up-to-date-buffer-name))
- (shrink-window-if-larger-than-buffer)
- (sort-lines nil (point-min) (point-max))
- (setq buffer-read-only t))))))
+ (this-buffer (current-buffer))
+ (makefile-up-to-date-buffer
+ (get-buffer-create makefile-up-to-date-buffer-name))
+ (filename (makefile-save-temporary))
+ ;;
+ ;; Forget the target table because it may contain picked-up
filenames
+ ;; that are not really targets in the current makefile.
+ ;; We don't want to query these, so get a new target-table with
just the
+ ;; targets that can be found in the makefile buffer.
+ ;; The 'old' target table will be restored later.
+ ;;
+ (real-targets (progn
+ (makefile-pickup-targets)
+ makefile-target-table))
+ (prereqs makefile-has-prereqs))
+ (unwind-protect
+ (progn
+ (set-buffer makefile-up-to-date-buffer)
+ (setq buffer-read-only nil)
+ (erase-buffer)
+ (makefile-query-targets filename real-targets prereqs)
+ (when (zerop (buffer-size)) ; if it did not get us anything
+ (kill-buffer (current-buffer))
+ (message "No overview created!"))
+ (set-buffer this-buffer)
+ (setq makefile-target-table saved-target-table)
+ (when (get-buffer makefile-up-to-date-buffer-name)
+ (pop-to-buffer (get-buffer makefile-up-to-date-buffer-name))
+ (shrink-window-if-larger-than-buffer)
+ (sort-lines nil (point-min) (point-max))
+ (setq buffer-read-only t)))
+ (ignore-errors (delete-file filename))))))
(defun makefile-save-temporary ()
"Create a temporary file from the current makefile buffer."