;;; ess-bugs-d.el --- ESS[BUGS] 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-custom) (require 'ess-mode) (setq auto-mode-alist (append '(("\\.[bB][uU][gG]\\'" . ess-bugs-mode)) auto-mode-alist)) (defvar ess-bugs-command "OpenBUGS" "Default BUGS program in PATH.") (make-local-variable 'ess-bugs-command) (defvar ess-bugs-monitor '("") "Default list of variables to monitor.") (make-local-variable 'ess-bugs-monitor) (defvar ess-bugs-thin 1 "Default thinning parameter.") (make-local-variable 'ess-bugs-thin) (defvar ess-bugs-chains 1 "Default number of chains.") (make-local-variable 'ess-bugs-chains) (defvar ess-bugs-burnin 10000 "Default burn-in.") (make-local-variable 'ess-bugs-burnin) (defvar ess-bugs-update 10000 "Default number of updates after burnin.") (make-local-variable 'ess-bugs-update) (defvar ess-bugs-system nil "Default whether BUGS recognizes the system command.") (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-root ".bog 2>&1 " ;; ess-bugs-batch-post-command "' > " ess-bugs-file-root ".bsh") ;; (comint-send-input) ;; (insert "at -f " ess-bugs-file-root ".bsh now") ;; (comint-send-input) (insert "echo '" ess-bugs-batch-pre-command " " bugs-command " < " ess-bugs-file-root ".bmd > " ess-bugs-file-root ".bog 2>&1 " ess-bugs-batch-post-command "' | at now") (comint-send-input) )) (defun ess-bugs-na-bug () "ESS[BUGS]: Perform Next-Action for .bug" (if (equal 0 (buffer-size)) (ess-bugs-switch-to-suffix ".bug") ;else (ess-save-and-set-local-variables) (ess-bugs-switch-to-suffix ".bmd" ess-bugs-chains ess-bugs-monitor ess-bugs-thin ess-bugs-burnin ess-bugs-update)) ) ;;;###autoload (defun ess-bugs-mode () "ESS[BUGS]: Major mode for BUGS." (interactive) (kill-all-local-variables) (ess-setq-vars-local '((comment-start . "#"))) (setq major-mode 'ess-bugs-mode) (setq mode-name "ESS[BUGS]") (use-local-map ess-bugs-mode-map) (make-local-variable 'font-lock-defaults) (setq font-lock-defaults '(ess-bugs-font-lock-keywords nil t)) (setq ess-language "S") ; mimic S for ess-smart-underscore (run-mode-hooks 'ess-bugs-mode-hook) (unless (when (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 '("\\.[Bb][Uu][Gg]\\'" . ess-bugs-mode)) ;;;###autoload (add-to-list 'auto-mode-alist '("\\.[Bb][Oo][Gg]\\'" . ess-bugs-mode)) ;;;###autoload (add-to-list 'auto-mode-alist '("\\.[Bb][Mm][Dd]\\'" . ess-bugs-mode)) (defun ess-sci-to-dec () "For BUGS/S family: Express +/-0.000E+/-0 or +/-0.0e+/-00 as a decimal." (interactive) (setq buffer-read-only nil) (save-excursion (goto-char 0) (save-match-data (let ((ess-temp-replacement-string nil) (ess-temp-replacement-9 0) (ess-temp-replacement-diff 0)) (while (search-forward-regexp "-?[0-9][.][0-9][0-9]?[0-9]?[Ee][+-][0-9][0-9]?" nil t) (setq ess-temp-replacement-string (int-to-string (string-to-number (match-string 0)))) (setq ess-temp-replacement-diff (- (match-end 0) (match-beginning 0))) (save-match-data (setq ess-temp-replacement-9 (string-match "99999999999$" ess-temp-replacement-string)) (if (not ess-temp-replacement-9) (setq ess-temp-replacement-9 (string-match "000000000001$" ess-temp-replacement-string)))) (if ess-temp-replacement-9 (setq ess-temp-replacement-string (substring ess-temp-replacement-string 0 ess-temp-replacement-9))) (setq ess-temp-replacement-diff (- ess-temp-replacement-diff (string-width ess-temp-replacement-string))) (while (> ess-temp-replacement-diff 0) (setq ess-temp-replacement-string (concat ess-temp-replacement-string " ")) (setq ess-temp-replacement-diff (- ess-temp-replacement-diff 1))) (replace-match ess-temp-replacement-string)))))) (setq features (delete 'ess-bugs-d features)) (provide 'ess-bugs-d) ;;; ess-bugs-d.el ends here