[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/mines 179ed77 32/43: Dont prompt user when updating the
From: |
Stefan Monnier |
Subject: |
[elpa] externals/mines 179ed77 32/43: Dont prompt user when updating the score file |
Date: |
Mon, 30 Nov 2020 18:44:18 -0500 (EST) |
branch: externals/mines
commit 179ed77dac7a81016947c2f7d40a0ae94228ba93
Author: Tino Calancha <tino.calancha@gmail.com>
Commit: Tino Calancha <tino.calancha@gmail.com>
Dont prompt user when updating the score file
Bump version to 1.4
* mines.el (mines--sort-score-file): Revert the buffer visiting the
score file and set it read only.
---
mines.el | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/mines.el b/mines.el
index 24ee5e8..63096a3 100644
--- a/mines.el
+++ b/mines.el
@@ -5,7 +5,7 @@
;; Author: Tino Calancha <tino.calancha@gmail.com>
;; Created: 2017-10-28
;; Keywords: games
-;; Version: 1.3
+;; Version: 1.4
;; Package-Requires: ((emacs "24.4") (cl-lib "0.5"))
;; url: https://github.com/calancha/Minesweeper
@@ -453,14 +453,20 @@ Instead, in this file the score is the number of seconds
to complete
the game, i.e., getting a shorter score means a better result.
After sorting, games completed with shorter times appear first."
(when (file-exists-p file)
- (with-temp-file file
- (insert
- (with-temp-buffer
- (insert-file-contents file) (buffer-string)))
- (sort-fields 1 (point-min) (point-max))
- (goto-char (point-min))
- (forward-line (or limit gamegrid-score-file-length))
- (delete-region (point) (point-max)))))
+ (let ((buf (get-file-buffer file)))
+ (with-temp-file file
+ (insert
+ (with-temp-buffer
+ (insert-file-contents file) (buffer-string)))
+ (sort-fields 1 (point-min) (point-max))
+ (goto-char (point-min))
+ (forward-line (or limit gamegrid-score-file-length))
+ (delete-region (point) (point-max)))
+ ;; If there is a buffer visiting FILE, then revert it.
+ (when buf
+ (with-current-buffer buf
+ (revert-buffer nil 'noconfirm)
+ (read-only-mode 1))))))
(defun mines-game-completed ()
(setq mines-end-time (current-time))
@@ -485,9 +491,7 @@ After sorting, games completed with shorter times appear
first."
;; save score
(gamegrid-add-score score-file score)
;; Sort `score-file' again and update the buffer visiting it.
- (mines--sort-score-file score-file)
- (with-current-buffer (find-buffer-visiting score-file)
- (revert-buffer nil 'noconfirm)))
+ (mines--sort-score-file score-file))
(message (format "Well done %s, you have completed it in %s!"
user-login-name elapsed-time))))
- [elpa] externals/mines 7133550 28/43: * mines/mines.el (mines-mode): Move the docstring to where it belongs., (continued)
- [elpa] externals/mines 7133550 28/43: * mines/mines.el (mines-mode): Move the docstring to where it belongs., Stefan Monnier, 2020/11/30
- [elpa] externals/mines 2241dcd 36/43: * mines/mines.el: Various minor changes, wave 1, Stefan Monnier, 2020/11/30
- [elpa] externals/mines 3308a99 38/43: * packages/mines/mines.el: Keep flag in mines-state, Stefan Monnier, 2020/11/30
- [elpa] externals/mines e090a90 40/43: * mines.el: Make sure the first move is successful, Stefan Monnier, 2020/11/30
- [elpa] externals/mines bea3ad8 42/43: * packages/mines/mines.el (mines-auto-flag): New custom var, Stefan Monnier, 2020/11/30
- [elpa] externals/mines 97e0a05 43/43: * mines.el: Adjust docs for the @ => SPC change, Stefan Monnier, 2020/11/30
- [elpa] externals/mines 92399df 29/43: * packages/mines/mines.el: Bump version to 1.2, Stefan Monnier, 2020/11/30
- [elpa] externals/mines 868e9b9 35/43: * mines.el: Bump version to v1.6, Stefan Monnier, 2020/11/30
- [elpa] externals/mines e127c84 30/43: Add fallback function for read-multiple-choice, Stefan Monnier, 2020/11/30
- [elpa] externals/mines bf577b0 31/43: Sort the score file from better to worst results, Stefan Monnier, 2020/11/30
- [elpa] externals/mines 179ed77 32/43: Dont prompt user when updating the score file,
Stefan Monnier <=
- [elpa] externals/mines 9b07cb6 33/43: Do not uncover flagged cells if the user dont want that, Stefan Monnier, 2020/11/30
- [elpa] externals/mines 34d088c 34/43: Reimplement mines-end-p, Stefan Monnier, 2020/11/30
- [elpa] externals/mines 5920f2d 37/43: * mines/mines.el (mines-grid): Use `bomb` instead of t, Stefan Monnier, 2020/11/30
- [elpa] externals/mines f11e546 41/43: * mines.el (mines-mode-map): Add mouse bindings, Stefan Monnier, 2020/11/30