]> git.donarmstrong.com Git - lib.git/commitdiff
add ess configuration and remote eval
authorDon Armstrong <don@donarmstrong.com>
Sun, 5 Oct 2014 05:31:49 +0000 (22:31 -0700)
committerDon Armstrong <don@donarmstrong.com>
Sun, 5 Oct 2014 05:31:49 +0000 (22:31 -0700)
emacs_el/configuration/ess_configuration.el [new file with mode: 0644]
emacs_el/configuration/ess_remote_eval.el [new file with mode: 0644]

diff --git a/emacs_el/configuration/ess_configuration.el b/emacs_el/configuration/ess_configuration.el
new file mode 100644 (file)
index 0000000..4547c5b
--- /dev/null
@@ -0,0 +1,24 @@
+(defun ess-change-directory (path)
+  "Set the current working directory to PATH for both *R* and Emacs."
+  (interactive "DDirectory to change to: ")
+
+  (when (file-exists-p path)
+    (ess-command (concat "setwd(\"" path "\")\n"))
+    ;; use file-name-as-directory to ensure it has trailing /
+    (setq default-directory (file-name-as-directory path))))
+(add-hook 'ess-mode-hook 'flyspell-prog-mode)
+;;; outlining support for ess modes
+(add-hook 'ess-mode-hook
+      '(lambda ()
+         (outline-minor-mode)
+         (setq outline-regexp "\\(^#\\{4,5\\} \\)\\|\\(^[a-zA-Z0-9_\.]+ ?<- ?function\\)")
+         (defun outline-level ()
+           (cond ((looking-at "^##### ") 1)
+             ((looking-at "^#### ") 2)
+             ((looking-at "^[a-zA-Z0-9_\.]+ ?<- ?function(.*{") 3)
+             (t 1000)))
+         ))
+(add-hook 'ess-mode-hook
+          '(lambda ()
+             (local-set-key (kbd "C-c C-r")
+                            dla/ess-eval-region)))
diff --git a/emacs_el/configuration/ess_remote_eval.el b/emacs_el/configuration/ess_remote_eval.el
new file mode 100644 (file)
index 0000000..c70e9a7
--- /dev/null
@@ -0,0 +1,7 @@
+(defun dla/ess-region-remote-eval (start end)
+  "Evaluate region in a remote ESS instance"
+  (interactive "r")
+  (shell-command-on-region start end "eval_r" (get-buffer-create "***essregionremoteeval***"))
+  (kill-buffer "***essregionremoteeval***")
+)
+