commit b3bf4a1f25ee371604589483c82b7bd27c177a97
parent 934b231183b28be4d7c49e7bf1ef3d80fad34f15
Author: Shimmy Xu <shimmy.xu@shimmy1996.com>
Date: Tue, 16 Apr 2019 00:07:53 -0400
Add keybinding for user/r-format-buffer.
Diffstat:
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/README.org b/README.org
@@ -886,13 +886,16 @@ Use the =styler= R package to format buffer or region. Modeled after =yapfify=.
(user/r-format-region (point-min) (point-max)))
#+END_SRC
-Auto format on save for =ess-r-mode=.
+Auto format bindings for =ess-r-mode=. Need a keybinding as auto formatting doesn't seem to work for org-mode =src= blocks.
#+BEGIN_SRC emacs-lisp
(defun user/r-format-before-save ()
"Runs r-format on current buffer if in ess-r-mode."
(interactive)
(when (eq major-mode 'ess-r-mode) (user/r-format-buffer)))
+ (add-hook 'ess-r-mode-hook
+ (lambda () (local-set-key (kbd "C-u") 'user/r-format-buffer)))
+
(add-hook 'before-save-hook 'user/r-format-before-save)
#+END_SRC