-
Notifications
You must be signed in to change notification settings - Fork 162
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
Allows some devtools commands to be run in a compilation-mode buffer. #531
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,6 +76,11 @@ All children of these directories are also considered source | |
containing directories. Use `ess-r-package-source-dirs' to get | ||
all source dirs recursively within the current package.") | ||
|
||
(defcustom ess-r-package-use-compile-buffer nil | ||
"When t, run some package commands in a separate compilation buffer." | ||
:group 'ess-r-package | ||
:type 'boolean) | ||
|
||
|
||
;;;*;;; Package Detection | ||
|
||
|
@@ -268,6 +273,20 @@ arguments, or expressions which return R arguments." | |
args | ||
(concat ", " args)))) | ||
|
||
(defun ess-r-package-eval-in-compile-buffer (expr) | ||
"Evalate R expression EXPR in a standalone `compilation-mode' | ||
buffer." | ||
(let* ((procname inferior-ess-r-program-name) | ||
(pkg-info (or (ess-r-package-project) | ||
(ess-r-package-set-package))) | ||
(pkg-name (ess-r-package-name)) | ||
(default-directory (cdr pkg-info)) | ||
(command (format "%s --slave --no-readline -e \"%s\"" procname expr))) | ||
(compilation-start command nil | ||
(lambda (name-of-mode) | ||
(concat "*" (downcase name-of-mode) ":" pkg-name "*")) | ||
ess-r-error-regexp-alist))) | ||
|
||
|
||
;;;*;;; Devtools Integration | ||
|
||
|
@@ -289,9 +308,13 @@ With prefix ARG ask for extra args." | |
"Interface for `devtools::check()'. | ||
With prefix ARG ask for extra args." | ||
(interactive "P") | ||
(ess-r-package-eval-linewise | ||
"devtools::check(%s)\n" "Checking %s" arg | ||
'("" (read-string "Arguments: " "vignettes = FALSE")))) | ||
(let ((actions '("" (read-string "Arguments: " "vignettes = FALSE")))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Too much copy pasting. I would add a wrapper which would dispatch to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had a hard time coming up with a design for such a wrapper -- do you have an idea about how to do it nicely? |
||
(if ess-r-package-use-compile-buffer | ||
(ess-r-package-eval-in-compile-buffer | ||
(format "devtools::check('.'%s)" | ||
(ess-r-command--build-args arg actions))) | ||
(ess-r-package-eval-linewise | ||
"devtools::check(%s)\n" "Checking %s" arg actions)))) | ||
|
||
(defun ess-r-devtools-check-with-winbuilder (&optional arg) | ||
"Interface for `devtools::buildwin()'. | ||
|
@@ -327,9 +350,13 @@ With prefix arg, build with 'vignettes = FALSE'." | |
"Interface for `devtools::test()'. | ||
With prefix argument ARG, run tests on current file only." | ||
(interactive "P") | ||
(ess-r-package-eval-linewise | ||
"devtools::test(%s)\n" "Testing %s" arg | ||
'("" ess-r-devtools--cur-file-filter))) | ||
(let ((actions '("" ess-r-devtools--cur-file-filter))) | ||
(if ess-r-package-use-compile-buffer | ||
(ess-r-package-eval-in-compile-buffer | ||
(format "devtools::test('.'%s)" | ||
(ess-r-command--build-args arg actions))) | ||
(ess-r-package-eval-linewise | ||
"devtools::test(%s)\n" "Testing %s" arg actions)))) | ||
|
||
(defun ess-r-devtools--cur-file-filter () | ||
(let ((file (or (and buffer-file-name | ||
|
@@ -364,9 +391,13 @@ With prefix argument ARG, run tests on current file only." | |
"Interface for `devtools::document()'. | ||
With prefix ARG ask for extra arguments." | ||
(interactive "P") | ||
(ess-r-package-eval-linewise | ||
"devtools::document(%s)\n" "Documenting %s" arg | ||
'("" (read-string "Arguments: ")))) | ||
(let ((actions '("" (read-string "Arguments: ")))) | ||
(if ess-r-package-use-compile-buffer | ||
(ess-r-package-eval-in-compile-buffer | ||
(format "devtools::document('.'%s)" | ||
(ess-r-command--build-args arg actions))) | ||
(ess-r-package-eval-linewise | ||
"devtools::document(%s)\n" "Documenting %s" arg actions)))) | ||
|
||
(defun ess-r-devtools-install-package (&optional arg) | ||
"Interface to `devtools::install()'. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t
instead of nil would result in compilation-shell-minor-mode which should solve the term signals issue.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately this also puts it in
comint-mode
, which is quite a different experience than the usualcompilation-mode
. I don't see an obvious way to get term signal handling outside ofcomint-mode
-- do you have any inkling of what could be done?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does that matter? If compilation mode is based on comint this is how it is.