]> git.eshelyaron.com Git - emacs.git/commitdiff
Visualize ranking of last game when adding scores
authorPeder O. Klingenberg <peder@klingenberg.no>
Thu, 18 Jul 2024 20:34:54 +0000 (22:34 +0200)
committerEshel Yaron <me@eshelyaron.com>
Mon, 22 Jul 2024 10:32:29 +0000 (12:32 +0200)
* lisp/play/gamegrid.el (gamegrid-add-score-insecure): Move point to
the score just added, or end of buffer if the new score did not make
the list.  This makes it easier to see where the last game
ranked.  (Bug#72185)

(cherry picked from commit c330b97fe24088c32394fae7f52aa18315d123b0)

lisp/play/gamegrid.el

index a098d0f6f69c51c269a5e7bc29ef04026cfc271e..36c72c5cff7e5490d2b4e227146f70e97fad25f5 100644 (file)
@@ -639,27 +639,31 @@ FILE is created there."
 
 (defun gamegrid-add-score-insecure (file score &optional directory reverse)
   (save-excursion
-    (setq file (expand-file-name file (or directory
-                                         temporary-file-directory)))
-    (unless (file-exists-p (file-name-directory file))
-      (make-directory (file-name-directory file) t))
-    (find-file-other-window file)
-    (setq buffer-read-only nil)
-    (goto-char (point-max))
-    (insert (format "%05d\t%s\t%s <%s>\n"
-                   score
-                   (current-time-string)
-                   (user-full-name)
-                   user-mail-address))
-    (sort-fields 1 (point-min) (point-max))
-    (unless reverse
-      (reverse-region (point-min) (point-max)))
-    (goto-char (point-min))
-    (forward-line gamegrid-score-file-length)
-    (delete-region (point) (point-max))
-    (setq buffer-read-only t)
-    (save-buffer)
-    (view-mode)))
+    (let ((score-line (format "%05d\t%s\t%s <%s>\n"
+                              score
+                              (current-time-string)
+                              (user-full-name)
+                              user-mail-address)))
+      (setq file (expand-file-name file (or directory
+                                            temporary-file-directory)))
+      (unless (file-exists-p (file-name-directory file))
+        (make-directory (file-name-directory file) t))
+      (find-file-other-window file)
+      (setq buffer-read-only nil)
+      (goto-char (point-max))
+      (insert score-line)
+      (sort-fields 1 (point-min) (point-max))
+      (unless reverse
+        (reverse-region (point-min) (point-max)))
+      (goto-char (point-min))
+      (forward-line gamegrid-score-file-length)
+      (delete-region (point) (point-max))
+      (setq buffer-read-only t)
+      (save-buffer)
+      (view-mode)
+      (goto-char (point-min))
+      (when (search-forward score-line nil 'end)
+        (forward-line -1)))))
 
 
 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;