update packages
This commit is contained in:
@@ -383,6 +383,7 @@ To be used as part of `font-lock-defaults' keywords."
|
||||
'((ess-local-customize-alist . 'ess-r-customize-alist)
|
||||
(ess-dialect . "R")
|
||||
(ess-suffix . "R")
|
||||
(ess-format-command-alist . ess-r-format-command-alist)
|
||||
(ess-traceback-command . ess-r-traceback-command)
|
||||
(ess-call-stack-command . ess-r-call-stack-command)
|
||||
(ess-mode-completion-syntax-table . ess-r-completion-syntax-table)
|
||||
@@ -418,6 +419,14 @@ fill=TRUE); try(traceback(), silent=TRUE)})\n")
|
||||
|
||||
(defvar ess-r-call-stack-command "traceback(1)\n")
|
||||
|
||||
(defun ess-r-format-command (cmd &rest args)
|
||||
(let ((sentinel (alist-get 'output-sentinel args)))
|
||||
(format ".ess.command(%s, '%s')\n" cmd sentinel)))
|
||||
|
||||
(defvar ess-r-format-command-alist
|
||||
'((fun . ess-r-format-command)
|
||||
(use-sentinel . t)))
|
||||
|
||||
(defvar ess-r-dump-filename-template
|
||||
(replace-regexp-in-string
|
||||
"S$" "R" ess-dump-filename-template-proto))
|
||||
@@ -540,11 +549,13 @@ will be prompted to enter arguments interactively."
|
||||
(ess-write-to-dribble-buffer
|
||||
(format "(R): inferior-ess-language-start=%s\n"
|
||||
inferior-ess-language-start)))
|
||||
;; FIXME: Current ob-R expects current buffer set to process buffer
|
||||
(set-buffer inf-buf))))
|
||||
inf-buf)))
|
||||
|
||||
;;;###autoload
|
||||
(defalias 'R #'run-ess-r)
|
||||
(defun R (&optional start-args)
|
||||
(interactive "P")
|
||||
;; FIXME: Current ob-R expects current buffer set to process buffer
|
||||
(set-buffer (run-ess-r start-args)))
|
||||
|
||||
(defun inferior-ess-r--adjust-startup-directory (dir dialect)
|
||||
"Adjust startup directory DIR if DIALECT is R.
|
||||
@@ -564,14 +575,25 @@ the package directory was selected in the first place."
|
||||
(defun inferior-ess-r--init-callback (_proc _name)
|
||||
(R-initialize-on-start))
|
||||
|
||||
(defmacro ess-r--without-format-command (&rest body)
|
||||
(declare (indent 0)
|
||||
(debug (&rest form)))
|
||||
`(with-current-buffer (process-buffer (ess-command--get-proc nil nil))
|
||||
(let ((old-alist ess-format-command-alist))
|
||||
(unwind-protect
|
||||
(progn
|
||||
(setq ess-format-command-alist nil)
|
||||
,@body)
|
||||
(setq ess-format-command-alist old-alist)))))
|
||||
|
||||
(defun R-initialize-on-start ()
|
||||
"This function is run after the first R prompt.
|
||||
Executed in process buffer."
|
||||
(ess-command (format
|
||||
"if(identical(getOption('pager'),
|
||||
file.path(R.home(), 'bin', 'pager')))
|
||||
options(pager='%s')\n"
|
||||
inferior-ess-pager))
|
||||
(ess-r--without-format-command
|
||||
(ess-command (format
|
||||
"if (identical(getOption('pager'), file.path(R.home(), 'bin', 'pager')))
|
||||
options(pager = '%s')\n"
|
||||
inferior-ess-pager)))
|
||||
(ess-r-load-ESSR)
|
||||
(when inferior-ess-language-start
|
||||
(ess-command (concat inferior-ess-language-start "\n")))
|
||||
@@ -879,7 +901,10 @@ prompt for command line arguments."
|
||||
(let ((inferior-ess-r-program ess-newest-R))
|
||||
(run-ess-r start-args)))
|
||||
|
||||
(defalias 'R-newest 'run-ess-r-newest)
|
||||
(defun R-newest (&optional start-args)
|
||||
(interactive "P")
|
||||
;; FIXME: Current ob-R expects current buffer set to process buffer
|
||||
(set-buffer (run-ess-r-newest start-args)))
|
||||
|
||||
;; (ess-r-version-date "R-2.5.1") (ess-r-version-date "R-patched")
|
||||
;; (ess-r-version-date "R-1.2.1") (ess-r-version-date "R-1.8.1")
|
||||
@@ -1039,7 +1064,7 @@ With argument UPDATE, update cached packages list."
|
||||
(not ess--packages-cache))
|
||||
(message "Fetching R packages ... ")
|
||||
(setq ess--packages-cache
|
||||
(ess-get-words-from-vector "print(rownames(available.packages()), max=1e6)\n")))
|
||||
(ess-get-words-from-vector--foreground "print(rownames(available.packages()), max=1e6)\n")))
|
||||
(let* ((ess-eval-visibly-p t)
|
||||
(package (or package
|
||||
(ess-completing-read "Package to install" ess--packages-cache))))
|
||||
@@ -1092,7 +1117,7 @@ Placed into `ess-presend-filter-functions' for R dialects."
|
||||
|
||||
(cl-defmethod ess-installed-packages (&context (ess-dialect "R"))
|
||||
;;; FIXME? .packages() does not cache; installed.packages() does but is slower first time
|
||||
(ess-get-words-from-vector "print(.packages(T), max=1e6)\n"))
|
||||
(ess-get-words-from-vector--foreground "print(.packages(T), max=1e6)\n"))
|
||||
|
||||
(cl-defmethod ess-load-library--override (pack &context (ess-dialect "R"))
|
||||
"Load an R package."
|
||||
@@ -1159,9 +1184,7 @@ variable.")
|
||||
|
||||
(defun ess-r-get-evaluation-env ()
|
||||
"Get current evaluation env."
|
||||
(or ess-r-evaluation-env
|
||||
(and ess-current-process-name
|
||||
(ess-get-process-variable 'ess-r-evaluation-env))))
|
||||
ess-r-evaluation-env)
|
||||
|
||||
(defun ess-r-set-evaluation-env (&optional arg)
|
||||
"Select a package namespace for evaluation of R code.
|
||||
@@ -1179,7 +1202,6 @@ attached packages."
|
||||
(t "*none*"))))
|
||||
(if (equal env "*none*")
|
||||
(let ((cur-env (ess-r-get-evaluation-env)))
|
||||
;; fixme: does not work if env is set at process level
|
||||
(setq ess-r-evaluation-env nil)
|
||||
(delq 'ess-r--evaluation-env-mode-line ess--local-mode-line-process-indicator)
|
||||
(message (format "Evaluation in %s disabled" (propertize cur-env 'face font-lock-function-name-face))))
|
||||
@@ -1269,7 +1291,7 @@ selected (see `ess-r-set-evaluation-env')."
|
||||
(command (format inferior-ess-r-help-command object)))
|
||||
(if pkg-dir
|
||||
;; Invoking `print.help_files_with_topic'
|
||||
(format "do.call(structure, c('%s', attributes(%s)))\n" pkg-dir command)
|
||||
(format "base::evalq(do.call(structure, c('%s', attributes(%s))), base::as.environment('ESSR'))\n" pkg-dir command)
|
||||
command))))
|
||||
|
||||
(cl-defmethod ess-build-help-command (object &context (ess-dialect "R"))
|
||||
@@ -1334,16 +1356,20 @@ selected (see `ess-r-set-evaluation-env')."
|
||||
|
||||
(defun ess-r-load-ESSR ()
|
||||
"Load ESSR functionality."
|
||||
(cond
|
||||
((file-remote-p (ess-get-process-variable 'default-directory))
|
||||
(if (eq ess-r-fetch-ESSR-on-remotes t)
|
||||
(ess-r--fetch-ESSR-remote)
|
||||
(ess-r--load-ESSR-remote)))
|
||||
((and (bound-and-true-p ess-remote))
|
||||
(if ess-r-fetch-ESSR-on-remotes
|
||||
(ess-r--fetch-ESSR-remote)
|
||||
(ess-r--load-ESSR-remote t)))
|
||||
(t (ess-r--load-ESSR-local))))
|
||||
;; `.ess.command()` is not defined until ESSR is loaded so disable
|
||||
;; it temporarily. Would be helpful to implement an `inferior-ess-let'
|
||||
;; macro .
|
||||
(ess-r--without-format-command
|
||||
(cond
|
||||
((file-remote-p (ess-get-process-variable 'default-directory))
|
||||
(if (eq ess-r-fetch-ESSR-on-remotes t)
|
||||
(ess-r--fetch-ESSR-remote)
|
||||
(ess-r--load-ESSR-remote)))
|
||||
((and (bound-and-true-p ess-remote))
|
||||
(if ess-r-fetch-ESSR-on-remotes
|
||||
(ess-r--fetch-ESSR-remote)
|
||||
(ess-r--load-ESSR-remote t)))
|
||||
(t (ess-r--load-ESSR-local)))))
|
||||
|
||||
(defun ess-r--load-ESSR-local ()
|
||||
(let* ((src-dir (expand-file-name "ESSR/R" ess-etc-directory))
|
||||
@@ -1352,7 +1378,7 @@ selected (see `ess-r-set-evaluation-env')."
|
||||
.ess.load.ESSR('%s')
|
||||
})\n"
|
||||
src-dir src-dir)))
|
||||
(with-current-buffer (ess-command cmd)
|
||||
(with-current-buffer (ess-command cmd nil nil nil nil nil nil 5)
|
||||
(let ((msg (buffer-string)))
|
||||
(when (> (length msg) 1)
|
||||
(message (format "Messages while loading ESSR: %s" msg)))))))
|
||||
@@ -2324,13 +2350,14 @@ If the current buffer does not have a usage section, return nil."
|
||||
(forward-line -1)
|
||||
(narrow-to-region usage-beg (point))
|
||||
(goto-char (point-min))
|
||||
;; Match objects until a parens
|
||||
(while (re-search-forward (rx bol (0+ whitespace) (not (syntax comment-delimiter))
|
||||
(group (1+ (not (any "(")))))
|
||||
usage-end t)
|
||||
(push (match-string-no-properties 1) usage-objects)
|
||||
;; Skip past function arguments
|
||||
(forward-list)))
|
||||
(forward-whitespace 1)
|
||||
(while (not (eobp))
|
||||
(if (looking-at (rx (group (1+ (not (any whitespace)))) "("))
|
||||
(progn
|
||||
(push (match-string-no-properties 1) usage-objects)
|
||||
;; Skip past function arguments
|
||||
(forward-list))
|
||||
(forward-whitespace 1))))
|
||||
(when usage-objects
|
||||
;; Get arguments:
|
||||
(setq usage-objects
|
||||
@@ -2457,7 +2484,11 @@ from all installed packages, which can be very slow."
|
||||
(define-key map "l" #'ess-r-package-list-local-packages)
|
||||
(define-key map "r" #'ess-r-package-list-available-packages)
|
||||
(define-key map "u" #'ess-r-package-update-packages)
|
||||
(define-key map "a" #'ess-display-help-apropos)
|
||||
(define-key map "m" #'ess-rutils-rm-all)
|
||||
(define-key map "o" #'ess-rdired)
|
||||
(define-key map "w" #'ess-rutils-load-workspace)
|
||||
(define-key map "s" #'ess-rutils-save-workspace)
|
||||
(define-key map "d" #'ess-change-directory)
|
||||
(define-key map "H" #'ess-rutils-html-docs)
|
||||
map))
|
||||
@@ -2641,15 +2672,17 @@ needed."
|
||||
(when (y-or-n-p "Delete all objects? ")
|
||||
(ess-execute "rm(list=ls())" 'buffer)))
|
||||
|
||||
(defun ess-rutils-load-wkspc (file)
|
||||
(defun ess-rutils-load-workspace (file)
|
||||
"Load workspace FILE into R."
|
||||
(interactive "fFile with workspace to load: ")
|
||||
(ess-execute (concat "load('" file "')") 'buffer))
|
||||
(define-obsolete-function-alias 'ess-rutils-load-wkspc #'ess-rutils-load-workspace "ESS 19.04")
|
||||
|
||||
(defun ess-rutils-save-wkspc (file)
|
||||
(defun ess-rutils-save-workspace (file)
|
||||
"Save FILE workspace as file.RData."
|
||||
(interactive "FSave workspace to file (no extension): ")
|
||||
(ess-execute (concat "save.image('" file ".RData')") 'buffer))
|
||||
(define-obsolete-function-alias 'ess-rutils-save-wkspc #'ess-rutils-save-workspace "ESS 19.04")
|
||||
|
||||
(defun ess-rutils-quit ()
|
||||
"Kill the ess-rutils buffer and return to the iESS buffer."
|
||||
|
||||
Reference in New Issue
Block a user