;;; essd-jags.el -- ESS[JAGS] dialect ;; Copyright (C) 2006-2008 Rodney Sparapani ;; Original Author: Rodney Sparapani ;; Created: 16 August 2006 ;; 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") (make-local-variable 'ess-jags-command) (defvar ess-jags-monitor '("")) (make-local-variable 'ess-jags-monitor) (defvar ess-jags-thin 1) (make-local-variable 'ess-jags-thin) (defvar ess-jags-chains 1) (make-local-variable 'ess-jags-chains) (defvar ess-jags-global-monitor nil) (defvar ess-jags-global-chains nil) (defvar ess-bugs-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-dir ess-bugs-file-root ".out ") (concat " > " ess-bugs-file-dir ess-bugs-file-root ".out 2>&1 ")) (concat ess-bugs-batch-post-command)) (comint-send-input) ) (defun ess-bugs-na-bug () "ESS[JAGS]: Perform Next-Action for .bug" (if (equal 0 (buffer-size)) (ess-bugs-switch-to-suffix ".bug") ;else (ess-save-and-set-local-variables) (setq ess-jags-global-chains (concat "compile, nchains(" (format "%d" ess-jags-chains) ")\n")) (while (< 0 ess-jags-chains) (setq ess-jags-global-chains (concat ess-jags-global-chains "parameters ## \"" ess-bugs-file-dir ess-bugs-file-root ".##" (format "%d" ess-jags-chains) "\", chain(" (format "%d" ess-jags-chains) ")\n")) (setq ess-jags-chains (- ess-jags-chains 1))) (setq ess-jags-global-monitor nil) (while (and (listp ess-jags-monitor) (consp ess-jags-monitor)) (setq ess-jags-global-monitor (concat ess-jags-global-monitor "monitor " (car ess-jags-monitor) ", thin(" (format "%d" ess-jags-thin) ")\n")) (setq ess-jags-monitor (cdr ess-jags-monitor))) (ess-bugs-switch-to-suffix ".jmd")) ) (defun ess-jags-mode () "ESS[JAGS]: Major mode for JAGS." (interactive) (kill-all-local-variables) (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-bugs-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)