Library Information r-autoyas.el --- Provides automatically created yasnippets for R function argument lists.
Filename :: [[file:r-autoyas.el][r-autoyas.el]]
Description :: r-autoyas is a small ESS complement. It provides automatically created yasnippets for R function argument lists.
Author :: Sven Hartenstein & Matthew Fidler
Maintainer :: Matthew Fidler
Created :: Fri Mar 25 10:36:08 2011 (-0500)
Version :: 0.28
Last-Updated :: Mon Jun 25 15:12:20 2012 (-0500)
By :: Matthew L. Fidler
Update # :: 873
Keywords :: R yasnippet Compatibility:
About r-autoyas is a small ESS complement. It provides automatically created yasnippets for R function argument lists.
Requirements The following are needed:
R & ESS
R process must be running.
Usage
To expand the snipped type the function name and them press =TAB=.
To jump from field to feild press =TAB=. If you did not change the field, the parameter will be deleted from this list
To exit the snipped and delete remaining arguments, press =C-g=
Options This is an incomplete list of user definable options. The complete list can be retrieved by =M-x customize-group r-autoyas= ** Debugging Debugging messages can be put on-screen. This is done by
(setq r-autoyas-debug t)
** Sending a ... replacement to R via emacs instead of by a global options statement Uses Lisp-based dot-replacement defined by `r-autoyas-r-based-dot-replacement' instead of specifying through options in R startup. This is on by default but can be turned off by
(setq r-autoyas-use-r-based-dot-replacement nil)
** Specifying the ...' replacement via the R options() statement Emacs can change the functions
...' replacement through lisp. The
easiest way to change this is, typing:
=M-x customize-variable r-autoyas-r-based-dot-replacement= ** Using functions within a namespace only By default, R-autoyas only expands predefined functions in namespaces/package that are loaded in R. This ignores any user-defined functions. However, R-autoyas may be used to expand user-defined functions as well. This is done with the =r-autoyas-expand-package-functions-only= variable. To turn on r-autoyas's expansion of user-defined functions, the following code may be used:
(setq r-autoyas-expand-package-functions-only nil)
This variable may also be customized.
Limitations
No nice error handling when no R process is found
Partial nested support -- not perfected
Loading r-autoyas in ~/.emacs You may use marmalade-repo and ELPA to install r-autoyas (http://marmalade-repo.org/), or put it into your load-path and put the following in ~/.emacs
(require 'r-autoyas) (add-hook 'ess-mode-hook 'r-autoyas-ess-activate)
*** r-autoyas-defined-p =(r-autoyas-defined-p &optional WITH-PAREN)=
Is the current function defined (like plot )
*** r-autoyas-ess-activate =(r-autoyas-ess-activate)=
R autoyas ESS hook
*** r-autoyas-exit-snippet-delete-remaining =(r-autoyas-exit-snippet-delete-remaining)=
Exit yas snippet and delete the remaining argument list.
*** r-autoyas-expand =(r-autoyas-expand &optional RM-PAREN)=
Insert argument list for R function before the point as intelligent yas snippets and expand the snippets. RM-PAREN removes the inserted parenthesis
*** r-autoyas-expand-maybe =(r-autoyas-expand-maybe &rest IGNORE)=
Might auto-expand snippet.
*** r-autoyas-paren =(r-autoyas-paren)=
Function to allow Auto-yas to insert parenthesis
*** r-autoyas-wrap =(r-autoyas-wrap)=
Wrap code
** Internal Functions
*** autopair-r-autoyas-paren-action =(autopair-r-autoyas-paren-action ACTION PAIR POS-BEFORE)=
Autopair R autoyas paren-action
*** r-autoyas-active-field-number =(r-autoyas-active-field-number &optional ARG)=
Get the active field position
*** r-autoyas-editing-field-num-p =(r-autoyas-editing-field-num-p &optional ARG)=
Which field is active?
*** r-autoyas-generate-dotreplace-list =(r-autoyas-generate-dotreplace-list)=
Generates dot-replace R-code
*** r-autoyas-generte-dotreplace-list-lisp =(r-autoyas-generte-dotreplace-list-lisp FUNC)=
Generates dot-replacement yasnippet based on lisp options
*** r-autoyas-m =(r-autoyas-m &rest OBJECTS)=
Message when debugging is on.
*** r-autoyas-namespace =(r-autoyas-namespace FUNCTION-NAME)=
Returns the namespace for FUNCTION-NAME, or nil if it cannot be determined.
*** r-autoyas-preloaded-namespace-p =(r-autoyas-preloaded-namespace-p NAMESPACE)=
Determines if NAMESPACE is preloaded in R. It is based on the variable =r-autoyas-preloaded-packages=
*** r-autoyas-text-on-moving-away =(r-autoyas-text-on-moving-away DEFAULT-TEXT &optional ORIG-TEXT)=
*** r-autoyas-update =(r-autoyas-update)=
Update fields
*** rayas-comma =(rayas-comma FIELD NUM)=
Inserts comma and field number if needed
*** rayas-require-explicit-p =(rayas-require-explicit-p NUM)=
Should the explicit x= be required?
*** rayas-space =(rayas-space FIELD-NUMBER)=
Adds a dummy space so that reducing the yasnippet field to zero doesn't cause strange errors.
*** r-autoyas-auto-expand-with-paren
*** r-autoyas-debug Add debugging comments for=r-autoyas=
*** r-autoyas-echo-inject-commands
*** r-autoyas-expand-package-functions-only Automatically expand only functions defined in a package/library.
*** r-autoyas-lisp-based-dot-replacement Defines default the ... replacement using lisp.
*** r-autoyas-number-of-commas-before-return Defines the number of commas before the snippet is inserted as:
plot(x= , y=NULL, type='p', xlim=NULL, ylim=NULL, log='', main=NULL, sub=NULL, xlab=NULL, ylab=NULL, ann=par("ann"), axes=TRUE, frame.plot= , panel.first=NULL, panel.last=NULL, asp=NA, ...)
insetad of:
plot(x= , y=NULL, type='p', xlim=NULL, ylim=NULL, log='', main=NULL, sub=NULL, xlab=NULL, ylab=NULL, ann=par("ann"), axes=TRUE, frame.plot= , panel.first=NULL, panel.last=NULL, asp=NA, ...)
If this number is zero or below, always insert as a single line.
*** r-autoyas-paren-ignored-functions List of functions to ignore when creating auto-snippets by inserting a parenthesis
*** r-autoyas-preloaded-packages List of preloaded packages in R. All other packages need to be included by a require(package) or library(package) statement.
*** r-autoyas-r-based-dot-replacement Defines default the ... replacement sent to the options() statement in R. quote() is used to keep the expression instead of evaluating it.
*** r-autoyas-remove-explicit-assignments
This option removes explicit assignments after tabbing away. For example
write.table(x= , file="", append=FALSE, quote=TRUE, sep=" ", eol="\n", na="NA", dec=".", row.names=TRUE, col.names=TRUE, qmethod=c("escape", "double"))
Becomes
write.table(d, "file-name.csv", append=FALSE, quote=TRUE, sep=" ", eol="\n", na="NA", dec=".", row.names=TRUE, col.names=TRUE, qmethod=c("escape", "double"));
*** r-autoyas-save-expression-to-memory Defines if r-autoyas should save the snippet to memory instead of calling the R communcation again.
*** r-autoyas-use-lisp-based-dot-replacement Uses Lisp-based dot-replacement defined by =r-autoyas-lisp-based-dot-replacement= instead of specifying through options in R startup.
*** r-autoyas-use-r-based-dot-replacement Uses Lisp-based dot-replacement defined by =r-autoyas-r-based-dot-replacement= instead of specifying through options in R startup.
*** r-autoyas-wrap-on-exit Defines if R-autoyas attempts to wrap end of lines.
** Internal Variables
*** r-autoyas-backward R-autoyas use backward compatability?
*** r-autoyas-backward-compatability Yasnippet backward compatability functions used in r-autoyas.el
Value: ((yas/expand-snippet yas-expand-snippet) (yas/active-field-overlay yas--active-field-overlay) (yas/wrap-around-region yas-wrap-around-region) (yas/moving-away-p yas-moving-away-p) (yas/expand yas-expand) (yas/modified-p yas-modified-p) (yas/moving-away-p yas-moving-away-p) (yas/text yas-text) (yas/skip-and-clear-or-delete-char yas-skip-and-clear-or-delete-char) (yas/snippet-fields yas--snippet-fields) (yas/snippets-at-point yas--snippets-at-point) (yas/update-mirrors yas--update-mirrors) (yas/fallback-behavior yas-fallback-behavior) (yas/minor-mode yas-minor-mode) (yas/field-probably-deleted-p yas--field-probably-deleted-p) (yas/field yas--field) (yas/field-text-for-display yas--field-text-for-display) (yas/snippet-control-overlay yas--snippet-control-overlay) (yas/exit-snippet yas-exit-snippet) (yas/check-commit-snippet yas--check-commit-snippet) (yas/define-snippets yas-define-snippets) (yas/after-exit-snippet-hook yas-after-exit-snippet-hook))
*** r-autoyas-cache Cache of complex language statments for R-autoyas
History