;;; ess-jags-d.el --- ESS[JAGS] dialect ;; Copyright (C) 2008-2011 Rodney Sparapani ;; Author: Rodney Sparapani ;; Created: 13 March 2008 ;; Maintainer: 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. ;; ;; A copy of the GNU General Public License is available at ;; https://www.r-project.org/Licenses/ ;;; Code: (require 'ess-bugs-l) (require 'ess-utils) (require 'ess-inf) (require 'ess-mode) (setq auto-mode-alist (append '(("\\.[jJ][aA][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 ;; .jag 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 .jag" (if (equal 0 (buffer-size)) (ess-jags-switch-to-suffix ".jag") ;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)) ) ;;;###autoload (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) (make-local-variable 'font-lock-defaults) (setq font-lock-defaults '(ess-jags-font-lock-keywords nil t)) (setq ess-language "S") ; mimic S for ess-smart-underscore (run-mode-hooks 'ess-bugs-mode-hook) (unless (and (fboundp 'w32-shell-dos-semantics) (w32-shell-dos-semantics)) (add-hook 'comint-output-filter-functions 'ess-bugs-exit-notify-sh)) ) ;;;###autoload (add-to-list 'auto-mode-alist '("\\.[Jj][Aa][Gg]\\'" . ess-jags-mode)) (defvaralias 'ess-jags-mode-hook 'ess-bugs-mode-hook) (defvaralias 'ess-jags-mode-map 'ess-bugs-mode-map) (setq features (delete 'ess-bugs-d features)) (provide 'ess-jags-d) ;;; ess-jags-d.el ends here