[ESS] elisp code: show function arguments
e.catchpole at adfa.edu.au
Tue Apr 3 08:40:14 CEST 2007
Me neither. Also ESS/emacs illiterate, and also running OpenSuse10.2.
"Not working" in my case means that when I type, e.g., "rnorm(", nothing
happens at all, as far as I can see. I've included all of Sven's code
in my .emacs/init.el file (I'm running xemacs 21.4.20) and restarted xemacs.
I also found strange behaviour of the cursor when trying to move through
the buffer by clicking on the up arrow in the right slider: after every
click the cursor returns to the main window and has to be dragged back
to the up arrow.
Mark W Kimpel wrote on 04/03/2007 03:03 PM:
> I can't get Sven's code to run. As I stated in another post, I am a
> newbie and am probably just doing something wrong. I did, btw, figure
> out that emacs IS loading the proper .emacs file.
> Anyway, I can't seem to get Sven's functionality to work. Below is my
> entire .emacs file. Could someone tell me what is wrong?
> ;;to initiate ess load
> (load "/home/mkimpel/src/ess-5.3.3/lisp/ess-site")
> ;;The following function should be called when point (text cursor) is
> between two parentheses of a R function call.
> ;;It will then (invisibly) query R for which arguments the respective
> function knows as well as their default values and show the result.
> ;; http://www.svenhartenstein.de/emacs-ess.php
> (defun my-r-show-args ()
> "Show arguments and their default values of function in minibuffer."
> (interactive "*")
> (let ((pointposition (point)))
> (up-list -1)
> (let ((posend (point)))
> (backward-sexp 1)
> (setq object (buffer-substring-no-properties posend (point)))
> (ess-command (concat "try(args(" object "), silent=TRUE)\n")
> (get-buffer-create "*my-r-args-completion*"))
> (goto-char pointposition)
> (with-current-buffer "*my-r-args-completion*"
> (goto-char (point-min))
> (if (equal nil (search-forward "function" 10 t))
> (message my-r-noargsmsg)
> (goto-char (point-min))
> (zap-to-char 1 (string-to-char "("))
> (goto-char (point-max))
> (zap-to-char -1 (string-to-char ")"))
> (if (equal my-r-show-as "tooltip")
> (tooltip-show (concat "ARGS: " (buffer-string)))
> (message (concat "ARGS: " (buffer-string)))
> (kill-buffer "*my-r-args-completion*")
> (defvar my-r-noargsmsg "Sorry, no arguments found"
> "The message that is returned if my-r-show-args does not find a list
> of arguments.")
> (defvar my-r-show-as nil
> "How my-r-show-args should show the argument list. Possible values
> are: 'message' (the default) or 'tooltip'.")
> ;; call my-r-show-args automatically
> (define-key ess-mode-map "(" '(lambda nil "" (interactive)
> (skeleton-pair-insert-maybe nil) (my-r-show-args)))
> Sven Hartenstein wrote:
>> Dear friends of Emacs and R,
>> I wrote an emacs lisp function that shows a R-function's arguments and
>> their default values on a single keystroke or as you type the opening
>> paranthesis ("(") after a function name. People like me who can't
>> remember all the parameter's names can thus very easily see them.
>> See screenshots and get it here:
>> The function uses ESS functions. I consider it quite handy and would
>> be interested to know whether anything similar existed already and how
>> it could be improved in case someone else considers it useful. (This
>> is one of my first lisp functions, I'm sure there's much to optimize.)
>> In fact, any feedback is highly appreciated.
>> Happy R-coding,
>> ESS-help at stat.math.ethz.ch mailing list
Dr E.A. Catchpole
Univ of New South Wales at ADFA, Canberra, Australia
_ and University of Kent, Canterbury, England
'v' - www.pems.adfa.edu.au/~ecatchpole
/ \ - fax: +61 2 6268 8786
m m - ph: +61 2 6268 8895
More information about the ESS-help