diff options
| -rw-r--r-- | lisp/play/dunnet.el | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lisp/play/dunnet.el b/lisp/play/dunnet.el index ae31dc56ffc..f0a1cf12003 100644 --- a/lisp/play/dunnet.el +++ b/lisp/play/dunnet.el | |||
| @@ -27,10 +27,6 @@ | |||
| 27 | ;; This game can be run in batch mode. To do this, use: | 27 | ;; This game can be run in batch mode. To do this, use: |
| 28 | ;; emacs -batch -l dunnet | 28 | ;; emacs -batch -l dunnet |
| 29 | 29 | ||
| 30 | ;;; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
| 31 | ;;; The log file should be set for your system, and it must | ||
| 32 | ;;; be writable by all. | ||
| 33 | |||
| 34 | ;;; Code: | 30 | ;;; Code: |
| 35 | 31 | ||
| 36 | (defgroup dunnet nil | 32 | (defgroup dunnet nil |
| @@ -38,8 +34,13 @@ | |||
| 38 | :prefix "dun-" | 34 | :prefix "dun-" |
| 39 | :group 'games) | 35 | :group 'games) |
| 40 | 36 | ||
| 41 | (defcustom dun-log-file "/usr/local/dunnet.score" | 37 | ;; Cf gamegrid. dunnet normally runs in batch mode, where |
| 38 | ;; locate-user-emacs-file doesn't create directories. | ||
| 39 | (defcustom dun-log-file (expand-file-name "dunnet-scores" | ||
| 40 | (let (noninteractive) | ||
| 41 | (locate-user-emacs-file "games/"))) | ||
| 42 | "Name of file to store score information for dunnet." | 42 | "Name of file to store score information for dunnet." |
| 43 | :version "26.1" | ||
| 43 | :type 'file | 44 | :type 'file |
| 44 | :group 'dunnet) | 45 | :group 'dunnet) |
| 45 | 46 | ||
| @@ -3068,11 +3069,15 @@ File not found"))) | |||
| 3068 | (setq dun-room 0))))) | 3069 | (setq dun-room 0))))) |
| 3069 | 3070 | ||
| 3070 | 3071 | ||
| 3072 | ;; See gamegrid-add-score; but that only handles a single integer score. | ||
| 3071 | (defun dun-do-logfile (type how) | 3073 | (defun dun-do-logfile (type how) |
| 3072 | (let (ferror) | 3074 | (let (ferror) |
| 3073 | (with-temp-buffer | 3075 | (with-temp-buffer |
| 3074 | (condition-case err | 3076 | (condition-case err |
| 3075 | (insert-file-contents dun-log-file) | 3077 | (if (file-exists-p dun-log-file) |
| 3078 | (insert-file-contents dun-log-file) | ||
| 3079 | (let ((dir (file-name-directory dun-log-file))) | ||
| 3080 | (if dir (make-directory dir t)))) | ||
| 3076 | (error | 3081 | (error |
| 3077 | (setq ferror t) | 3082 | (setq ferror t) |
| 3078 | (dun-mprincl (error-message-string err)))) | 3083 | (dun-mprincl (error-message-string err)))) |