[ESS] elisp code: show function arguments
Mark W Kimpel
mwkimpel at gmail.com
Tue Apr 3 07:03:59 CEST 2007
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
;;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.
(defun my-r-show-args ()
"Show arguments and their default values of function in minibuffer."
(let ((pointposition (point)))
(let ((posend (point)))
(setq object (buffer-substring-no-properties posend (point)))
(ess-command (concat "try(args(" object "), silent=TRUE)\n")
(if (equal nil (search-forward "function" 10 t))
(zap-to-char 1 (string-to-char "("))
(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)))
(defvar my-r-noargsmsg "Sorry, no arguments found"
"The message that is returned if my-r-show-args does not find a list
(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
Mark W. Kimpel MD
Department of Psychiatry
Indiana University School of Medicine
More information about the ESS-help