Visualize ranking of last game when adding scores

* 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)
This commit is contained in:
Peder O. Klingenberg 2024-07-18 22:34:54 +02:00 committed by Stefan Kangas
parent 99b360bb5a
commit c330b97fe2

View 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)))))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;