;;; essd-jags.el -- ESS[JAGS] dialect ;; Copyright (C) 2008-2009 Rodney Sparapani ;; Original Author: Rodney Sparapani ;; Created: 13 March 2008 ;; Maintainers: ESS-help ;; This file is part of ESS ;; This file is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2, or (at your option) ;; any later version. ;; ;; This file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. ;; ;; In short: you may use this code any way you like, as long as you ;; don't charge money for it, remove this notice, or hold anyone liable ;; for its results. ;; Code: (require 'essl-bugs) (require 'ess-utils) (require 'ess-inf) (setq auto-mode-alist (delete '("\\.[bB][uU][gG]\\'" . ess-bugs-mode) auto-mode-alist)) (setq auto-mode-alist (append '(("\\.[bB][uU][gG]\\'" . ess-jags-mode)) auto-mode-alist)) (defvar ess-jags-command "jags" "Default JAGS program in PATH.") (make-local-variable 'ess-jags-command) (defvar ess-jags-monitor '("") "Default list of variables to monitor.") (make-local-variable 'ess-jags-monitor) (defvar ess-jags-thin 1 "Default thinning parameter.") (make-local-variable 'ess-jags-thin) (defvar ess-jags-chains 1 "Default number of chains.") (make-local-variable 'ess-jags-chains) (defvar ess-jags-burnin 10000 "Default burn-in.") (make-local-variable 'ess-jags-burnin) (defvar ess-jags-update 10000 "Default number of updates after burnin.") (make-local-variable 'ess-jags-update) (defvar ess-jags-system t "Default whether JAGS recognizes the system command.") (defvar ess-jags-font-lock-keywords (list ;; .bug files (cons "#.*\n" font-lock-comment-face) (cons "^[ \t]*\\(model\\|var\\)\\>" font-lock-keyword-face) (cons (concat "\\& " ess-bugs-file-root ".jog ") ;else "> " ess-bugs-file-root ".jog 2>&1 ") ; ;.txt not recognized by BOA and impractical to over-ride ; "&& (rm -f " ess-bugs-file-root ".ind; " ; "ln -s " ess-bugs-file-root "index.txt " ess-bugs-file-root ".ind; " ; "for i in " ess-jags-temp-chains "; do; " ; "rm -f " ess-bugs-file-root "$i.out; " ; "ln -s " ess-bugs-file-root "chain$i.txt " ess-bugs-file-root "$i.out; done) " ess-bugs-batch-post-command) (comint-send-input) ));) (defun ess-jags-na-bug () "ESS[JAGS]: Perform Next-Action for .bug" (if (equal 0 (buffer-size)) (ess-jags-switch-to-suffix ".bug") ;else (ess-save-and-set-local-variables) (ess-jags-switch-to-suffix ".jmd" ess-jags-chains ess-jags-monitor ess-jags-thin ess-jags-burnin ess-jags-update)) ) (defun ess-jags-mode () "ESS[JAGS]: Major mode for JAGS." (interactive) (kill-all-local-variables) (ess-setq-vars-local '((comment-start . "#"))) (setq major-mode 'ess-jags-mode) (setq mode-name "ESS[JAGS]") (use-local-map ess-bugs-mode-map) (setq font-lock-auto-fontify t) (make-local-variable 'font-lock-defaults) (setq font-lock-defaults '(ess-jags-font-lock-keywords nil t)) (run-hooks 'ess-bugs-mode-hook) (if (not (w32-shell-dos-semantics)) (add-hook 'comint-output-filter-functions 'ess-bugs-exit-notify-sh)) ) (setq features (delete 'essd-bugs features)) (provide 'essd-jags)