diff options
| author | Colin Walters | 2002-04-10 19:13:35 +0000 |
|---|---|---|
| committer | Colin Walters | 2002-04-10 19:13:35 +0000 |
| commit | baf9c39a8c126e8dad9a528bf5f1f0c1f08c6531 (patch) | |
| tree | 36c3c81f1b26347b9d1ea20a42be44fc60dbaf36 | |
| parent | b23af4699917734d50dc9f0daf7942866da7c466 (diff) | |
| download | emacs-baf9c39a8c126e8dad9a528bf5f1f0c1f08c6531.tar.gz emacs-baf9c39a8c126e8dad9a528bf5f1f0c1f08c6531.zip | |
(gamegrid-add-score): Rewrite from scratch to use `update-game-score'.
| -rw-r--r-- | lisp/play/gamegrid.el | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/lisp/play/gamegrid.el b/lisp/play/gamegrid.el index 2ff50ad53eb..ffb179d52d2 100644 --- a/lisp/play/gamegrid.el +++ b/lisp/play/gamegrid.el | |||
| @@ -406,25 +406,35 @@ static char *noname[] = { | |||
| 406 | 406 | ||
| 407 | (defun gamegrid-add-score (file score) | 407 | (defun gamegrid-add-score (file score) |
| 408 | "Add the current score to the high score file." | 408 | "Add the current score to the high score file." |
| 409 | (let ((result nil) | ||
| 410 | (errbuf (generate-new-buffer " *update-game-score loss*"))) | ||
| 411 | (let ((default-directory "/")) | ||
| 412 | (apply | ||
| 413 | 'call-process | ||
| 414 | (append | ||
| 415 | (list | ||
| 416 | (expand-file-name "update-game-score" exec-directory) | ||
| 417 | nil errbuf nil | ||
| 418 | "-m" (int-to-string gamegrid-score-file-length) file | ||
| 419 | (int-to-string score) | ||
| 420 | (concat | ||
| 421 | (user-full-name) | ||
| 422 | " <" | ||
| 423 | (cond ((fboundp 'user-mail-address) | ||
| 424 | (user-mail-address)) | ||
| 425 | ((boundp 'user-mail-address) | ||
| 426 | user-mail-address) | ||
| 427 | (t "")) | ||
| 428 | "> " | ||
| 429 | (current-time-string))))) | ||
| 430 | (if (buffer-modified-p errbuf) | ||
| 431 | (progn | ||
| 432 | (display-buffer errbuf) | ||
| 433 | (error "Failed to update game score file")) | ||
| 434 | (kill-buffer errbuf)))) | ||
| 409 | (save-excursion | 435 | (save-excursion |
| 410 | (find-file-other-window file) | 436 | (find-file-read-only-other-window (expand-file-name file game-score-directory)))) |
| 411 | (setq buffer-read-only nil) | 437 | |
| 412 | (goto-char (point-max)) | ||
| 413 | (insert (format "%05d\t%s\t%s <%s>\n" | ||
| 414 | score | ||
| 415 | (current-time-string) | ||
| 416 | (user-full-name) | ||
| 417 | (cond ((fboundp 'user-mail-address) | ||
| 418 | (user-mail-address)) | ||
| 419 | ((boundp 'user-mail-address) | ||
| 420 | user-mail-address) | ||
| 421 | (t "")))) | ||
| 422 | (sort-numeric-fields 1 (point-min) (point-max)) | ||
| 423 | (reverse-region (point-min) (point-max)) | ||
| 424 | (goto-line (1+ gamegrid-score-file-length)) | ||
| 425 | (delete-region (point) (point-max)) | ||
| 426 | (setq buffer-read-only t) | ||
| 427 | (save-buffer))) | ||
| 428 | 438 | ||
| 429 | ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 439 | ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 430 | 440 | ||