[PATCH] Add Bochs to the supported emulators in movitz-slime.el

Yoni Rabkin <[email protected]> Sun, 20 Jul 2008 20:20:53 +0300
Newsgroups gmane.lisp.movitz.devel
Message-ID <[email protected]>
--=-=-=


This allows running Bochs with "C-c C-d" using movitz-slime.el.


--=-=-=
Content-Type: text/x-diff
Content-Disposition: inline; filename=movitz-slime-add-bochs-support.patch
Content-Description: Add Bochs to movitz-slime.el

Index: movitz-slime.el
===================================================================
RCS file: /project/movitz/cvsroot/movitz/ide/movitz-slime.el,v
retrieving revision 1.8
diff -u -r1.8 movitz-slime.el
--- movitz-slime.el	7 Jun 2008 13:00:08 -0000	1.8
+++ movitz-slime.el	20 Jul 2008 17:11:14 -0000
@@ -2,6 +2,9 @@
 
 ;; 2004, Written by Luke Gorrie <[email protected]> and placed in
 ;;       the public domain.
+;;
+;; 2007, 2008, Yoni Rabkin <[email protected]>, placed in the
+;;             public domain.
 
 ;;; Commentary:
 ;;
@@ -20,11 +23,19 @@
 ;; Load this mode by adding the location of this file to your
 ;; load-path and invoking (require 'movitz-slime).
 ;;
+;; In order to run an emulator, set `movitz-mode-emulator' to either
+;; 'qemu or 'bochs, appropriately.
+;;
 ;; If you use QEMU under GNU/Linux, you should probably also set the
 ;; following to some same value, for example:
 ;; 
 ;; (setq movitz-mode-qemu-binary-path "/usr/bin/qemu")
 ;; (setq movitz-mode-qemu-directory "/usr/share/qemu/")
+;;
+;; The equivalent variable for Bochs is
+;; `movitz-mode-bochs-binary-path'.
+
+;;; Code:
 
 (require 'slime)
 (require 'cl)
@@ -49,11 +60,21 @@
   :type 'string
   :group 'movitz)
 
+(defcustom movitz-mode-emulator 'qemu
+  "*Which emulator to run."
+  :type 'symbol
+  :group 'movitz)
+
 (defcustom movitz-mode-qemu-binary-path "c:/progra~1/qemu/qemu"
   "*Location of the QEMU binary."
   :type 'string
   :group 'movitz)
 
+(defcustom movitz-mode-bochs-binary-path "/usr/local/bin/bochs"
+  "*Location of the Bochs binary."
+  :type 'string
+  :group 'movitz)
+
 (defcustom movitz-mode-qemu-directory "c:/progra~1/qemu/qemu"
   "*Location for the QEMU -L option."
   :type 'string
@@ -180,15 +201,23 @@
   (message "Dumping '%s'.." movitz-mode-image-file)
   (slime-eval-async `(movitz.ide:dump-image ,(file-name-nondirectory movitz-mode-image-file))
 		    (if run-emulator
-			;; choose emulator here, currently only qemu
-			(lambda (_)
-			  (message "Dumping '%s'..done, starting qemu" movitz-mode-image-file)
-			  (call-process movitz-mode-qemu-binary-path
-					nil 0 nil
-					"-s"
-					"-L" movitz-mode-qemu-directory
-					"-fda" movitz-mode-image-file
-					"-boot" "a"))	
+			(cond ((eq movitz-mode-emulator 'qemu)
+			       (lambda (_)
+				 (message "Dumping '%s'..done, starting qemu" 
+					  movitz-mode-image-file)
+				 (call-process movitz-mode-qemu-binary-path
+					       nil 0 nil
+					       "-s"
+					       "-L" movitz-mode-qemu-directory
+					       "-fda" movitz-mode-image-file
+					       "-boot" "a")))
+			      ((eq movitz-mode-emulator 'bochs)
+			       (lambda (_)
+				 (message "Dumping '%s'..done, starting Bochs" 
+					  movitz-mode-image-file)
+				 (call-process movitz-mode-bochs-binary-path nil 0 nil 
+					       "-q")))
+			      (t (error "unsupported emulator %S" movitz-mode-emulator)))
 		      (lambda (_) (message "Dumping '%s'..done" movitz-mode-image-file)))))
 
 (defun movitz-defun-name-and-type ()

--=-=-=


-- 
   "Cut your own wood and it will warm you twice"

--=-=-=
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline