;;; ess-noweb.el --- support for Literate Data Analysis12;; Copyright (C) 1999 Mark Lunt3;; Copyright (C) 1999--2004 A.J. Rossini, Richard M. Heiberger, Martin4;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.56;; Author: Mark Lunt <[email protected]>7;; A.J. Rossini <[email protected]>8;; Created: April 18, 19999;; Maintainer: ESS-core <[email protected]>1011;; Keywords: statistics, languages12;; Summary: Noweb support for ESS1314;; This file is part of ESS1516;; This file is free software; you can redistribute it and/or modify17;; it under the terms of the GNU General Public License as published by18;; the Free Software Foundation; either version 2, or (at your option)19;; any later version.2021;; This file is distributed in the hope that it will be useful,22;; but WITHOUT ANY WARRANTY; without even the implied warranty of23;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the24;; GNU General Public License for more details.2526;; A copy of the GNU General Public License is available at27;; http://www.r-project.org/Licenses/2829;;; Commentary:3031;; Code for ESS and Literate Data Analysis.3233;;; Code:3435; Requires and autoloads3637(require 'ess-noweb-mode)38;; still needed when user turns font-lock-mode *on* (from initial off):39(autoload 'ess-noweb-font-lock-mode "ess-noweb-font-lock-mode")4041; Variables4243(defvar ess-noweb-use-font-lock font-lock-mode44"Set to t if you want to use font-locking in ESS noweb buffers.")4546;; this helps with XEmacs barfing, sigh...47;; but is *NOT* okay to do *globally*: (setq global-font-lock-mode t)4849(if ess-noweb-use-font-lock50(require 'ess-noweb-font-lock-mode))5152; Functions5354;;*;; Code Chunk evaluation.5556(defun ess-eval-chunk (vis)57"Tangle the current chunk and send it to the inferior ESS process.58Arg has same meaning as for `ess-eval-region'."59(interactive "P")60(let ((process-name ess-local-process-name)61new-process-name62(cbuf (current-buffer))63(temp-buffer (ess-create-temp-buffer "Tangle Buffer")))64(save-excursion65(ess-noweb-tangle-chunk temp-buffer)66(set-buffer temp-buffer)67;; When the temp buffer is created, it does not inherit any value68;; of ess-local-process-name from the .Rnw buffer, so we have to set it69;; here. If ess-local-process-name is not set in the .Rnw buffer,70;; it will inherit the value that is chosen here.71(set (make-local-variable 'ess-local-process-name) process-name)72(ess-eval-region (point-min) (point-max) vis "Eval Chunk")73(if process-name74(kill-buffer temp-buffer)75;; if process-name was nil, source buffer did not have a local process76;; so keep value from temp buffer before killing it.77(setq new-process-name ess-local-process-name)78(kill-buffer temp-buffer)79(set-buffer cbuf)80(set (make-local-variable 'ess-local-process-name) new-process-name)))))818283(defun ess-eval-chunk-and-step (&optional vis)84"Tangle the current chunk and send it to the inferior ESS process and85step to the next chunk"86(interactive)87(ess-eval-chunk vis)88(ess-noweb-next-code-chunk 1))8990(defun ess-eval-chunk-and-go (vis)91"Tangle the current chunk, send to the ESS process, and go there.92Arg has same meaning as for `ess-eval-region'."93(interactive "P")94(ess-eval-chunk vis)95(ess-switch-to-ESS t))9697;;*;; Thread code chunk evaluation9899;;;100;;; Threads are code chunks which fit into the same "buffer" (I'm (AJR)101;;; abusing terminology, but what I mean is things like:102;;; <<thing1>>=103;;; code for thing1104;;; @105;;; Documentation106;;; <<thing1>>=107;;; continuing code for thing1108;;; @109;;;110111(defun ess-eval-thread (vis)112"Tangle all chunks in the current chunk-thread and send to the ESS process.113Arg has same meaning as for `ess-eval-region'."114(interactive "P")115(let ((temp-buffer (ess-create-temp-buffer "Tangle Buffer")))116(ess-noweb-tangle-current-thread temp-buffer)117(set-buffer temp-buffer)118(ess-eval-region (point-min) (point-max) vis "Eval buffer")119(kill-buffer temp-buffer)))120121(defun ess-eval-thread-and-go (vis)122"Tangle all chunks in the current chunk-thread, send to ESS process,123and go there. Arg has same meaning as for `ess-eval-region'."124(interactive "P")125(ess-eval-thread vis)126(ess-switch-to-ESS t))127128; Provide package129130(provide 'ess-noweb)131132; Local variables section133134;;; This file is automatically placed in Outline minor mode.135;;; The file is structured as follows:136;;; Chapters: ^L ;137;;; Sections: ;;*;;138;;; Subsections: ;;;*;;;139;;; Components: defuns, defvars, defconsts140;;; Random code beginning with a ;;;;* comment141142;;; Local variables:143;;; mode: emacs-lisp144;;; outline-minor-mode: nil145;;; mode: outline-minor146;;; outline-regexp: "\^L\\|\\`;\\|;;\\*\\|;;;\\*\\|(def[cvu]\\|(setq\\|;;;;\\*"147;;; End:148149;;; ess-noweb.el ends here150151152