[ESS] ess completion

Steve Goldstein sgoldstein at wisc.edu
Thu Jun 12 15:34:14 CEST 2008

Hi Stephen,

With your help, the completion problem is no longer a problem. 


>The trace you've sent suggests that XEmacs is complaining that
>comint-bol has not been given any arguments (the arg is optional in
>Emacs).  I do not have XEmacs here; please can you send me the output of
>"C-h f comint-bol" so that I can check. 
Output from "C-h f comint-bol":

`comint-bol' is an interactive compiled Lisp function
  -- loaded from "comint"
(comint-bol ARG)

Goes to the beginning of line, then skips past the prompt, if any.
If prefix argument is given (C-u) the prompt is not skipped.

The prompt skip is done by skipping text matching the regular expression
`comint-prompt-regexp', a buffer local variable.


> Either that or please put the
>following in your .emacs (after the place where ESS has been loaded) and
>try again.

Adding this function definition to my xemacs init.el file has apparently 
solved the problem.  Thanks so much.

>(Please also tell us what R version and what you typed in *R* to get the
I'm using R version 2.6.1.   I got the error whenever I hit tab in 
*R*while trying to enter a command (at the > prompt).


>(defun ess-R-complete-object-name ()
>  "Completion in R via R's completion utilities (formerly 'rcompgen').
>To be used instead of ESS' completion engine for R versions >= 2.5.0
> (or slightly older versions of R with an attached and working
>  'rcompgen' package)."
>  (interactive)
>  (ess-make-buffer-current)
>  (let* ((comint-completion-addsuffix nil)
>	 (beg-of-line (save-excursion (comint-bol nil) (point)))
>	 (end-of-line (point-at-eol))
>	 (line-buffer (buffer-substring beg-of-line end-of-line))
>	 (NS (if (ess-current-R-at-least '2.7.0)
>		 "utils:::"
>	       "rcompgen:::"))
>	 (token-string ;; setup, including computation of the token
>	  (progn
>	    (ess-command
>	     (format (concat NS ".assignLinebuffer('%s')\n") line-buffer))
>	    (ess-command (format (concat NS ".assignEnd(%d)\n")
>				 (- (point) beg-of-line)))
>	    (car (ess-get-words-from-vector
>		  (concat NS ".guessTokenFromLine()\n")))))
>	 (possible-completions ;; compute and retrieve possible completions
>	  (progn
>	    (ess-command (concat NS ".completeToken()\n"))
>	    (ess-get-words-from-vector
>	     (concat NS ".retrieveCompletions()\n")))))
>    (or (comint-dynamic-simple-complete token-string
>					possible-completions)
>	'none)))
Again, thanks.   Since I'm relatively new to R, command completion is an 
indispensable tool.


More information about the ESS-help mailing list