emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master ba011e4: * lisp/play/dunnet.el: Run the game when loaded via `--b


From: Stefan Monnier
Subject: master ba011e4: * lisp/play/dunnet.el: Run the game when loaded via `--batch -l dunnet`
Date: Tue, 5 Jan 2021 21:29:48 -0500 (EST)

branch: master
commit ba011e487d40b96691d3e7af917ff6ce9d7c7a00
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    * lisp/play/dunnet.el: Run the game when loaded via `--batch -l dunnet`
    
    (dun--batch): Rename from `dun-batch` and don't autoload.
    (dunnet): Delegate to `dun--batch` when in batch mode.
---
 lisp/play/dunnet.el | 29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/lisp/play/dunnet.el b/lisp/play/dunnet.el
index e328b6e..3916e35 100644
--- a/lisp/play/dunnet.el
+++ b/lisp/play/dunnet.el
@@ -25,7 +25,8 @@
 ;;; Commentary:
 
 ;; This game can be run in batch mode.  To do this, use:
-;;    emacs -batch -l dunnet
+;;
+;;    emacs --batch -f dunnet
 
 ;;; Code:
 
@@ -1170,11 +1171,13 @@ treasures for points?" "4" "four")
 (defun dunnet ()
   "Switch to *dungeon* buffer and start game."
   (interactive)
-  (pop-to-buffer-same-window "*dungeon*")
-  (dun-mode)
-  (setq dun-dead nil)
-  (setq dun-room 0)
-  (dun-messages))
+  (if noninteractive
+      (dun--batch)
+    (pop-to-buffer-same-window "*dungeon*")
+    (dun-mode)
+    (setq dun-dead nil)
+    (setq dun-room 0)
+    (dun-messages)))
 
 ;;;;
 ;;;; This section contains all of the verbs and commands.
@@ -3126,8 +3129,7 @@ File not found")))
   (dun-mprinc "\n")
   (dun-batch-loop))
 
-;;;###autoload
-(defun dun-batch ()
+(defun dun--batch ()
   "Start `dunnet' in batch mode."
   (fset 'dun-mprinc #'dun-batch-mprinc)
   (fset 'dun-mprincl #'dun-batch-mprincl)
@@ -3140,6 +3142,17 @@ File not found")))
   (setq dun-batch-mode t)
   (dun-batch-loop))
 
+;; Apparently, there are many references out there to running us via
+;;
+;;     emacs --batch -l dunnet
+;;
+;; So try and accommodate those without interfering with other cases
+;; where `dunnet.el' might be loaded in batch mode with no intention
+;; to run the game.
+(when (and noninteractive
+           (equal '("-l" "dunnet") (member "-l" command-line-args)))
+  (dun--batch))
+
 (provide 'dunnet)
 
 ;; Local Variables:



reply via email to

[Prev in Thread] Current Thread [Next in Thread]