Skip to content

Conversation

@charJe
Copy link

@charJe charJe commented Jan 27, 2020

No description provided.

@lionel-
Copy link
Member

lionel- commented Jan 27, 2020

I think we should avoid adding small functions piecemeal, and instead implement compilation commands in a consistent way for a range of cases. Connected to #531.

I've been using this for a while.

(defun my-ess-r-eval-in-compile-buffer (expr)
  "Evalate R expression EXPR in a standalone `compilation-mode' buffer."
  (let* ((procname inferior-ess-r-program-name)
         (command (format "%s --slave --no-readline -e \"%s\"" procname expr)))
    (compilation-start command nil
                       (lambda (name-of-mode)
                         (concat "*" (downcase name-of-mode) "*"))
                       ess-r-error-regexp-alist)))

(defun my-ess-rmarkdown-render (arg)
  (interactive "P")
  (let ((cmd (if (file-exists-p "_bookdown.yml")
                 (if arg
                     (format "bookdown::render_book('%s')" buffer-file-name)
                   (format "bookdown::render_book('%s', preview = TRUE)" buffer-file-name))
               (format "rmarkdown::render('%s')" buffer-file-name))))
    (my-ess-r-eval-in-compile-buffer cmd)))

@charJe
Copy link
Author

charJe commented Jan 27, 2020

That's fine with me. I just needed the functionality, and I thought other people might need it too. It should be a part of the master branch. I also think there should be a menu item for discoverability.

@lionel-
Copy link
Member

lionel- commented Apr 26, 2020

I'm closing this for now because this single command would be better suited in the Emacs wiki or in an SO answer. If we're adding compilation-mode support to ESS, it should be part of a larger design.

@lionel- lionel- closed this Apr 26, 2020
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

Successfully merging this pull request may close these issues.

2 participants