Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dot emacs #1

Open
JWiley opened this issue Oct 2, 2021 · 3 comments
Open

dot emacs #1

JWiley opened this issue Oct 2, 2021 · 3 comments

Comments

@JWiley
Copy link

JWiley commented Oct 2, 2021

This presentation on setting up and using rmarkdown is very helpful.
It would be wonderful if there could be an example or link to a .emacs file that would automatically install and set everything up.
I have something like this, but it was completely hacked together without a real understanding of what/how I'm doing it and I'm afraid is wrong.

;; repos
(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(column-number-mode t)
 '(completion-ignore-case t t)
 '(cursor-type 'bar)
 '(ess-R-font-lock-keywords
   '((ess-R-fl-keyword:keywords . t)
     (ess-R-fl-keyword:constants . t)
     (ess-R-fl-keyword:modifiers . t)
     (ess-R-fl-keyword:fun-defs . t)
     (ess-R-fl-keyword:assign-ops . t)
     (ess-R-fl-keyword:%op% . t)
     (ess-fl-keyword:fun-calls . t)
     (ess-fl-keyword:numbers . t)
     (ess-fl-keyword:operators . t)
     (ess-fl-keyword:delimiters . t)
     (ess-fl-keyword:= . t)
     (ess-R-fl-keyword:F&T . t)))
 '(global-hl-line-mode t)
 '(inferior-R-args "--no-restore --no-save")
 '(inferior-R-program-name "c:/usr/R/R-4.1.0/bin/x64/Rterm.exe")
 '(inferior-ess-r-program "c:/usr/R/R-4.1.0/bin/x64/Rterm.exe")
 '(inhibit-startup-screen t)
 '(ispell-program-name "c:/usr/hunspell/bin/hunspell.exe")
 '(markdown-command "C:/usr/Pandoc/pandoc.exe")
 '(package-archives '(("melpa" . "https://melpa.org/packages/")))
 '(package-selected-packages
   '(flycheck color-theme-sanityinc-tomorrow ess treemacs-persp treemacs-magit treemacs-icons-dired treemacs-projectile treemacs yasnippet poly-R poly-markdown markdown-mode magit projectile company helm wc-mode diminish smooth-scrolling use-package))
 '(read-buffer-completion-ignore-case t)
 '(read-file-name-completion-ignore-case t)
 '(send-mail-function 'mailclient-send-it))

;; use-package to auto get packages
(package-initialize)
(when (not package-archive-contents)
  (package-refresh-contents))
(when (not (package-installed-p 'use-package))
  (package-install 'use-package))
(require 'use-package)


;; markdown mode
(use-package markdown-mode
  :ensure t
  :mode ("README\\.md\\'" . gfm-mode)
  :init (setq markdown-command "multimarkdown"))

;; various polymode
(use-package polymode
  :ensure t)

;; sufficient for R + markdown?
(use-package poly-R
  :ensure t)

;; associate the new polymode to Rmd files:
(add-to-list 'auto-mode-alist
             '("\\.[rR]md\\'" . poly-gfm+r-mode))

;; uses braces around code block language strings:
(setq markdown-code-block-braces t)

;; emacs speaks statistics --- central to using R in Emacs!
(use-package ess
  :ensure t
  :config
  ;; RStudio style, like only 2 spaces for indent
  (add-hook 'ess-mode-hook
            (lambda ()
              (ess-set-style 'RStudio)))
  :custom
  (ess-ask-for-ess-directory . nil))

;; only R features, not all ESS by default
(require 'ess-r-mode)

@eddelbuettel
Copy link
Member

That is a good plan, I just wonder how to go about it. Should we ask ess-help / the ESS team to "minimize" it?

@plantarum
Copy link
Member

Thanks for your interest!

As far as this individual tutorial goes, I intend it to be completely self-contained. All the configuration necessary to use every feature I cover is included in the tutorial itself. I test this explicitly, and if you find something doesn't work as advertised, it's a bug and I want to hear about it, so I can fix it.

For the record, the necessary configuration is:

(add-to-list 'auto-mode-alist '("\\.[rR]md\\'" . poly-gfm+r-mode))
(setq markdown-code-block-braces t)

I delayed recording my demo until I was able to submit patches to markdown-mode and poly-R mode that allowed me to eliminate most of the config that was required in the first draft.

This assumes the listed prerequisites are met. These are also listed in the tutorial. I don't explain how to install Emacs packages, but do point to the previous tutorial for those details: https://github.com/ess-intro/presentation-ess-base-install/blob/master/ess-installation.Rmd. Ideally we'll have fixed links to these tutorials, but I'm not sure they have a permanent home yet?

As for having a more comprehensive config template, I have mixed feelings about it. It would be a great resource, no question. But also difficult to find the sweet spot between simple enough to be easily maintainable, and modified by users without breakage; and thorough enough to not become completely redundant once a user understands the basics.

My hope for these tutorials (and I think Dirk's original intent?) is that they provide bite-sized lessons on how to use, and install/configure, a particular feature. They won't (individually) be comprehensive, but they should break down the material into small enough stand-alone chunks that an interested user can learn what they need in about five minutes (plus or minus 10 minutes), and add code they understand to their own configuration.

@JWiley
Copy link
Author

JWiley commented Oct 3, 2021

@plantarum Thanks for the detailed reply. Your approach and intent makes sense.

If there were a comprehensive config template, I would suggest

-- support for R (ESS)
-- Rmarkdown
-- argument names / tab completion (eg company)
-- syntax checking (eg flycheck and lintr)
-- spell check for the text part of Rmarkdown files
-- git integration (eg magit)
-- object buffer (eg rdired)
-- data viewer (eg ess-view-data, which I've gotten kind of working, but I wanted to use data.table but I'm not savvy enough to understand how to set the customization)

these could all be turned on for .R, .Rmd, and .Rnw files, which would give a comprehensive out of box experience.

In terms of maintenance / workload, if one of your or the ESS gurus has a dot emacs that does much of that, that could just be shared and made a "recommended" example?

I'd also be happy to contribute mine and keep it up to date with comments and a video explaining the purpose of each part + how to add a dot emacs / init.el file. I suspect I've done some silly / redundant things in mine, but it seems not to give errors on the few systems I've tried it on.

Also, feel free to close this issue. I don't want to stop dialogue if you want to continue it, but also think we are probably off the topic of your Rmarkdown presentation, as this would be a separate one if done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants