{"action":"created","comment":{"url":"https://api.github.com/repos/emacs-ess/ESS/pulls/comments/168462743","pull_request_review_id":96831248,"id":168462743,"diff_hunk":"@@ -242,53 +179,144 @@ Root is determined by locating `ess-r-package-root-file'.\"\n           (intern (match-string 1)))))))\n \n \f\n+;;;*;;; UI\n+\n+(defun ess-r-package-use-dir ()\n+  \"Set process directory to current package directory.\"\n+  (interactive)\n+  (let ((dir (cdr (ess-r-package-project))))\n+    (ess-use-dir dir)))\n+\n+(defun ess-r-package-set-package ()\n+  \"Set a package for ESS r-package commands.\"\n+  (interactive)\n+  (let* ((pkg-path (read-directory-name\n+                    \"Path: \" (or (ess-r-package--find-package-path)\n+                                 ess-r-package-library-path)\n+                    nil t))\n+         (pkg-name (ess-r-package--find-package-name pkg-path))\n+         (pkg-info (cons pkg-name pkg-path)))\n+    (unless (and pkg-name pkg-path\n+                 (file-exists-p (expand-file-name ess-r-package-root-file pkg-path)))\n+      (error \"Not a valid package. No '%s' found in `%s'.\" ess-r-package-root-file pkg-path))\n+    (message (format \"%s selected and added to file-local variables\" pkg-name))\n+    (save-excursion\n+      (add-file-local-variable 'ess-r-package--project-cache pkg-info))\n+    (setq ess-r-package--project-cache pkg-info)))\n+\n+\f\n+;;;*;;; Evaluation\n+\n+(defun ess-r-package-enable-namespaced-evaluation ()\n+  \"Enable namespaced evaluation in current buffer.\n+Namespaced evaluation is enabled if\n+`ess-r-package-auto-enable-namespaced-evaluation' is non-nil.\"\n+  (when ess-r-package-auto-enable-namespaced-evaluation\n+    (let ((path (cdr (ess-r-package-project))))\n+      ;; Check that we are in a file within R/\n+      (when (and path\n+                 (let* ((subpath (substring default-directory\n+                                            (1+ (length path))\n+                                            (length default-directory)))\n+                        (subpath (substring subpath 0 2)))\n+                   (string= subpath (file-name-as-directory \"R\"))))\n+        (ess-r-set-evaluation-env (ess-r-package-name))))))\n+\n+(add-hook 'R-mode-hook 'ess-r-package-enable-namespaced-evaluation)\n+\n+(defun ess-r-package-eval-linewise (command &optional msg p actions pkg-path)\n+  \"Send COMMAND to R process.\n+COMMAND is a command string with %s placeholder for the\n+arguments. MSG is the message displayed in minibuffer with %s\n+placeholder for the package name. P is the value of universal\n+argument usually received from the upstream command and indicates\n+which action in ACTIONS list to perform; if 0 or nil, first\n+action, if 1 or (4) second if 2 or (16) third etc. ACTIONS is a\n+list of strings (R arguments), or functions which return R\n+arguments, or expressions which return R arguments.\"\n+  (inferior-ess-r-force)\n+  (let* ((pkg-info (or (ess-r-package-project)\n+                       (ess-r-package-set-package)))\n+         (pkg-name (ess-r-package-name))\n+         (pkg-path (or pkg-path (concat \"'\" (cdr pkg-info) \"'\")))\n+         (args (ess-r-command--build-args p actions)))\n+    (message msg pkg-name)\n+    (with-ess-process-buffer nil\n+      (setq ess-r-package--project-cache ess-r-package--project-cache))\n+    (ess-eval-linewise (format command (concat pkg-path args)))))\n+\n+(defun ess-r-command--build-args (ix &optional actions)\n+  (let* ((n (cond ((null ix) 0)\n+                  ((listp ix) (round (log (car ix) 4)))\n+                  ((integer ix) ix)\n+                  (t (error \"Invalid index\"))))\n+         (action (nth n actions))\n+         (args (cond ((null action) \"\")\n+                     ((stringp action) action)\n+                     ((functionp action) (funcall action))\n+                     ((listp action) (eval action))\n+                     (t (error \"Invalid action\")))))\n+    (if (string= \"\" args)\n+        args\n+      (concat \", \" args))))\n+\n+\f\n ;;;*;;; Devtools Integration\n \n-(defun ess-r-devtools-load-package (&optional alt)\n-  \"Interface for `devtools::load_all()'.\"\n+(defun ess-r-devtools-load-package (&optional arg)\n+  \"Interface for `devtools::load_all()'.\n+With prefix ARG ask for extra args.\"\n   (interactive \"P\")\n-  (ess-r-package-send-process \"devtools::load_all(%s)\\n\"\n-                              \"Loading %s\"\n-                              alt \"recompile = TRUE\"))\n+  (ess-r-package-eval-linewise\n+   \"devtools::load_all(%s)\\n\" \"Loading %s\" arg\n+   '(\"\" (read-string \"Load args:\" \"recompile = TRUE\"))))","path":"lisp/ess-r-package.el","position":218,"original_position":218,"commit_id":"3b401e008b37d5b3cbe3193dda6a2873b20c1275","original_commit_id":"3b401e008b37d5b3cbe3193dda6a2873b20c1275","user":{"login":"vspinu","id":1363467,"avatar_url":"https://avatars3.githubusercontent.com/u/1363467?v=4","gravatar_id":"","url":"https://api.github.com/users/vspinu","html_url":"https://github.com/vspinu","followers_url":"https://api.github.com/users/vspinu/followers","following_url":"https://api.github.com/users/vspinu/following{/other_user}","gists_url":"https://api.github.com/users/vspinu/gists{/gist_id}","starred_url":"https://api.github.com/users/vspinu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vspinu/subscriptions","organizations_url":"https://api.github.com/users/vspinu/orgs","repos_url":"https://api.github.com/users/vspinu/repos","events_url":"https://api.github.com/users/vspinu/events{/privacy}","received_events_url":"https://api.github.com/users/vspinu/received_events","type":"User","site_admin":false},"body":"Good catch.","created_at":"2018-02-15T12:36:17Z","updated_at":"2018-02-15T12:36:17Z","html_url":"https://github.com/emacs-ess/ESS/pull/479#discussion_r168462743","pull_request_url":"https://api.github.com/repos/emacs-ess/ESS/pulls/479","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/emacs-ess/ESS/pulls/comments/168462743"},"html":{"href":"https://github.com/emacs-ess/ESS/pull/479#discussion_r168462743"},"pull_request":{"href":"https://api.github.com/repos/emacs-ess/ESS/pulls/479"}},"in_reply_to_id":168376840},"pull_request":{"url":"https://api.github.com/repos/emacs-ess/ESS/pulls/479","id":166940410,"html_url":"https://github.com/emacs-ess/ESS/pull/479","diff_url":"https://github.com/emacs-ess/ESS/pull/479.diff","patch_url":"https://github.com/emacs-ess/ESS/pull/479.patch","issue_url":"https://api.github.com/repos/emacs-ess/ESS/issues/479","number":479,"state":"open","locked":false,"title":"ess-r-package improvements","user":{"login":"vspinu","id":1363467,"avatar_url":"https://avatars3.githubusercontent.com/u/1363467?v=4","gravatar_id":"","url":"https://api.github.com/users/vspinu","html_url":"https://github.com/vspinu","followers_url":"https://api.github.com/users/vspinu/followers","following_url":"https://api.github.com/users/vspinu/following{/other_user}","gists_url":"https://api.github.com/users/vspinu/gists{/gist_id}","starred_url":"https://api.github.com/users/vspinu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vspinu/subscriptions","organizations_url":"https://api.github.com/users/vspinu/orgs","repos_url":"https://api.github.com/users/vspinu/repos","events_url":"https://api.github.com/users/vspinu/events{/privacy}","received_events_url":"https://api.github.com/users/vspinu/received_events","type":"User","site_admin":false},"body":"A bunch of improvements aimed to increase devtools command flexibility. Once approved, I would like to add customization variables for each devtools command actions. ","created_at":"2018-02-03T02:07:18Z","updated_at":"2018-02-15T12:36:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a1285823c46c6d1f3d3d9e20665cf4dd2df3830b","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/emacs-ess/ESS/pulls/479/commits","review_comments_url":"https://api.github.com/repos/emacs-ess/ESS/pulls/479/comments","review_comment_url":"https://api.github.com/repos/emacs-ess/ESS/pulls/comments{/number}","comments_url":"https://api.github.com/repos/emacs-ess/ESS/issues/479/comments","statuses_url":"https://api.github.com/repos/emacs-ess/ESS/statuses/3b401e008b37d5b3cbe3193dda6a2873b20c1275","head":{"label":"emacs-ess:r-package","ref":"r-package","sha":"3b401e008b37d5b3cbe3193dda6a2873b20c1275","user":{"login":"emacs-ess","id":1433218,"avatar_url":"https://avatars2.githubusercontent.com/u/1433218?v=4","gravatar_id":"","url":"https://api.github.com/users/emacs-ess","html_url":"https://github.com/emacs-ess","followers_url":"https://api.github.com/users/emacs-ess/followers","following_url":"https://api.github.com/users/emacs-ess/following{/other_user}","gists_url":"https://api.github.com/users/emacs-ess/gists{/gist_id}","starred_url":"https://api.github.com/users/emacs-ess/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emacs-ess/subscriptions","organizations_url":"https://api.github.com/users/emacs-ess/orgs","repos_url":"https://api.github.com/users/emacs-ess/repos","events_url":"https://api.github.com/users/emacs-ess/events{/privacy}","received_events_url":"https://api.github.com/users/emacs-ess/received_events","type":"Organization","site_admin":false},"repo":{"id":3585447,"name":"ESS","full_name":"emacs-ess/ESS","owner":{"login":"emacs-ess","id":1433218,"avatar_url":"https://avatars2.githubusercontent.com/u/1433218?v=4","gravatar_id":"","url":"https://api.github.com/users/emacs-ess","html_url":"https://github.com/emacs-ess","followers_url":"https://api.github.com/users/emacs-ess/followers","following_url":"https://api.github.com/users/emacs-ess/following{/other_user}","gists_url":"https://api.github.com/users/emacs-ess/gists{/gist_id}","starred_url":"https://api.github.com/users/emacs-ess/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emacs-ess/subscriptions","organizations_url":"https://api.github.com/users/emacs-ess/orgs","repos_url":"https://api.github.com/users/emacs-ess/repos","events_url":"https://api.github.com/users/emacs-ess/events{/privacy}","received_events_url":"https://api.github.com/users/emacs-ess/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/emacs-ess/ESS","description":"Emacs Speaks Statistics: ESS","fork":false,"url":"https://api.github.com/repos/emacs-ess/ESS","forks_url":"https://api.github.com/repos/emacs-ess/ESS/forks","keys_url":"https://api.github.com/repos/emacs-ess/ESS/keys{/key_id}","collaborators_url":"https://api.github.com/repos/emacs-ess/ESS/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/emacs-ess/ESS/teams","hooks_url":"https://api.github.com/repos/emacs-ess/ESS/hooks","issue_events_url":"https://api.github.com/repos/emacs-ess/ESS/issues/events{/number}","events_url":"https://api.github.com/repos/emacs-ess/ESS/events","assignees_url":"https://api.github.com/repos/emacs-ess/ESS/assignees{/user}","branches_url":"https://api.github.com/repos/emacs-ess/ESS/branches{/branch}","tags_url":"https://api.github.com/repos/emacs-ess/ESS/tags","blobs_url":"https://api.github.com/repos/emacs-ess/ESS/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/emacs-ess/ESS/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/emacs-ess/ESS/git/refs{/sha}","trees_url":"https://api.github.com/repos/emacs-ess/ESS/git/trees{/sha}","statuses_url":"https://api.github.com/repos/emacs-ess/ESS/statuses/{sha}","languages_url":"https://api.github.com/repos/emacs-ess/ESS/languages","stargazers_url":"https://api.github.com/repos/emacs-ess/ESS/stargazers","contributors_url":"https://api.github.com/repos/emacs-ess/ESS/contributors","subscribers_url":"https://api.github.com/repos/emacs-ess/ESS/subscribers","subscription_url":"https://api.github.com/repos/emacs-ess/ESS/subscription","commits_url":"https://api.github.com/repos/emacs-ess/ESS/commits{/sha}","git_commits_url":"https://api.github.com/repos/emacs-ess/ESS/git/commits{/sha}","comments_url":"https://api.github.com/repos/emacs-ess/ESS/comments{/number}","issue_comment_url":"https://api.github.com/repos/emacs-ess/ESS/issues/comments{/number}","contents_url":"https://api.github.com/repos/emacs-ess/ESS/contents/{+path}","compare_url":"https://api.github.com/repos/emacs-ess/ESS/compare/{base}...{head}","merges_url":"https://api.github.com/repos/emacs-ess/ESS/merges","archive_url":"https://api.github.com/repos/emacs-ess/ESS/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/emacs-ess/ESS/downloads","issues_url":"https://api.github.com/repos/emacs-ess/ESS/issues{/number}","pulls_url":"https://api.github.com/repos/emacs-ess/ESS/pulls{/number}","milestones_url":"https://api.github.com/repos/emacs-ess/ESS/milestones{/number}","notifications_url":"https://api.github.com/repos/emacs-ess/ESS/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/emacs-ess/ESS/labels{/name}","releases_url":"https://api.github.com/repos/emacs-ess/ESS/releases{/id}","deployments_url":"https://api.github.com/repos/emacs-ess/ESS/deployments","created_at":"2012-02-29T20:13:38Z","updated_at":"2018-02-13T00:13:52Z","pushed_at":"2018-02-14T20:49:19Z","git_url":"git://github.com/emacs-ess/ESS.git","ssh_url":"git@github.com:emacs-ess/ESS.git","clone_url":"https://github.com/emacs-ess/ESS.git","svn_url":"https://github.com/emacs-ess/ESS","homepage":"http://ess.r-project.org/","size":22188,"stargazers_count":337,"watchers_count":337,"language":"Emacs Lisp","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":101,"mirror_url":null,"archived":false,"open_issues_count":121,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0"},"forks":101,"open_issues":121,"watchers":337,"default_branch":"master"}},"base":{"label":"emacs-ess:master","ref":"master","sha":"9329b410bec2004ec6199bb5070f2072f5b18330","user":{"login":"emacs-ess","id":1433218,"avatar_url":"https://avatars2.githubusercontent.com/u/1433218?v=4","gravatar_id":"","url":"https://api.github.com/users/emacs-ess","html_url":"https://github.com/emacs-ess","followers_url":"https://api.github.com/users/emacs-ess/followers","following_url":"https://api.github.com/users/emacs-ess/following{/other_user}","gists_url":"https://api.github.com/users/emacs-ess/gists{/gist_id}","starred_url":"https://api.github.com/users/emacs-ess/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emacs-ess/subscriptions","organizations_url":"https://api.github.com/users/emacs-ess/orgs","repos_url":"https://api.github.com/users/emacs-ess/repos","events_url":"https://api.github.com/users/emacs-ess/events{/privacy}","received_events_url":"https://api.github.com/users/emacs-ess/received_events","type":"Organization","site_admin":false},"repo":{"id":3585447,"name":"ESS","full_name":"emacs-ess/ESS","owner":{"login":"emacs-ess","id":1433218,"avatar_url":"https://avatars2.githubusercontent.com/u/1433218?v=4","gravatar_id":"","url":"https://api.github.com/users/emacs-ess","html_url":"https://github.com/emacs-ess","followers_url":"https://api.github.com/users/emacs-ess/followers","following_url":"https://api.github.com/users/emacs-ess/following{/other_user}","gists_url":"https://api.github.com/users/emacs-ess/gists{/gist_id}","starred_url":"https://api.github.com/users/emacs-ess/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/emacs-ess/subscriptions","organizations_url":"https://api.github.com/users/emacs-ess/orgs","repos_url":"https://api.github.com/users/emacs-ess/repos","events_url":"https://api.github.com/users/emacs-ess/events{/privacy}","received_events_url":"https://api.github.com/users/emacs-ess/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/emacs-ess/ESS","description":"Emacs Speaks Statistics: ESS","fork":false,"url":"https://api.github.com/repos/emacs-ess/ESS","forks_url":"https://api.github.com/repos/emacs-ess/ESS/forks","keys_url":"https://api.github.com/repos/emacs-ess/ESS/keys{/key_id}","collaborators_url":"https://api.github.com/repos/emacs-ess/ESS/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/emacs-ess/ESS/teams","hooks_url":"https://api.github.com/repos/emacs-ess/ESS/hooks","issue_events_url":"https://api.github.com/repos/emacs-ess/ESS/issues/events{/number}","events_url":"https://api.github.com/repos/emacs-ess/ESS/events","assignees_url":"https://api.github.com/repos/emacs-ess/ESS/assignees{/user}","branches_url":"https://api.github.com/repos/emacs-ess/ESS/branches{/branch}","tags_url":"https://api.github.com/repos/emacs-ess/ESS/tags","blobs_url":"https://api.github.com/repos/emacs-ess/ESS/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/emacs-ess/ESS/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/emacs-ess/ESS/git/refs{/sha}","trees_url":"https://api.github.com/repos/emacs-ess/ESS/git/trees{/sha}","statuses_url":"https://api.github.com/repos/emacs-ess/ESS/statuses/{sha}","languages_url":"https://api.github.com/repos/emacs-ess/ESS/languages","stargazers_url":"https://api.github.com/repos/emacs-ess/ESS/stargazers","contributors_url":"https://api.github.com/repos/emacs-ess/ESS/contributors","subscribers_url":"https://api.github.com/repos/emacs-ess/ESS/subscribers","subscription_url":"https://api.github.com/repos/emacs-ess/ESS/subscription","commits_url":"https://api.github.com/repos/emacs-ess/ESS/commits{/sha}","git_commits_url":"https://api.github.com/repos/emacs-ess/ESS/git/commits{/sha}","comments_url":"https://api.github.com/repos/emacs-ess/ESS/comments{/number}","issue_comment_url":"https://api.github.com/repos/emacs-ess/ESS/issues/comments{/number}","contents_url":"https://api.github.com/repos/emacs-ess/ESS/contents/{+path}","compare_url":"https://api.github.com/repos/emacs-ess/ESS/compare/{base}...{head}","merges_url":"https://api.github.com/repos/emacs-ess/ESS/merges","archive_url":"https://api.github.com/repos/emacs-ess/ESS/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/emacs-ess/ESS/downloads","issues_url":"https://api.github.com/repos/emacs-ess/ESS/issues{/number}","pulls_url":"https://api.github.com/repos/emacs-ess/ESS/pulls{/number}","milestones_url":"https://api.github.com/repos/emacs-ess/ESS/milestones{/number}","notifications_url":"https://api.github.com/repos/emacs-ess/ESS/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/emacs-ess/ESS/labels{/name}","releases_url":"https://api.github.com/repos/emacs-ess/ESS/releases{/id}","deployments_url":"https://api.github.com/repos/emacs-ess/ESS/deployments","created_at":"2012-02-29T20:13:38Z","updated_at":"2018-02-13T00:13:52Z","pushed_at":"2018-02-14T20:49:19Z","git_url":"git://github.com/emacs-ess/ESS.git","ssh_url":"git@github.com:emacs-ess/ESS.git","clone_url":"https://github.com/emacs-ess/ESS.git","svn_url":"https://github.com/emacs-ess/ESS","homepage":"http://ess.r-project.org/","size":22188,"stargazers_count":337,"watchers_count":337,"language":"Emacs Lisp","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":101,"mirror_url":null,"archived":false,"open_issues_count":121,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0"},"forks":101,"open_issues":121,"watchers":337,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/emacs-ess/ESS/pulls/479"},"html":{"href":"https://github.com/emacs-ess/ESS/pull/479"},"issue":{"href":"https://api.github.com/repos/emacs-ess/ESS/issues/479"},"comments":{"href":"https://api.github.com/repos/emacs-ess/ESS/issues/479/comments"},"review_comments":{"href":"https://api.github.com/repos/emacs-ess/ESS/pulls/479/comments"},"review_comment":{"href":"https://api.github.com/repos/emacs-ess/ESS/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/emacs-ess/ESS/pulls/479/commits"},"statuses":{"href":"https://api.github.com/repos/emacs-ess/ESS/statuses/3b401e008b37d5b3cbe3193dda6a2873b20c1275"}},"author_association":"OWNER"}}
{"actor":{"display_login":"vspinu"}}