407 |
(defun gamegrid-add-score (file score) |
(defun gamegrid-add-score (file score) |
408 |
"Add the current score to the high score file." |
"Add the current score to the high score file." |
409 |
(let ((result nil) |
(let ((result nil) |
410 |
(errbuf (generate-new-buffer " *update-game-score loss*"))) |
(errbuf (generate-new-buffer " *update-game-score loss*")) |
411 |
|
(target (if game-score-directory |
412 |
|
file |
413 |
|
(let ((f (expand-file-name "~/.emacs.d/games"))) |
414 |
|
(unless (eq (car-safe (file-attributes f)) |
415 |
|
t) |
416 |
|
(make-directory f)) |
417 |
|
(setq f (expand-file-name file f)) |
418 |
|
(unless (file-exists-p f) |
419 |
|
(write-region "" nil f nil 'silent nil 'excl)) |
420 |
|
f)))) |
421 |
(let ((default-directory "/")) |
(let ((default-directory "/")) |
422 |
(apply |
(apply |
423 |
'call-process |
'call-process |
436 |
user-mail-address) |
user-mail-address) |
437 |
(t "")) |
(t "")) |
438 |
"> " |
"> " |
439 |
(current-time-string))))) |
(current-time-string)))))) |
440 |
(if (buffer-modified-p errbuf) |
(if (buffer-modified-p errbuf) |
441 |
(progn |
(progn |
442 |
(display-buffer errbuf) |
(display-buffer errbuf) |
443 |
(error "Failed to update game score file")) |
(error "Failed to update game score file")) |
444 |
(kill-buffer errbuf)))) |
(kill-buffer errbuf)) |
445 |
(save-excursion |
(save-excursion |
446 |
(find-file-read-only-other-window (expand-file-name file game-score-directory)))) |
(find-file-read-only-other-window target)))) |
447 |
|
|
448 |
|
|
449 |
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |