Coder Social home page Coder Social logo

poly-r's Introduction

License GPL 3 MELPA MELPA Stable

Polymodes for the R language:

  • poly-noweb+R-mode
  • poly-markdown+R-mode
  • poly-rapport-mode
  • poly-html+R-mode
  • poly-brew+R-mode
  • poly-R+C++-mode
  • poly-C++R-mode
  • poly-ess-help+R-mode
  • poly-Rd-mode

Weavers:

  • knitr
  • knitr-ESS
  • `Sweave-ESS
  • Sweave

Exporters:

  • Rmarkdown
  • Rmarkdown-ESS
  • Rbookdown-ESS
  • Shiny
  • Shiny-ESS

RMarkdown templates available through ESS menus and on M-n M-m in Rmd files (poly-r-rmarkdown-create-from-template):

poly-r's People

Contributors

lionel- avatar plantarum avatar vspinu avatar wmay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

poly-r's Issues

error on startup: poly-R/:catch: Symbol’s value as variable is void: poly-noweb-innermode

I've been using poly-R for months but upon the latest update I cannot get it to load properly. I've tried two strategies for loading:

(use-package poly-R
:ensure t)

Which results in the error:

poly-R/:catch: Symbol’s value as variable is void: poly-noweb-innermode

I then tried to be more explicit about the load paths, by doing:

(use-package polymode
:ensure t
:pin melpa-stable
:init
(setq load-path
(append '("/.emacs.d/elpa/polymode-20190508.1847/"
"
/.emacs.d/elpa/polymode-20190508.1847/modes"
"/.emacs.d/elpa/polymode-20190508.1847/modes/poly-R"
"
/.emacs.d/elpa/polymode-20190508.1847/modes/poly-org"
"/.emacs.d/elpa/polymode-20190508.1847/modes/poly-noweb"
"
/.emacs.d/elpa/polymode-20190508.1847/modes/poly-markdown"
) load-path))
(require 'poly-R)
(require 'poly-markdown)
(require 'poly-noweb)
(require 'poly-org))

Which results in the same error. Any idea what the problem might be? Sorry that this is very similar to the last posted issue but I've been unable to find a fix.

RMarkdown template menu population so slow making emacs menu system unusable

I find poly-r-rmarkdown-templates-menu takes so long to build them menu items with the dozens of available templates (order 5 seconds, in my hands at least), and apparently has to be repopulated on every menubar selection, thus making all menus unusable.

My workaround is to redefine the menu in my init.el as follows:

(easy-menu-define poly-markdown+R-menu (list ess-mode-map
							 inferior-ess-mode-map
							 poly-markdown+r-mode-map)
	      "Menu for poly-r+markdown-mode"
	      '("RMarkdown"
		("Templates - too slow! Disabled in your init.el!"
		 ;;:active (ess-get-next-available-process "R" t)
		 :filter ignore)))

Could the results be computed once, asynchronously, and cached (possible for each different installation of R it is used with)?

poly-R start up error

I'm testing poly-R using make start (thanks it's very convenient), and when I create/open an .Rmd file I met this error:

Entering debugger...
File mode specification error: (wrong-type-argument eieio-object #s(pm-polymode #s(pm-polymode unbound poly-markdown-polymode nil poly-markdown-hostmode (poly-markdown-fenced-code-innermode poly-markdown-displayed-math-innermode poly-markdown-inline-math-innermode poly-markdown-yaml-metadata-innermode) (pm-exporter/pandoc) nil (poly-r-knitr-ess-weaver poly-r-knitr-weaver) nil nil polymode-minor-mode-map nil poly-markdown-mode unbound nil nil nil) poly-markdown+r-polymode unbound unbound (:inherit poly-r-markdown-inline-code-innermode) (poly-r-shiny-ess-exporter poly-r-shiny-exporter poly-r-bookdown-ess-exporter poly-r-markdown-exporter poly-r-markdown-ess-exporter) unbound unbound unbound unbound unbound unbound poly-markdown+r-mode unbound unbound unbound unbound) obj)

From the terminal:

(master) % make start                                                                             ~/.emacs.d/straight/repos/poly-R
EMACS VERSION: 26.3
GIT HEAD: 0443c89
emacs -Q -L . -L modes -L tests -L .ELPA/26.3 --batch --load targets/melpa.el
Importing package-keyring.gpg...
Importing package-keyring.gpg...done
Contacting host: melpa.org:443
Contacting host: melpa.org:443
Package refresh done
INSTALLED DEPS: ess:(20191014 1343) polymode:(20190714 2017) poly-markdown:(20190916 702) poly-noweb:(20190605 2102)
emacs -Q -L . -L modes -L tests -L .ELPA/26.3 -L . \
	--load targets/melpa-init.el \
	--load tests/*.el

Am I missing something? I'm running on Linux.

template menu not populated

Hi,

I think my problem may be related to #6. After opening an .Rmd file, and starting an R process via M-x R, the RMarkdown menu shows a single entry for "Templates", but there's nothing else listed there.

I installed the tufte package in R to make sure I had some templates that should be available. That didn't change anything. I tried to run the function poly-r-rmarkdown-templates by hand, and got the following error:

Error: Timeout during background ESS command ’local({list_templates <- function(user_dirs) {    user_dirs <- c(user_dirs, unlist(lapply(user_dirs, list.dirs, recursive = FALSE)))    list_from_dir <- function(dir, pkg = NULL) {      pkg_name <- if(is.null(pkg)) 'USER' else pkg      if (dir.exists(dir)) {        dirs <- list.dirs(dir, recursive = FALSE)        for (d in dirs) {          yaml_file <- file.path(d, 'template.yaml')          if (file.exists(yaml_file)) {            yaml <- yaml::yaml.load(readLines(yaml_file, encoding = 'UTF-8'))            if (is.null(desc <- yaml$description)) desc <- 'nil'            if (!is.null(pkg)) d <- basename(d)            cat(sprintf('("%s" "%s" "%s" "%s")', pkg_name, d, yaml$name, desc))          }        }      }    }    cat('(')    for (user_dir in user_dirs) {      files <- list.files(user_dir,  '\\.[Rr]md$', full.names = TRUE)      for (f in files) {        name <- sub('\\.[^.]+$','', basename(f))        cat(sprintf('("USER" "%s" "%s")', f, name))      }      list_from_dir(user_dir)    }    packages <- sort(unlist(lapply(.libPaths(), dir)))    for (pkg in packages) {      template_folder <- system.file('rmarkdown', 'templates', package = pkg)      list_from_dir(template_folder, pkg)    }    cat(')')  }list_templates(c())})’

Is there something else I need to do to configure templates, or is there a bug in poly-R?

I'm using poly-R from MELPA, which appears to match the latest commit to the repo: 20200316.1315 (melpa).

Emacs version 28.0.50, compiled form source

R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out", from Ubuntu repositories

How to change to latex-mode in math enviroments

Hi!

In a Rmd file normally I use full environments like equation, align, etc.

However, if I write one of these environments into a Rmd file, and I put the cursor inside, the mode of the file keeps in markdown-mode (or Rmarkdown).

What is the configuration to make this work?

Best.

File mode specification error: (void-variable keymap)

I'm getting this error from poly-R when I try to load it. I'm using the below configuration, which I slightly abbreviated by removing some custom functions.

(use-package polymode
  :defer t
  :ensure t)

(use-package poly-R
  :defer t
  :after polymode
  :ensure t)

(use-package poly-markdown
  :defer t
  :after polymode
  :mode
  ("\\.Rmd\\'" . poly-markdown+R-mode)
  :ensure t)

Losing track of org buffer with smartparens

Not sure if this is a poly-R, poly-org or smartparens issue. With smartparens on, when leaving an R block in a org file, emacs can fail to switch from ESS mode to org mode. This error message appears in the minibuffer: "(pm-switch-to-buffer 62): Wrong type argument: number-or-marker-p, nil"

I can reproduce this with this org file:
`
Test poly org with R.

#+begin_src R

x <- 1:3

#+end_src
`

  1. Turn on smartparens
  2. Move point to # character in #+end_src (i.e. beginning of line)
  3. Type character 'd', then backspace (just deleting the typed character)
  4. Move point up one line (into R block) then down two lines (out of R block)

At this point the error message appears in the minibuffer and instead of being in org-mode, emacs remains in ESS mode.

I have removed all customizations and only have the following in my init.el file:
`
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/"))
(add-to-list 'package-archives
'("org" . "https://orgmode.org/elpa/"))
(setq package-enable-at-startup nil)
(package-initialize)

(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))

(require 'use-package)
(require 'bind-key)
(use-package smartparens
:ensure t)
(use-package poly-org
:ensure t)
(load-theme 'spacemacs-dark t)
`

error at startup

I think modes have been renamed in ess and now poly-R fails to load:

Error (use-package): poly-R/:catch: Symbol’s value as variable is void: ess-mode-map

Eglot slow down polymode

I use a polymode for python in latex mode however when eglot is also enabled every time I type something in a python chunk, it seems like a new eglot instance is launched and then typing becomes really slow (hangs for 2~3 seconds every time I type something).

This seems linked to #34
(setq polymode-lsp-integration nil) did not do anything. Nor did

  (add-to-list 'polymode-run-these-after-change-functions-in-other-buffers 'eglot--after-change)
  (add-to-list 'polymode-run-these-before-change-functions-in-other-buffers 'eglot--before-change)

suggested in here: joaotavora/eglot#1229

As a first approach, is there a way to disable eglot in inner chuncks? Maybe a hook with elglot-shutdown-all ? I tried to add (elglot-shutdown-all) to the init functions of the inner mode (e.g. python) but it did not work.

For now, I am launching polymode and then I am typing in M-x eglot-shutdown-all. It works but this is very non-optimal: not automatic and ideally I would prefer to keep eglot.

poly-r fails to load when using `straight.el`

poly-r can't be loaded when using straight.el for installations.

Error output when trying to require poly-r:

Error (use-package): poly-r/:catch: Loading file /Users/ks/.emacs.d/straight/build/poly-r/poly-r.elc failed to provide feature ‘poly-r’ 

I am not quite sure if this is a problem with poly-r or straight..

Fontification error Rmd files

I am greeted with this error when I open an .Rmd file.

Debugger entered--Lisp error: (wrong-type-argument characterp nil)
  tex--prettify-symbols-compose-p(16 22 #("\\gamma" 0 5 (fontified nil :pm-span (body 3 22 #s(pm-inner-chunkmode #s(pm-inner-chunkmode #s(pm-inner-chunkmode unbound "markdown-root" nil nil host t 2 0 0 t t t 2 nil nil nil nil 0 nil nil host host unbound unbound bold nil nil nil) "markdown-inline-math" unbound latex-mode unbound nil unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound poly-markdown-inline-math-head-matcher poly-markdown-inline-math-tail-matcher unbound unbound unbound unbound) "markdown-inline-math:" unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound #<buffer  test.Rmd[latex]> unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound)) :pm-mode latex-mode) 5 6 (fontified nil :pm-span (body 3 22 #s(pm-inner-chunkmode #s(pm-inner-chunkmode #s(pm-inner-chunkmode unbound "markdown-root" nil nil host t 2 0 0 t t t 2 nil nil nil nil 0 nil nil host host unbound unbound bold nil nil nil) "markdown-inline-math" unbound latex-mode unbound nil unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound poly-markdown-inline-math-head-matcher poly-markdown-inline-math-tail-matcher unbound unbound unbound unbound) "markdown-inline-math:" unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound #<buffer  test.Rmd[latex]> unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound)) :pm-mode latex-mode font-lock-multiline t)))
  TeX--prettify-symbols-compose-p(16 22 #("\\gamma" 0 5 (fontified nil :pm-span (body 3 22 #s(pm-inner-chunkmode #s(pm-inner-chunkmode #s(pm-inner-chunkmode unbound "markdown-root" nil nil host t 2 0 0 t t t 2 nil nil nil nil 0 nil nil host host unbound unbound bold nil nil nil) "markdown-inline-math" unbound latex-mode unbound nil unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound poly-markdown-inline-math-head-matcher poly-markdown-inline-math-tail-matcher unbound unbound unbound unbound) "markdown-inline-math:" unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound #<buffer  test.Rmd[latex]> unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound)) :pm-mode latex-mode) 5 6 (fontified nil :pm-span (body 3 22 #s(pm-inner-chunkmode #s(pm-inner-chunkmode #s(pm-inner-chunkmode unbound "markdown-root" nil nil host t 2 0 0 t t t 2 nil nil nil nil 0 nil nil host host unbound unbound bold nil nil nil) "markdown-inline-math" unbound latex-mode unbound nil unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound poly-markdown-inline-math-head-matcher poly-markdown-inline-math-tail-matcher unbound unbound unbound unbound) "markdown-inline-math:" unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound #<buffer  test.Rmd[latex]> unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound)) :pm-mode latex-mode font-lock-multiline t)))
  apply(TeX--prettify-symbols-compose-p (16 22 #("\\gamma" 0 5 (fontified nil :pm-span (body 3 22 #s(pm-inner-chunkmode #s(pm-inner-chunkmode #s(pm-inner-chunkmode unbound "markdown-root" nil nil host t 2 0 0 t t t 2 nil nil nil nil 0 nil nil host host unbound unbound bold nil nil nil) "markdown-inline-math" unbound latex-mode unbound nil unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound poly-markdown-inline-math-head-matcher poly-markdown-inline-math-tail-matcher unbound unbound unbound unbound) "markdown-inline-math:" unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound #<buffer  test.Rmd[latex]> unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound)) :pm-mode latex-mode) 5 6 (fontified nil :pm-span (body 3 22 #s(pm-inner-chunkmode #s(pm-inner-chunkmode #s(pm-inner-chunkmode unbound "markdown-root" nil nil host t 2 0 0 t t t 2 nil nil nil nil 0 nil nil host host unbound unbound bold nil nil nil) "markdown-inline-math" unbound latex-mode unbound nil unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound poly-markdown-inline-math-head-matcher poly-markdown-inline-math-tail-matcher unbound unbound unbound unbound) "markdown-inline-math:" unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound #<buffer  test.Rmd[latex]> unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound)) :pm-mode latex-mode font-lock-multiline t))))
  #f(advice-wrapper :override #f(compiled-function (&rest args) #<bytecode 0x12061c1>) TeX--prettify-symbols-compose-p)(16 22 #("\\gamma" 0 5 (fontified nil :pm-span (body 3 22 #s(pm-inner-chunkmode #s(pm-inner-chunkmode #s(pm-inner-chunkmode unbound "markdown-root" nil nil host t 2 0 0 t t t 2 nil nil nil nil 0 nil nil host host unbound unbound bold nil nil nil) "markdown-inline-math" unbound latex-mode unbound nil unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound poly-markdown-inline-math-head-matcher poly-markdown-inline-math-tail-matcher unbound unbound unbound unbound) "markdown-inline-math:" unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound #<buffer  test.Rmd[latex]> unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound)) :pm-mode latex-mode) 5 6 (fontified nil :pm-span (body 3 22 #s(pm-inner-chunkmode #s(pm-inner-chunkmode #s(pm-inner-chunkmode unbound "markdown-root" nil nil host t 2 0 0 t t t 2 nil nil nil nil 0 nil nil host host unbound unbound bold nil nil nil) "markdown-inline-math" unbound latex-mode unbound nil unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound poly-markdown-inline-math-head-matcher poly-markdown-inline-math-tail-matcher unbound unbound unbound unbound) "markdown-inline-math:" unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound #<buffer  test.Rmd[latex]> unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound unbound)) :pm-mode latex-mode font-lock-multiline t)))
  prettify-symbols--compose-symbol((("\\alpha" . 945) ("\\beta" . 946) ("\\gamma" . 947) ("\\delta" . 948) ("\\epsilon" . 1013) ("\\zeta" . 950) ("\\eta" . 951) ("\\theta" . 952) ("\\iota" . 953) ("\\kappa" . 954) ("\\lambda" . 955) ("\\mu" . 956) ("\\nu" . 957) ("\\xi" . 958) ("\\pi" . 960) ("\\rho" . 961) ("\\sigma" . 963) ("\\tau" . 964) ("\\upsilon" . 965) ("\\phi" . 981) ("\\chi" . 967) ("\\psi" . 968) ("\\omega" . 969) ("\\Gamma" . 915) ("\\Delta" . 916) ("\\Lambda" . 923) ("\\Phi" . 934) ("\\Pi" . 928) ("\\Psi" . 936) ("\\Sigma" . 931) ("\\Theta" . 920) ("\\Upsilon" . 933) ("\\Xi" . 926) ("\\Omega" . 937) ("\\Box" . 9633) ("\\Bumpeq" . 8782) ("\\Cap" . 8914) ("\\Cup" . 8915) ("\\Diamond" . 9671) ("\\Downarrow" . 8659) ("\\H{o}" . 337) ("\\Im" . 8465) ("\\Join" . 8904) ("\\Leftarrow" . 8656) ("\\Leftrightarrow" . 8660) ("\\Ll" . 8920) ("\\Lleftarrow" . 8666) ("\\Longleftarrow" . 8656) ("\\Longleftrightarrow" . 8660) ("\\Longrightarrow" . 8658) ...))
  eval((prettify-symbols--compose-symbol (quote (("\\alpha" . 945) ("\\beta" . 946) ("\\gamma" . 947) ("\\delta" . 948) ("\\epsilon" . 1013) ("\\zeta" . 950) ("\\eta" . 951) ("\\theta" . 952) ("\\iota" . 953) ("\\kappa" . 954) ("\\lambda" . 955) ("\\mu" . 956) ("\\nu" . 957) ("\\xi" . 958) ("\\pi" . 960) ("\\rho" . 961) ("\\sigma" . 963) ("\\tau" . 964) ("\\upsilon" . 965) ("\\phi" . 981) ("\\chi" . 967) ("\\psi" . 968) ("\\omega" . 969) ("\\Gamma" . 915) ("\\Delta" . 916) ("\\Lambda" . 923) ("\\Phi" . 934) ("\\Pi" . 928) ("\\Psi" . 936) ("\\Sigma" . 931) ("\\Theta" . 920) ("\\Upsilon" . 933) ("\\Xi" . 926) ("\\Omega" . 937) ("\\Box" . 9633) ("\\Bumpeq" . 8782) ("\\Cap" . 8914) ("\\Cup" . 8915) ("\\Diamond" . 9671) ("\\Downarrow" . 8659) ("\\H{o}" . 337) ("\\Im" . 8465) ("\\Join" . 8904) ("\\Leftarrow" . 8656) ("\\Leftrightarrow" . 8660) ("\\Ll" . 8920) ("\\Lleftarrow" . 8666) ("\\Longleftarrow" . 8656) ("\\Longleftrightarrow" . 8660) ("\\Longrightarrow" . 8658) ...))))
  font-lock-fontify-keywords-region(3 22 nil)
  font-lock-default-fontify-region(3 22 nil)
  font-latex-fontify-region(3 22 nil)
  #f(compiled-function (beg end &optional loudly) #<bytecode 0x1e5f5b>)(3 22)
  apply(#f(compiled-function (beg end &optional loudly) #<bytecode 0x1e5f5b>) (3 22))
  (if pm-initialization-in-progress nil (apply orig-fun args))
  polymode-inhibit-during-initialization(#f(compiled-function (beg end &optional loudly) #<bytecode 0x1e5f5b>) 3 22)
  apply(polymode-inhibit-during-initialization #f(compiled-function (beg end &optional loudly) #<bytecode 0x1e5f5b>) (3 22))
  font-lock-fontify-region(3 22)
  #f(compiled-function (fun) #<bytecode 0x1536ea9>)(font-lock-fontify-region)
  run-hook-wrapped(#f(compiled-function (fun) #<bytecode 0x1536ea9>) font-lock-fontify-region)
  jit-lock--run-functions(3 22)
  #f(compiled-function (span) #<bytecode 0x15bc3e9>)((body 3 22 #<pm-inner-chunkmode markdown-inline-math:>))
  funcall(#f(compiled-function (span) #<bytecode 0x15bc3e9>) (body 3 22 #<pm-inner-chunkmode markdown-inline-math:>))
  (while *span* (setq nr (1+ nr)) (pm-select-buffer *span* visibly) (funcall fun *span*) (setq pos (if backwardp (max 1 (1- (nth 1 *span*))) (min (point-max) (nth 2 *span*)))) (setq *span* (and (if backwardp (> pos beg) (< pos end)) (< nr count) (pm-innermost-span pos no-cache))))
  (let* ((nr 0) (pos (if backwardp end beg)) (*span* (pm-innermost-span pos no-cache))) (while *span* (setq nr (1+ nr)) (pm-select-buffer *span* visibly) (funcall fun *span*) (setq pos (if backwardp (max 1 (1- (nth 1 *span*))) (min (point-max) (nth 2 *span*)))) (setq *span* (and (if backwardp (> pos beg) (< pos end)) (< nr count) (pm-innermost-span pos no-cache)))))
  (save-restriction (widen) (setq beg (or beg (point-min)) end (if end (min end (point-max)) (point-max))) (if count nil (setq count most-positive-fixnum)) (let* ((nr 0) (pos (if backwardp end beg)) (*span* (pm-innermost-span pos no-cache))) (while *span* (setq nr (1+ nr)) (pm-select-buffer *span* visibly) (funcall fun *span*) (setq pos (if backwardp (max 1 (1- (nth 1 *span*))) (min (point-max) (nth 2 *span*)))) (setq *span* (and (if backwardp (> pos beg) (< pos end)) (< nr count) (pm-innermost-span pos no-cache))))))
  pm-map-over-spans(#f(compiled-function (span) #<bytecode 0x15bc3e9>) 1 26)
  poly-lock-fontify-now(1 26)
  poly-lock-function(1)
  redisplay_internal\ \(C\ function\)()

The file contains a mathematical formula only: \alpha+\beta=\gamma. When it contains no formula, no error is shown. So I fathom it's got something to do with LaTeX fontification?

Dependencies are all updated to latest. To be specific, the commit hashes are:

ess-version: d31b96e0
polymode: 01232ad
poly-markdown: a867e5e
poly-noweb: 4e65cb2

PS: When I tried to debug using make start, I met another issue which is filed at #16

Call bookdown exporter interactively

Hello,

I would like to be able to call bookdown to render my Rmd source using the pdf_document2 format. This happens automatically if I include the directive in the Rmd yaml:

output:
  bookdown::pdf_document2

However, I would like to be able to select this output interactively. It's already defined in poly-r-bookdown-ess-exporter, but that exporter isn't offered as an option when I set my exporter (it doesn't have a matching from argument).

How can I make poly-R use the bookdown exporter interactively?

minimal.Rmd not found

When attempting to run "make all", I see the following error:

******************* Testing poly-R ***************************
emacs -Q -L . -L modes -L tests -L .ELPA/27.0.50 --batch --load targets/melpa-init.el --load targets/test.el
Loading /home/sly/.emacs.d/site-lisp/modes/poly-R/tests/poly-R-tests.el (source)...
Eager macro-expansion failure: (error "No file with name ’minimal.Rmd’ found in ’~/.emacs.d/site-lisp/modes/poly-R/’")
Eager macro-expansion failure: (error "No file with name ’minimal.Rmd’ found in ’~/.emacs.d/site-lisp/modes/poly-R/’")
No file with name ’minimal.Rmd’ found in ’~/.emacs.d/site-lisp/modes/poly-R/’
make: *** [Makefile:54: test] Error 255

Latex (Math) highlight is broken when auctex is installed

two versions of minimal config (one with auctex installed and one without auctex installed)

the first is without auctex installed:

(require 'package)
(setq package-user-dir "~/Downloads/emacs-package-dir")

(setq package-list '(poly-R poly-markdown ess))
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(package-initialize)

(unless package-archive-contents
  (package-refresh-contents))

(dolist (package package-list)
  (unless (package-installed-p package)
    (package-install package)))

(setq markdown-enable-math t)
(setq warning-minimum-level :error)

emacs -Q -l minimal-config.el opens the following rmd file: test.rmd

---
title: 'test rmd'
author: 'author'
date: '12/14/2021'
output: 
    bookdown::pdf_document2:
---

$y = \sum_{i=1}^n sin5x^3 + 2$

the rendering is the following:

Screen Shot 2022-11-23 at 01 16 05

and if with auctex installed:

(require 'package)
(setq package-user-dir "~/Downloads/emacs-package-dir")

(setq package-list '(poly-R poly-markdown ess))
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(package-initialize)

(unless package-archive-contents
  (package-refresh-contents))

(dolist (package package-list)
  (unless (package-installed-p package)
    (package-install package)))

(setq markdown-enable-math t)
(setq warning-minimum-level :error)

emacs -Q -l minimal-config.el opens the same file, will see that math (latex) highlight is broken:

Screen Shot 2022-11-23 at 01 17 16

It is clear that the highlight of the keyword (\sum) is broken, and the variable pitch for superscript and subscript is also broken

Support for Github-flavored markdown mode

There is a polymode defined for gfm-mode, a variant that accommodates fenced code blocks and a few other features. It doesn't appear to be supported by poly-R. I think it would only require two lines of code:

To define the mode we need only:

(define-polymode poly-gfm+r-mode poly-gfm-mode :lighter " PGFM-Rmd"
  :innermodes '(:inherit poly-r-markdown-inline-code-innermode))

And then we need to do the file association:

(setq auto-mode-alist
         (append
          '(("\\.[rR]md\\'" . poly-gfm+r-mode))
          auto-mode-alist))

I'm not sure where this ought to go - maybe there should be a user option that could signal whether to assign poly-gfm+r-mode or poly-markdown+r-mode to Rmd files?

If you have a suggestion as to how to deal with auto-mode-alist, I can put together a pull request.

smartparens not working for ' and ", () throwing error, in rmarkdown polymode

This had worked fine for me until I updated my polymode packages a few days ago.

In an .Rmd file, inside an R chunk, pressing " or ' just inserts a single character not a matched pair. A matched pair is inserted in the markdown buffer portions.

In plain .R files, using ESS, matched pairs for ' and " are inserted as expected.

Possibly related: inserting a parenthesis pair, () inside an Rmd R chunk generates an error: Error running timer ‘sp-show--pair-function’: (wrong-type-argument characterp nil)

Again I do not see this error when inserting parenthesis in the markdown buffer portions or when using plain .R files with ESS.

Loading template for .Rmd file and using it

Hi,

Related to this other issue, when I open a .Rmd file, let's say xaringan_example.Rmd I have to first start a ess process by doing M-x R, and then I am able to start a template by executing M-n M-m.

However, when I select the desired template (in my case is "xaringan/Ninja Presentation"), the prompt immediately asks me for a "Draft name", in which I don't know what to type. So I proceed to type just another filename like example_presentation.Rmd and I see on the process that the command:

rmarkdown::draft('~/Downloads/xaringan_draft.Rmd', 'xaringan', package = "xaringan", edit = FALSE)

was executed. In addition, I also see on the prompt ESS process not ready. Finish your command before trying again.

Two things:

  1. What is the purpose of this "draft" that I am asked to fill in?
  2. When I try to execute the .Rmd file, I do M-n W and select knitr-ess to use the current R process, however, nothing happens after hitting enter. On the other hand, trying M-n w asks me to select the desired export format, in which I select HTML, but then I get just a plain .html file with clearly no usage of the template. How can I make poly-R to use the template that I selected doing M-n M-m?

Rstudio vs poly-R output files

Just to add extra information to solve the problem, I run exactly the same file on Rstudio using the package xaringan. The source code of the generated file starts with the following code:

`

<title>Presentation Ninja</title> <script src="libs/header-attrs/header-attrs.js"></script> <script src="libs/htmlwidgets/htmlwidgets.js"></script> <script src="libs/jquery/jquery.min.js"></script> <script src="libs/leaflet/leaflet.js"></script> <script src="libs/proj4/proj4.min.js"></script> <script src="libs/Proj4Leaflet/proj4leaflet.js"></script> <script src="libs/leaflet-binding/leaflet.js"></script> <script src="libs/datatables-binding/datatables.js"></script> <script src="libs/dt-core/js/jquery.dataTables.min.js"></script> <script src="libs/crosstalk/js/crosstalk.min.js"></script> <textarea id="source">`

and so on. On the other hand, when using poly-R the output doesn't contain anything like that, it starts directly with the content.
My interpretation of the problem is that poly-R is not using xaringan package with weaving the file to html using knitr. It would be nice to know how to generate the same output as Rstudio.

Thanks in advance for the help!

PD: selecting as draft the current opened file (xaringan_example.Rmd) doesn't solve the issue.

Polymode crashes Emacs 29 for Windows

Steps to reproduce in a freshly installed Windows 10 virtual machine hosted in Linux.

  1. Download Emacs 29.1_1 or 29.2_1, see links:
    http://ftpmirror.gnu.org/emacs/windows/emacs-29/emacs-29.1_1.zip
    http://ftpmirror.gnu.org/emacs/windows/emacs-29/emacs-29.2_1.zip

  2. Extract the zip and start Emacs with:
    runemacs.exe -Q

  3. Evaluate the following expressions:

 (require 'package)
 (add-to-list 'package-archives  '("stable-melpa" . "https://stable.melpa.org/packages/"))
 (list-packages)
  1. Install ess and poly-R packages from the stable MELPA archive.

  2. Evaluate the following expressions:

 (let ((default-directory user-emacs-directory))
   (normal-top-level-add-subdirs-to-load-path))
 (setopt inferior-R-program-name "path to your R/bin/x64/Rterm.exe")
 (require 'poly-R)
  1. Open a relatively large Rmd document.

  2. On an R code chunk, type C-return to start the inferior R buffer.

  3. Finally, navigate the document via the Polymode menu with Next/Previous chunk entries.
    Don't use key bindings, but the mouse and, in particular, use the same-type chunk entry in the menu.

May be after 10/15 chunk visits, like said above, Emacs crashes. Probably, the test works better if you do not disable the default Windows real-time virus & threat protection settings (active).

Specifically, for version 29.1_1, it just suddenly closes, so there are not many useful details.
For 29.2_1 it gets stuck. If you kill Rterm in Windows Task Manager, functionality seems to be restored, but only at keyboard level. Clicking with the mouse pointer is ineffective. I was unable to reproduce with ordinary R files in r-mode buffers, using the ESS menu eval entries, and similarly in Polymode using the key bindings, rather than the menu bar, I do not get errors.

As it seems, the bug is a mouse thing and is related to comint communication with the R process. The menu somehow queries R to navigate chunks and loses sync with the process, then it remains stuck waiting for an answer.

Function indirection loop

In version 20190320.2042 of poly-R from melpa, I see the following error during init:

Symbol's chain of function indirections contains a loop: poly-markdown+r-mode

Removing line 90 from my poly-R.el and the corresponding line from poly-R-autoloads.el fixes this problem. I think this line is a typo?

(define-obsolete-function-alias 'poly-markdown+r-mode 'poly-markdown+r-mode "v0.2")

Thanks for a great package!

R chunks starting with a single-commented line not indented on first line

I am using the default ESS commenting system, where single comment characters are indented to comment-column. This works as expected with poly-r, except for the first line. If the first line of a chunk starts with a single comment, pressing tab indents the line to the first column. I.e., if I start from this:

```{R code-test}
# This is the first commented line
# Second comment line
1 + 1
```

Pressing tab on the first line doesn't change indentation. On the second line it does:

```{R code-test}
# This is the first commented line
                                        # Second comment line
1 + 1
```

What I expect is:

```{R code-test}
                                        # This is the first commented line
                                        # Second comment line
1 + 1
```

Is this intentional? If so, can I change it to give me the indentation I want?

My motivation is to move the comment column to column 2, so I can use single # characters to get nearly full-line comments. If I use ### comments, markdown-mode as the host mode treats these as headlines, which breaks visibility cycling.

Emacs 28.0.50
poly-R 20200316.1315

poly-R no longer works in doom

poly-R is no longer working. I get the following error when running with --debug-init:

Debugger entered--Lisp error: (void-variable keymap)
  byte-code("\305\306!\210\307\310\311\"\211\205\16\0\211J\312\304!\210\313\314\10!\203\35\0\10\202Y\0\314\10!\203'\0\315\202O\0\316\11J!\203@\0\317\10\11J\"\320\n\2@\"\20\211A\262\1\202O\0\11\203N\0\321\322\3\323\"!J\202O\0\13\324\10\315\211\325\5D$\262\1!\210\312\326!\210\327\2\203q\0..." [keymap parent keylist polymode-minor-mode-map poly-noweb+r-mode-map make-variable-buffer-local poly-noweb+r-mode pm--config-name poly-noweb-mode must-exist makunbound (lambda (def-tmp-var) (defvar poly-noweb+r-mode-map def-tmp-var "Keymap for poly-noweb+r-mode.")) keymapp nil eieio-object-p pm--get-keylist\.keymap-from-parent append derived-mode-map-name eieio-oref -minor-mode easy-mmode-define-keymap :inherit poly-noweb+r-polymode (lambda (def-tmp-var) (defvar poly-noweb+r-polymode def-tmp-var "Configuration object for `poly-noweb+r-mode' polym...")) clone :name "poly-noweb+r-polymode" :innermodes (poly-r-noweb-innermode) pm-polymode defalias #f(compiled-function (&optional arg) "Polymode for noweb+r.\n\n\\{poly-noweb+r-mode-map}" (interactive nil) #<bytecode 0x1f027115e3458555>) add-minor-mode " PM-Rnw" require poly-markdown custom-declare-variable poly-r-rmarkdown-template-dirs funcall function #f(compiled-function () #<bytecode 0x1f4000153e91>) "Directories containing RMarkdown templates.\nTempla..." :type (repeat string) :group poly-R poly-r-markdown-inline-code-innermode] 11)
  require(poly-R nil nil)
  load-with-code-conversion("/Users/atanas/.doom.d/+ess.el" "/Users/atanas/.doom.d/+ess.el" nil t)
  load("/Users/atanas/.doom.d/+ess" nil nomessage)
  (let (file-name-handler-alist) (load (expand-file-name "+ess" "/Users/atanas/.doom.d") nil 'nomessage))
  (condition-case e (let (file-name-handler-alist) (load (expand-file-name "+ess" "/Users/atanas/.doom.d") nil 'nomessage)) ((debug doom-error) (signal (car e) (cdr e))) ((debug error) (doom--handle-load-error e (expand-file-name "+ess" "/Users/atanas/.doom.d") "/Users/atanas/.doom.d")))
  load-with-code-conversion("/Users/atanas/.doom.d/config.el" "/Users/atanas/.doom.d/config.el" t t)
  load("/Users/atanas/.doom.d/config" t nomessage)
  (let (file-name-handler-alist) (load (expand-file-name "config" doom-private-dir) t 'nomessage))
  (condition-case e (let (file-name-handler-alist) (load (expand-file-name "config" doom-private-dir) t 'nomessage)) ((debug doom-error) (signal (car e) (cdr e))) ((debug error) (doom--handle-load-error e (expand-file-name "config" doom-private-dir) doom-private-dir)))
  (if no-config-p nil (maphash (doom-module-loader doom-module-config-file) doom-modules) (run-hook-wrapped 'doom-init-modules-hook #'doom-try-run-hook) (condition-case e (let (file-name-handler-alist) (load (expand-file-name "config" doom-private-dir) t 'nomessage)) ((debug doom-error) (signal (car e) (cdr e))) ((debug error) (doom--handle-load-error e (expand-file-name "config" doom-private-dir) doom-private-dir))) (load custom-file 'noerror (not doom-debug-mode)))
  (progn (if doom-debug-p (progn (let ((inhibit-message (active-minibuffer-window))) (message #("DOOM Initializing user config" 0 5 (face font-lock-comment-face)))))) (maphash (doom-module-loader doom-module-init-file) doom-modules) (run-hook-wrapped 'doom-before-init-modules-hook #'doom-try-run-hook) (if no-config-p nil (maphash (doom-module-loader doom-module-config-file) doom-modules) (run-hook-wrapped 'doom-init-modules-hook #'doom-try-run-hook) (condition-case e (let (file-name-handler-alist) (load (expand-file-name "config" doom-private-dir) t 'nomessage)) ((debug doom-error) (signal (car e) (cdr e))) ((debug error) (doom--handle-load-error e (expand-file-name "config" doom-private-dir) doom-private-dir))) (load custom-file 'noerror (not doom-debug-mode))))
  (if init-p (progn (if doom-debug-p (progn (let ((inhibit-message (active-minibuffer-window))) (message #("DOOM Initializing user config" 0 5 (face font-lock-comment-face)))))) (maphash (doom-module-loader doom-module-init-file) doom-modules) (run-hook-wrapped 'doom-before-init-modules-hook #'doom-try-run-hook) (if no-config-p nil (maphash (doom-module-loader doom-module-config-file) doom-modules) (run-hook-wrapped 'doom-init-modules-hook #'doom-try-run-hook) (condition-case e (let (file-name-handler-alist) (load (expand-file-name "config" doom-private-dir) t 'nomessage)) ((debug doom-error) (signal (car e) (cdr e))) ((debug error) (doom--handle-load-error e (expand-file-name "config" doom-private-dir) doom-private-dir))) (load custom-file 'noerror (not doom-debug-mode)))) nil)
  (let* ((init-p (and t (condition-case e (let (file-name-handler-alist) (load (expand-file-name doom-module-init-file doom-private-dir) t 'nomessage)) ((debug doom-error) (signal (car e) (cdr e))) ((debug error) (doom--handle-load-error e (expand-file-name doom-module-init-file doom-private-dir) doom-private-dir)))))) (if init-p (progn (if doom-debug-p (progn (let ((inhibit-message ...)) (message #("DOOM Initializing user config" 0 5 ...))))) (maphash (doom-module-loader doom-module-init-file) doom-modules) (run-hook-wrapped 'doom-before-init-modules-hook #'doom-try-run-hook) (if no-config-p nil (maphash (doom-module-loader doom-module-config-file) doom-modules) (run-hook-wrapped 'doom-init-modules-hook #'doom-try-run-hook) (condition-case e (let (file-name-handler-alist) (load (expand-file-name "config" doom-private-dir) t 'nomessage)) ((debug doom-error) (signal (car e) (cdr e))) ((debug error) (doom--handle-load-error e (expand-file-name "config" doom-private-dir) doom-private-dir))) (load custom-file 'noerror (not doom-debug-mode)))) nil))
  (progn (setq doom-init-modules-p t) (if no-config-p nil (if doom-debug-p (progn (let ((inhibit-message (active-minibuffer-window))) (message #("DOOM Initializing core modules" 0 5 (face font-lock-comment-face)))))) (doom-initialize-core-modules)) (let* ((init-p (and t (condition-case e (let (file-name-handler-alist) (load ... t ...)) ((debug doom-error) (signal ... ...)) ((debug error) (doom--handle-load-error e ... doom-private-dir)))))) (if init-p (progn (if doom-debug-p (progn (let (...) (message ...)))) (maphash (doom-module-loader doom-module-init-file) doom-modules) (run-hook-wrapped 'doom-before-init-modules-hook #'doom-try-run-hook) (if no-config-p nil (maphash (doom-module-loader doom-module-config-file) doom-modules) (run-hook-wrapped 'doom-init-modules-hook #'doom-try-run-hook) (condition-case e (let (file-name-handler-alist) (load ... t ...)) ((debug doom-error) (signal ... ...)) ((debug error) (doom--handle-load-error e ... doom-private-dir))) (load custom-file 'noerror (not doom-debug-mode)))) nil)))
  (if (or force-p (not doom-init-modules-p)) (progn (setq doom-init-modules-p t) (if no-config-p nil (if doom-debug-p (progn (let ((inhibit-message ...)) (message #("DOOM Initializing core modules" 0 5 ...))))) (doom-initialize-core-modules)) (let* ((init-p (and t (condition-case e (let ... ...) (... ...) (... ...))))) (if init-p (progn (if doom-debug-p (progn (let ... ...))) (maphash (doom-module-loader doom-module-init-file) doom-modules) (run-hook-wrapped 'doom-before-init-modules-hook #'doom-try-run-hook) (if no-config-p nil (maphash (doom-module-loader doom-module-config-file) doom-modules) (run-hook-wrapped 'doom-init-modules-hook #'doom-try-run-hook) (condition-case e (let ... ...) (... ...) (... ...)) (load custom-file 'noerror (not doom-debug-mode)))) nil))))
  doom-initialize-modules(nil)
  (progn (setq doom-init-p t) (if doom-debug-p (progn (let ((inhibit-message (active-minibuffer-window))) (message #("DOOM Initializing Doom" 0 5 (face font-lock-comment-face)))))) (progn (set-default 'exec-path doom--initial-exec-path) (set-default 'load-path doom--initial-load-path) (set-default 'process-environment doom--initial-process-environment)) (condition-case e (load (string-remove-suffix ".el" doom-autoloads-file) nil 'nomessage) (file-missing (if (locate-file doom-autoloads-file load-path) (signal 'doom-autoload-error e) (signal 'doom-error (list "Doom is in an incomplete state" "run 'doom sync' on the command line to repair it"))))) (if (or (display-graphic-p) (daemonp)) (doom-load-envvars-file doom-env-file 'noerror)) (require 'core-modules) (autoload 'doom-initialize-packages "core-packages") (eval-after-load 'package #'(lambda nil (require 'core-packages))) (eval-after-load 'straight #'(lambda nil (doom-initialize-packages))) (add-hook 'doom-first-buffer-hook #'gcmh-mode) (add-hook 'after-change-major-mode-hook #'doom-run-local-var-hooks-h) (add-hook 'emacs-startup-hook #'doom-load-packages-incrementally-h) (add-hook 'window-setup-hook #'doom-display-benchmark-h) (doom-run-hook-on 'doom-first-buffer-hook '(after-find-file doom-switch-buffer-hook)) (doom-run-hook-on 'doom-first-file-hook '(after-find-file dired-initial-position-hook)) (doom-run-hook-on 'doom-first-input-hook '(pre-command-hook)) (if doom-debug-p (doom-debug-mode 1)) (doom-initialize-modules force-p))
  (if (or force-p (not doom-init-p)) (progn (setq doom-init-p t) (if doom-debug-p (progn (let ((inhibit-message (active-minibuffer-window))) (message #("DOOM Initializing Doom" 0 5 (face font-lock-comment-face)))))) (progn (set-default 'exec-path doom--initial-exec-path) (set-default 'load-path doom--initial-load-path) (set-default 'process-environment doom--initial-process-environment)) (condition-case e (load (string-remove-suffix ".el" doom-autoloads-file) nil 'nomessage) (file-missing (if (locate-file doom-autoloads-file load-path) (signal 'doom-autoload-error e) (signal 'doom-error (list "Doom is in an incomplete state" "run 'doom sync' on the command line to repair it"))))) (if (or (display-graphic-p) (daemonp)) (doom-load-envvars-file doom-env-file 'noerror)) (require 'core-modules) (autoload 'doom-initialize-packages "core-packages") (eval-after-load 'package #'(lambda nil (require 'core-packages))) (eval-after-load 'straight #'(lambda nil (doom-initialize-packages))) (add-hook 'doom-first-buffer-hook #'gcmh-mode) (add-hook 'after-change-major-mode-hook #'doom-run-local-var-hooks-h) (add-hook 'emacs-startup-hook #'doom-load-packages-incrementally-h) (add-hook 'window-setup-hook #'doom-display-benchmark-h) (doom-run-hook-on 'doom-first-buffer-hook '(after-find-file doom-switch-buffer-hook)) (doom-run-hook-on 'doom-first-file-hook '(after-find-file dired-initial-position-hook)) (doom-run-hook-on 'doom-first-input-hook '(pre-command-hook)) (if doom-debug-p (doom-debug-mode 1)) (doom-initialize-modules force-p)))
  doom-initialize()
  load-with-code-conversion("/Users/atanas/.emacs.d/init.el" "/Users/atanas/.emacs.d/init.el" t t)
  load("/Users/atanas/.emacs.d/init" noerror nomessage)
  startup--load-user-init-file(#f(compiled-function () #<bytecode -0x14935ace27dc677>) #f(compiled-function () #<bytecode -0x1f3c686ddc0d7975>) t)
  command-line()
  normal-top-level()

My polymode config is:

(use-package! polymode
  ;; :ensure t
  :init
  (use-package! poly-markdown)
  (use-package! poly-noweb)
  ;; (use-package! poly-R)
  ;; (require 'poly-R)
  ;; (require 'poly-markdown)
  ;; (require 'poly-noweb)
  :config
  (add-to-list 'auto-mode-alist '("\\.md" . poly-markdown-mode))
  (add-to-list 'auto-mode-alist '("\\.Snw" . poly-noweb+R-mode))
  (add-to-list 'auto-mode-alist '("\\.Rnw" . poly-noweb+R-mode))
  (add-to-list 'auto-mode-alist '("\\.Rmd" . poly-markdown+R-mode))
  ;; Export files with the same name as the main file
  (setq polymode-exporter-output-file-format "%s")
  )

When I comment out the call to poly-R, I no longer get the error but my ability to work with .Rmd is gone.

My system info is:

ProductName:    macOS
ProductVersion: 11.2.2
BuildVersion:   20D80
GNU Emacs 28.0.50 # built via homebrew with native-comp
Doom v2.0.9 (grafted, HEAD -> develop, origin/develop, origin/HEAD 88e18fc 2021-02-27 23:56:15 -0500)
poly-R v0.2.2

Please let me know if you need any more info. Thanks in advance.

Bug when typing in Markdown after using ESS with LSP

When I write in an rmd file everything is normal when editing the markdown parts. After I enter an ESS code chunk, subsequent typing in markdown leads to weird things, including jumping to the end of the buffer and typing in reverse. Editing is fine within the code chunk. The issue persists even after deleting the code chunk but "resets" after I close and reopen the buffer. Also the bug doesn't happen when I don't load the lsp layer in spacemacs so I assume it has something to do with that. I usually have (ess :variables ess-r-backend 'lsp) in the layer config but the issue happens even when I just load ess. Everything is fine in a normal ESS buffer. See below for a demonstration:

poly-r-bug.mov

Setup

  • M1 Pro Macbook
  • macOS 12.0.1
  • emacs-plus@28

dependency on ess

poly-R will not load without ess: see these lines

However, ess is not declared as a dependency. Thus, it's possible to install poly-R without ess, in which case things won't work. For example, if I start a fresh emacs (with emacs -Q), configure melpa, install poly-R, and then (require 'poly-R), I get an error about being unable to load ess-mode.

This bug probably rarely comes up, since most people using poly-R have probably already installed ess, but it would be nice to make this explicit/automatic.

Fixing this is as simple as making the dependency explicit, but rather than submitting a PR, I wanted to check if there's a particular version of ess on which poly-R depends.

Do I need to configure `poly-r-rmarkdown-template-dirs` manually, even for templates included with installed R packages (e.g. tufte)?

(note: this question stems from https://emacs.stackexchange.com/questions/47942/missing-rmarkdown-templates-with-poly-r)
I inspected the poly-R source, and I did not find any code that would search for templates in the local R Libraries; it seems all paths must be listed manually in poly-r-rmarkdown-template-dirs. Is that right? The reason I am asking is that poly-R's README.md says in a cursory way "RMarkdown templates available through ESS menus and on M-n M-m in Rmd files (poly-r-rmarkdown-create-from-template)", without alluding specifically to the variable poly-r-rmarkdown-template-dirs. Also, RStudio also lists installed .Rmd templates automatically, so I thought I might have missed in the poly-R source a call to an R function that would list installed .Rmd templates.

Menubar crashes Aquamacs when R buffer is open

I recently updated to polymode and poly-R versions 0.2. I am running Aquamacs 3.5 on MacOS 10.14.6 Mojave. When I open an R buffer, as soon as I click on the menu bar, Aquamacs immediately crashes. I have replicated this on two different computers.

I traced the problem to the (easy-menu-define poly-markdown+R-menu) function in poly-R.el. If I comment out lines 218-225, and byte-compile the modified file, the crash goes away. I'm not sure what functionality I am losing, so I don't want to submit a pull request just yet. But there appears to be an issue with that function.

How to enable shell-escape latex option?

Hi,

Thank you for that package. I am using Snw noweb+r-mode and I set TeX-command-extra-options to --shell-escape, both locally and globally. Yet, when I export I got an error that I have not set shell-escape.

What am I missing here?

Thank you

Edit:

I also have problems with the bibliography. The references are not created correctly.

why does polymode autolaunch R now?

I'm having nothing but trouble since trying to update to the latest git head. My immediate problem is that when I try to open a .org R file, it wants to immediately launch R, and keeps asking me over and over to start yet another R session. I'm not sure if this is a poly-org or poly-R issue but it has made polymode unusable for me, at least for the moment.

Error on startup - Unknown specializer "R"

Hej,

I am running GNU Emacs 26.2 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
of 2019-04-12) on Ubuntu, and after package updates I get the following error:

error: Unknown specializer "R"

Does anyone experience the same issue?

poly-R 20190605.2103
ess 20190708.1230
polymode 20190714.2017

When starting emacs with --debug-init the following appears:

 Debugger entered--Lisp error: (error "Unknown specializer \"R\"")
  signal(error ("Unknown specializer \"R\""))
  error("Unknown specializer %S" "R")
  #f(compiled-function (specializer) "Support for the catch-all t specializer which always matches." #<bytecode 0x484b49>)("R")
  apply(#f(compiled-function (specializer) "Support for the catch-all t specializer which always matches." #<bytecode 0x484b49>) "R")
  #f(compiled-function (&rest cnm-args) #<bytecode 0x1944fd1>)()
  #f(compiled-function (cl--cnm specializer) "Support for (head VAL) specializers.\nThese match if the argument is a cons cell whose car is `eql' to VAL." #<bytecode 0x46fe09>)(#f(compiled-function (&rest cnm-args) #<bytecode 0x1944fd1>) "R")
  apply(#f(compiled-function (cl--cnm specializer) "Support for (head VAL) specializers.\nThese match if the argument is a cons cell whose car is `eql' to VAL." #<bytecode 0x46fe09>) #f(compiled-function (&rest cnm-args) #<bytecode 0x1944fd1>) "R")
  #f(compiled-function (&rest args) #<bytecode 0x54d391>)("R")
  apply(#f(compiled-function (&rest args) #<bytecode 0x54d391>) "R")
  #f(compiled-function (&rest cnm-args) #<bytecode 0x1944fb5>)()
  #f(compiled-function (cl--cnm type) "Support for dispatch on types defined by `cl-defstruct'." #<bytecode 0x46c3b5>)(#f(compiled-function (&rest cnm-args) #<bytecode 0x1944fb5>) "R")
  apply(#f(compiled-function (cl--cnm type) "Support for dispatch on types defined by `cl-defstruct'." #<bytecode 0x46c3b5>) #f(compiled-function (&rest cnm-args) #<bytecode 0x1944fb5>) "R")
  #f(compiled-function (&rest args) #<bytecode 0x54d3bd>)("R")
  apply(#f(compiled-function (&rest args) #<bytecode 0x54d3bd>) "R")
  #f(compiled-function (&rest cnm-args) #<bytecode 0x1944f99>)()
  #f(compiled-function (cl--cnm type) "Support for dispatch on builtin types.\nSee the full list and their hierarchy in `cl--generic-typeof-types'." #<bytecode 0x586fcd>)(#f(compiled-function (&rest cnm-args) #<bytecode 0x1944f99>) "R")
  apply(#f(compiled-function (cl--cnm type) "Support for dispatch on builtin types.\nSee the full list and their hierarchy in `cl--generic-typeof-types'." #<bytecode 0x586fcd>) #f(compiled-function (&rest cnm-args) #<bytecode 0x1944f99>) "R")
  #f(compiled-function (&rest args) #<bytecode 0x54d3e9>)("R")
  apply(#f(compiled-function (&rest args) #<bytecode 0x54d3e9>) "R")
  #f(compiled-function (&rest cnm-args) #<bytecode 0x1944f7d>)()
  #f(compiled-function (cl--cnm specializer) "Support for dispatch on types defined by EIEIO's `defclass'." #<bytecode 0x54a7ed>)(#f(compiled-function (&rest cnm-args) #<bytecode 0x1944f7d>) "R")
  apply(#f(compiled-function (cl--cnm specializer) "Support for dispatch on types defined by EIEIO's `defclass'." #<bytecode 0x54a7ed>) #f(compiled-function (&rest cnm-args) #<bytecode 0x1944f7d>) "R")
  #f(compiled-function (&rest args) #<bytecode 0x54db25>)("R")
  apply(#f(compiled-function (&rest args) #<bytecode 0x54db25>) "R" nil)
  cl-generic-generalizers("R")
  cl-generic-define-method(ess-help-get-topics nil (proc &context (ess-dialect "R")) nil #f(compiled-function (proc) "Return a list of current S help topics associated with process PROC.\nIf 'sp-for-help-changed?' process variable is non-nil or\n`ess-help-topics-list' is nil, (re)-populate the latter and\nreturn it.  Otherwise, return `ess-help-topics-list'." #<bytecode 0x19419ed>))
  byte-code("\300\301\302\303#\210\304\305\301\306#\210\300\305\301\303#\210\307\310\311\"\210\312\313\306\314\306\315%\210\304\316\317\"\210\304\320\321\"\210\304\322\323\"\210\304\324\322\"\210\304\325\320\"\210\304\326\327\306#\210\300\326\327\330#\210\304\331\332\306#\210\300\331\332\330#\210\304\333\332\306#\210\300\333\332\330#\210\304\334\335\306#\210\300\334\335\330#\210\304\336\335\306#\210\300\336\335\330#\210\337\340\341\"\210\337\340\342\"\210\343\344!\207" [make-obsolete ess-imenu-S "It is set automatically in major modes" "ESS 19.04" defalias ess-imenu-R nil eval-after-load "speedbar" #f(compiled-function () #<bytecode 0x19419e1>) cl-generic-define-method ess-help-get-topics (proc &context (ess-dialect "R")) #f(compiled-function (proc) "Return a list of current S help topics associated with process PROC.\nIf 'sp-for-help-changed?' process variable is non-nil or\n`ess-help-topics-list' is nil, (re)-populate the latter and\nreturn it.  Otherwise, return `ess-help-topics-list'." #<bytecode 0x19419ed>) S S+ s-mode S+-mode s-transcript-mode S+-transcript-mode S-transcript-mode S-mode ess-toggle-S-assign-key ignore "ESS 18.10" ess-smart-underscore ess-insert-assign ess-insert-S-assign ess-toggle-underscore ess-disable-smart-S-assign ess-toggle-S-assign add-to-list auto-mode-alist ("\\.[Ss]t\\'" . S-transcript-mode) ("\\.Sout" . S-transcript-mode) provide ess-s-lang] 6)
  require(ess-s-lang)
  byte-code("\303\304!\210\303\305!\210\303\306!\210\303\307!\210\303\310!\210\303\311!\210\303\312!\210\303\313!\210\303\314!\210\303\315!\210\303\316!\210\010\317Y\2036\0\303\320!\210\321\322\323\324#\210\325\324\031\211\032\203b\0\n@\021\322\011N\203[\0\323\011N\204[\0\326\323\011\322\011N#\210\nA\211\022\204D\0*\327\322\323\330#\210\331\323\324\332\333\334\335\336\337\340&\011\210\331\341\324\342\335\343\337\340&\007\210\321\344\345\324#\210\325\324\031\211\032\203\255\0\n@\021\344\011N\203\246\0\345\011N\204\246\0\326\345\011\344\011N#\210\nA\211\022\204\217\0*\327\344\345\346#\210\331\345\347\350\337\340\335\351\352\353\354\355&\013\207" [emacs-major-version prop --dolist-tail-- require cl-lib compile ess-mode ess-help ess-s-lang ess-roxy ess-r-completion ess-r-syntax ess-r-package ess-trns ess-r-xref 26 ess-r-flymake defvaralias R-mode-hook ess-r-mode-hook nil (saved-value saved-variable-comment) put make-obsolete-variable "19.04" custom-declare-variable "Hook run when entering `ess-r-mode'." :options (electric-layout-local-mode) :type hook :group ess-R ess-r-fetch-ESSR-on-remotes "If non-nil, fetch ESSR from the github repository.\nOtherwise source from local ESS installation. When 'ess-remote,\nfetch only with `ess-remote'. When t, always fetch from remotes.\nChange this variable when loading ESSR code on remotes fails\nsystematically.\n\nFetching happens once per new ESSR version. The archive is stored\nin ~/.config/ESSR/ folder. You can download and place it there\nmanually if the remote has restricted network access." (choice (const nil :tag "Never") (const (quote ess-remote) :tag "With ess-remote only") (const t :tag "Always")) ess-r-versions ess-r-runner-prefixes "ESS 19.04" (let ((r-ver (quote ("R-1" "R-2" "R-3" "R-devel" "R-patched")))) (if (eq system-type (quote darwin)) (append r-ver (quote ("R32" "R64"))) r-ver)) "List of partial strings for versions of R to access within ESS.\nEach string specifies the start of a filename. If a filename\nbeginning with one of these strings is found on variable\n`exec-path', a command for that version of R is made available.\nFor example, if the file \"R-1.8.1\" is found and this variable\nincludes the string \"R-1\", a function called `R-1.8.1' will be\navailable to run that version of R. If duplicate versions of the\nsame program are found (which happens if the same path is listed\non variable `exec-path' more than once), they are ignored by\ncalling `delete-dups'. Set this variable to nil to disable\nsearching for other versions of R. Setting this variable directly\ndoes not take effect; use either \\[customize-option] or set the\nvalue by using `ess-r-runners-reset'." (repeat string) :set ess-r-runners-reset :initialize custom-initialize-default] 13)
  require(ess-r-mode nil t)
  eval-buffer(#<buffer  *load*-411394> nil "/home/ab/.emacs.d/elpa/poly-R-20190605.2103/poly-R.el" nil t)  ; Reading at buffer position 1501
  load-with-code-conversion("/home/ab/.emacs.d/elpa/poly-R-20190605.2103/poly-R.el" "/home/ab/.emacs.d/elpa/poly-R-20190605.2103/poly-R.el" nil t)
  require(poly-R)
  eval-buffer(#<buffer  *load*-421748> nil "/home/ab/.emacs.d/config.el" nil t)  ; Reading at buffer position 21593
  load-with-code-conversion("/home/ab/.emacs.d/config.el" "/home/ab/.emacs.d/config.el" nil nil)
  load("/home/ab/.emacs.d/config.el" nil nil t)
  load-file("~/.emacs.d/config.el")
  (let ((orgfile (concat my-user-emacs-directory "config.org")) (elfile (concat my-user-emacs-directory "config.el")) (gc-cons-threshold most-positive-fixnum)) (if (or (not (file-exists-p elfile)) (file-newer-than-file-p orgfile elfile)) (progn (my-tangle-config-org))) (load-file elfile))
  eval-buffer(#<buffer  *load*> nil "/home/ab/.emacs.d/init.el" nil t)  ; Reading at buffer position 5421
  load-with-code-conversion("/home/ab/.emacs.d/init.el" "/home/ab/.emacs.d/init.el" t t)
  load("/home/ab/.emacs.d/init" t t)
  #f(compiled-function () #<bytecode 0x25f7fd>)()
  command-line()
  normal-top-level()

Cheers.

Inline code starting with `r#` not detected

A while back knitr added the option to start inline code with r# instead of r to solve some issues with line wrapping (see here). poly-R doesn't recognize this code as R though.

I was able to get the right behavior by changing the head-matcher for poly-r-markdown-inline-code-innermode to [^`]\\(`{?[rR]}?[ #\t]\\). Not sure I understand the package well enough to submit a proper pull request though.

Cannot evaluate R in flatwhatson/emacs-pgtk-nativecomp build

I recently upgraded to pgtk-nativecomp, now using my forked build here: Copr bacarson/emacs-pgtk-nativecomp.

This build allows Polymode to compile and run (I don't experience polymode/polymode#285).

Observed Behaviour

I cannot evaluate any R code blocks in Rmd files, nor anything in R files. In both cases, upon C^c C^j, I get this message: ad-Advice-select-window: Wrong type argument: window-live-p, nil. In order to evaluate anything, I have to use polymode-export to run the entire Rmd document's code blocks and regenerate the HTML I'm exporting to.

Expected Behaviour

  • Evaluate code blocks with C^c C^r or lines with C^c C^j
  • Markdown export (C^c C^c e) should trigger polymode-export, not simply convert MD to HTML

I'm noobish, however, so I'm not sure how to properly introspect the issue.

Emacs Version

Build Information / Commit

Information from SPC h d s

#### System Info :computer:
- OS: gnu/linux
- Emacs: 28.0.50
- Spacemacs: 0.300.0
- Spacemacs branch: develop (rev. 369cf7519)
- Graphic display: t
- Distribution: spacemacs
- Editing style: vim
- Completion: helm
- Layers:
‘‘‘elisp
(html emacs-lisp helm multiple-cursors treemacs)
‘‘‘
- System configuration features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PGTK PNG RSVG SOUND THREADS TIFF TOOLKIT_SCROLL_BARS XIM XWIDGETS GTK3 ZLIB

.spacemacs

Package information

Polymode

     Status: Installed in ‘polymode-20200606.1106/’ (unsigned).
    Version: 20200606.1106
     Commit: b3871e946d278a256d95a3bd4615b1df234ad75a

poly-R

     Status: Installed in ‘poly-R-20210210.1053/’ (unsigned).
    Version: 20210210.1053
     Commit: c42ff3a4d0da96ccb7f826dca5c6b2eb558a2ab5

Package Install & Compile Order is specific

  • Polymode packages should be installed in a specific order.
  • If the packages are already installed, reinstall them using M^x package-reinstall in this order:
  1. ess
  2. polymode
  3. poly-noweb
  4. poly-R
  5. poly-markdown
  • This is what worked for myself, using Spacemacs and this Copr build.

Pandoc/LaTeX errors caused by appending "[exported]" to directory name.

When compiling from Rmarkdown to PDF, poly-R puts intermediate files in a directory test[exported]_files. A bug in Pandoc causes the braces to placed around brackets when referring to files in this directory like so:

\includegraphics{test{[}exported{]}_files/figure-latex/unnamed-chunk-2-1.pdf}.

This is causes LaTeX compile to fail with the error:

! Package pdftex.def Error: File `test{[}exported{]}_files/figure-latex/unnamed -chunk-2-1.pdf' not found: using draft setting.

Note RMarkdown always fails to compile a pdf document that has square brackets in the filename, due to the same Pandoc bug.

execute one/some/all R chunks from Rmd buffer in ESS buffer

Before the refactoring of polymode this summer, some EmacsLisp code existed allowing to interactively execute one/some/all R chunks from a Rmd buffer into an ESS buffer (see here), which made Emacs+ESS+polymode a very useful replacement of RStudio.

However, the refactoring seems to have broken this code, and an error message points towards pm-map-over-spans. Below is a minimal reproducible example tested under Ubuntu 16.04, Emacs 26.1 with all packages up-to-date (ess-20181010.1844, polymode 20181010.2138, poly-R 20181010.2137 and their dependencies).

Here is the Rmd file saved in a file named test.Rmd:

---
title: "..."
author: "..."
date: "..."
output: html_document
---

```{r}
x <- 42
x
```

Here are the Rmd functions saved in a file named rmd.el:


(eval-when-compile
  (require 'polymode-core)  ;; SO format :('
  (defvar pm/chunkmode))
(declare-function pm-map-over-spans "polymode-core")
(declare-function pm-narrow-to-span "polymode-core")

(defun rmd-insert-chunk (header)
  "Insert an R chunk."
  (interactive "sHeader: ")
	(if (equal "" header)
			(insert (concat "```{r}\n\n```"))
		(insert (concat "```{r " header "}\n\n```")))
  (forward-line -1))

(defun rmd-send-chunk ()
  "Send current R chunk to ess process."
  (interactive)
  (and (eq (oref pm/chunkmode :mode) 'r-mode) ;;'
       (pm-with-narrowed-to-span nil
         (goto-char (point-min))
         (forward-line)
         (ess-eval-region (point) (point-max) nil nil 'R)))) ;;'

(defun rmd-send-buffer (arg)
  "Send all R code blocks in buffer to ess process. With prefix
send regions above point."
  (interactive "P")
  (save-restriction
    (widen)
    (save-excursion
      (pm-map-over-spans
       'rmd-send-chunk (point-min) ;;'
       ;; adjust this point to send prior regions
       (if arg (point) (point-max))))))

Here is the workflow:

  1. launch Emacs;
  2. open the Rmd file via C-x C-f test.Rmd in a polymode buffer;
  3. put the cursor inside the R chunk and do C-c C-z which automatically opens an ESS buffer;
  4. load the ELisp functions via M-x load-file rmd.el;
  5. put the cursor of the polymode buffer inside the R chunk and do M-x rmd-send-chunk; at this stage, the following message appears in the ESS buffer: Error: object 'x' not found, but the *Messages* buffer only displays Eval region;
  6. put the cursor at the end of the polymode buffer and do M-x rmd-send-buffer; at this stage, the following message appears in the mini-buffer as well as in the *Messages* buffer: Wrong number of arguments: (lambda nil "Send current R chunk to ess process." (interactive) (and (eq (eieio-oref pm/chunkmode (quote :mode)) (quote r-mode)) (save-restriction \ (pm-narrow-to-span nil) (goto-char (point-min)) (forward-line) (ess-eval-region (point) (point-max) nil nil (quote R))))), 1.

By any chance, do you have any idea?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.