Klimi's new dotfiles with stow.
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

138 linhas
4.3 KiB

há 5 anos
  1. ;;; ess-noweb.el --- support for Literate Data Analysis
  2. ;; Copyright (C) 1999 Mark Lunt
  3. ;; Copyright (C) 1999--2004 A.J. Rossini, Richard M. Heiberger, Martin
  4. ;; Maechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.
  5. ;; Author: Mark Lunt <mark.lunt@mrc-bsu.cam.ac.uk>
  6. ;; A.J. Rossini <rossini@u.washington.edu>
  7. ;; Created: April 18, 1999
  8. ;; Maintainer: ESS-core <ESS-core@r-project.org>
  9. ;; Keywords: statistics, languages
  10. ;; Summary: Noweb support for ESS
  11. ;; This file is part of ESS
  12. ;; This file is free software; you can redistribute it and/or modify
  13. ;; it under the terms of the GNU General Public License as published by
  14. ;; the Free Software Foundation; either version 2, or (at your option)
  15. ;; any later version.
  16. ;; This file is distributed in the hope that it will be useful,
  17. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. ;; GNU General Public License for more details.
  20. ;; A copy of the GNU General Public License is available at
  21. ;; https://www.r-project.org/Licenses/
  22. ;;; Commentary:
  23. ;; Code for ESS and Literate Data Analysis.
  24. ;;; Code:
  25. ; Requires and autoloads
  26. (require 'ess-custom)
  27. (require 'ess-inf)
  28. (require 'ess-noweb-mode)
  29. ; Variables
  30. (defvar ess-noweb-use-font-lock font-lock-mode
  31. "Set to t if you want to use font-locking in ESS noweb buffers.")
  32. (if ess-noweb-use-font-lock
  33. (require 'ess-noweb-font-lock-mode))
  34. ; Functions
  35. ;;*;; Code Chunk evaluation.
  36. (defun ess-noweb-create-tangle-buffer (name)
  37. (let ((buff (get-buffer-create name))
  38. (elca (eval ess-local-customize-alist)))
  39. (with-current-buffer buff
  40. (erase-buffer)
  41. (ess-setq-vars-local elca buff))
  42. buff))
  43. (defun ess-eval-chunk (vis)
  44. "Tangle the current chunk and send it to the inferior ESS process.
  45. Arg has same meaning as for `ess-eval-region'."
  46. (interactive "P")
  47. (let ((process-name ess-local-process-name)
  48. new-process-name
  49. (cbuf (current-buffer))
  50. (temp-buffer (ess-noweb-create-tangle-buffer "Tangle Buffer")))
  51. (save-excursion
  52. (ess-noweb-tangle-chunk temp-buffer)
  53. (set-buffer temp-buffer)
  54. ;; When the temp buffer is created, it does not inherit any value
  55. ;; of ess-local-process-name from the .Rnw buffer, so we have to set it
  56. ;; here. If ess-local-process-name is not set in the .Rnw buffer,
  57. ;; it will inherit the value that is chosen here.
  58. (set (make-local-variable 'ess-local-process-name) process-name)
  59. (ess-eval-region (point-min) (point-max) vis "Eval Chunk")
  60. (if process-name
  61. (kill-buffer temp-buffer)
  62. ;; if process-name was nil, source buffer did not have a local process
  63. ;; so keep value from temp buffer before killing it.
  64. (setq new-process-name ess-local-process-name)
  65. (kill-buffer temp-buffer)
  66. (set-buffer cbuf)
  67. (set (make-local-variable 'ess-local-process-name) new-process-name)))))
  68. (defun ess-eval-chunk-and-step (&optional vis)
  69. "Tangle the current chunk and send it to the inferior ESS process and
  70. step to the next chunk"
  71. (interactive)
  72. (ess-eval-chunk vis)
  73. (ess-noweb-next-code-chunk 1))
  74. (defun ess-eval-chunk-and-go (vis)
  75. "Tangle the current chunk, send to the ESS process, and go there.
  76. Arg has same meaning as for `ess-eval-region'."
  77. (interactive "P")
  78. (ess-eval-chunk vis)
  79. (ess-switch-to-ESS t))
  80. ;;*;; Thread code chunk evaluation
  81. ;;
  82. ;; Threads are code chunks which fit into the same "buffer" (I'm (AJR)
  83. ;; abusing terminology, but what I mean is things like:
  84. ;; <<thing1>>=
  85. ;; code for thing1
  86. ;; @
  87. ;; Documentation
  88. ;; <<thing1>>=
  89. ;; continuing code for thing1
  90. ;; @
  91. ;;
  92. (defun ess-eval-thread (vis)
  93. "Tangle all chunks in the current chunk-thread and send to the ESS process.
  94. Arg has same meaning as for `ess-eval-region'."
  95. (interactive "P")
  96. (let ((temp-buffer (ess-noweb-create-tangle-buffer "Tangle Buffer")))
  97. (ess-noweb-tangle-current-thread temp-buffer)
  98. (set-buffer temp-buffer)
  99. (ess-eval-region (point-min) (point-max) vis "Eval buffer")
  100. (kill-buffer temp-buffer)))
  101. (defun ess-eval-thread-and-go (vis)
  102. "Tangle all chunks in the current chunk-thread, send to ESS process,
  103. and go there. Arg has same meaning as for `ess-eval-region'."
  104. (interactive "P")
  105. (ess-eval-thread vis)
  106. (ess-switch-to-ESS t))
  107. ; Provide package
  108. (provide 'ess-noweb)
  109. ;;; ess-noweb.el ends here