How to run XSB in Emacs

  1. If you work on fissure, most probably Emacs is already customized for XSB. You can check this by starting Prolog ("M-x run-prolog"), loading a file, and trying to consult it (check below for instructions). If all these work fine, you may still want to customize the .emacs file to auto-detect the prolog mode based on the extension of the file you load. If none of these work (especially the run-prolog part, follow the instructions below.
  2. Create a directory called .eprolog in your home directory
  3. Put the file prolog.el in the previously created .eprolog
  4. Add this lines to the file .emacs in your home directory: (modify it to suit your need, you may especially need to change the auto-mode-alist and the load-path)
    ;; make sure emacs can find prolog.el when it goes looking...
    (setq load-path (cons "/Path_to_your_home_directory/.eprolog" load-path))
    ;; tell emacs where to find xsb-mode and prolog-mode
    (autoload 'xsb-mode "prolog" "Major mode for editing XSB programs." t) 
    (autoload 'prolog-mode "prolog" "Major mode for editing Prolog programs." t) 
    ;; uncomment one of these to select your prolog of the month. 
    (setq prolog-program-name "xsb") 
    ;; (setq prolog-program-name "sicstus") 
    ;; tell emacs to enter xsb-mode for a file ending in .P or .H and to
    ;; enter prolog-mode for a file ending in .pl
    (setq auto-mode-alist (mapcar 'purecopy
           '(("\\.c$" . c-mode)
            ("\\.h$" . c++-mode)
            ("\\.cc$" . c++-mode) 
            ("\\.C$" . c++-mode)
            ("Makefile" . makefile-mode)
            ("\\.el$" . emacs-lisp-mode)
            ("\\.emacs$" . emacs-lisp-mode)
            ("\\.a$" . c-mode)
            ("\\.html$" . html-mode)
            ("\\.htm$" . html-mode)
            ("\\.tex$" . latex-mode)
            ("\\.bib$" . bibtex-mode)
            ("\\.p$" . prolog-mode)
            ("\\.P$" . prolog-mode)
            ("\\.pl$" . perl-mode)
            ("\\.lsp$" . lisp-mode))))
    
  5. Run Emacs
  6. Load your file: C-x C-f foo.P
  7. Run xsb: M-x run-prolog
    Note: C means the Control (CTRL) key, M means the Meta key (ALT or ESC, depending on your Linux/Unix)

The basic commands in prolog mode are: Other commands are available from the Menu Bar (both in the buffer that runs prolog and in the buffer with your file).



© Cosmin Munteanu, 2002

The information here was gathered from various sources:
Univ. of Maryland
SICSTUS Prolog
XSB Prolog