23
23
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
24
;; GNU General Public License for more details.
26
;; You should have received a copy of the GNU General Public License
27
;; along with GNU Emacs; see the file COPYING. If not, write to
28
;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26
;; A copy of the GNU General Public License is available at
27
;; http://www.r-project.org/Licenses/
270
269
;; precede R4 and allowes spaces in file path
271
270
(add-to-list 'compilation-error-regexp-alist-alist
272
271
;; start with bol,: but don't start with digit
273
'(R3 "\\(?:^ +\\|: +\\)\\([^-+[:digit:]\n][^:\n]*\\):\\([0-9]+\\):\\([0-9]+\\):" 1 2 3 2 1))
272
'(R3 "\\(?:^ +\\|: +\\)\\([^-+[:digit:]\n]:?[^:\n]*\\):\\([0-9]+\\):\\([0-9]+\\):" 1 2 3 2 1))
275
274
(add-to-list 'compilation-error-regexp-alist-alist
276
275
;; don't start with digit, don't contain spaces
348
351
If you have certain command line arguments that should always be passed
349
352
to R, put them in the variable `inferior-R-args'."
350
353
(interactive "P")
351
;; get settings, notably inferior-R-program-name :
352
(setq ess-customize-alist R-customize-alist)
353
354
(ess-write-to-dribble-buffer ;; for debugging only
355
356
"\n(R): ess-dialect=%s, buf=%s, start-arg=%s\n current-prefix-arg=%s\n"
369
370
(concat " [other than '" r-always-arg "']"))
373
(cust-alist (copy-alist R-customize-alist))
374
(gdbp (string-match-p "gdb" r-start-args))
378
(setcdr (assoc 'inferior-ess-secondary-prompt cust-alist)
379
(format "\\(%s\\)\\|\\((gdb) \\)"
380
(cdr (assoc 'inferior-ess-secondary-prompt cust-alist)))))
374
382
(when (or ess-microsoft-p
375
383
(eq system-type 'cygwin))
376
384
(setq use-dialog-box nil)
377
(if ess-microsoft-p ;; default-process-coding-system would break UTF locales on Unix
378
(setq default-process-coding-system '(undecided-dos . undecided-dos))))
385
(when ess-microsoft-p ;; default-process-coding-system would break UTF locales on Unix
386
(setq default-process-coding-system '(undecided-dos . undecided-dos))))
380
(inferior-ess r-start-args)
388
(inferior-ess r-start-args cust-alist gdbp)
382
390
(ess-process-put 'funargs-pre-cache ess-R--funargs-pre-cache)
391
;; We need to use callback, because R might start with a gdb process
392
(ess-process-put 'callbacks '(R-initialize-on-start))
393
;; trigger the callback
394
(process-send-string (get-process ess-local-process-name) "\n")
384
396
(remove-hook 'completion-at-point-functions 'ess-filename-completion 'local) ;; should be first
385
397
(add-hook 'completion-at-point-functions 'ess-R-object-completion nil 'local)
386
398
(add-hook 'completion-at-point-functions 'ess-filename-completion nil 'local)
388
;;-------------------------
389
399
(setq comint-input-sender 'inferior-R-input-sender)
390
401
(ess-write-to-dribble-buffer
391
402
(format "(R): inferior-ess-language-start=%s\n"
392
inferior-ess-language-start))
394
(when ess-can-eval-in-background
395
(ess-async-command-delayed
396
"invisible(installed.packages())\n" nil (get-process ess-local-process-name)
397
;; "invisible(Sys.sleep(10))\n" nil (get-process ess-local-process-name) ;; test only
398
(lambda (proc) (process-put proc 'packages-cached? t))))
402
(if inferior-ess-language-start
403
(ess-eval-linewise inferior-ess-language-start
404
nil nil nil 'wait-prompt))
406
(with-ess-process-buffer nil
407
(run-mode-hooks 'ess-R-post-run-hook))))
403
inferior-ess-language-start))))
405
(defun R-initialize-on-start (&optional proc string)
406
"This function is run after the first R prompt.
407
Executed in process buffer."
410
(when ess-can-eval-in-background
411
(ess-async-command-delayed
412
"invisible(installed.packages())\n" nil (get-process ess-local-process-name)
413
;; "invisible(Sys.sleep(10))\n" nil (get-process ess-local-process-name) ;; test only
414
(lambda (proc) (process-put proc 'packages-cached? t))))
418
(when inferior-ess-language-start
419
(ess-eval-linewise inferior-ess-language-start
420
nil nil nil 'wait-prompt))
422
(with-ess-process-buffer nil
423
(run-mode-hooks 'ess-R-post-run-hook)))
411
426
;; (defun ess--R-cache-installed-packages ()
971
987
;; always return a non-nil value to prevent history expansions
972
988
(or (comint-dynamic-simple-complete pattern components) 'none))))
974
;; Hmm... shouldn't we keep and use this for R <= 2.6.x ???
975
(make-obsolete 'ess-internal-complete-object-name nil "ESS 13.09")
990
;; *NOT* doing this, as it is needed for R <= 2.6.x
991
;;(make-obsolete 'ess-internal-complete-object-name nil "ESS 13.09")
977
993
(defun ess-R-get-rcompletions (&optional start end)
978
994
"Call R internal completion utilities (rcomp) for possible completions.