[R-SIG-Mac] short-cut feature for getting help for the current word in the Console (CTRL+H)

Hans-Jörg Bibiko bibiko at eva.mpg.de
Wed Apr 1 17:28:52 CEST 2009

Dear Simon, dear all,

it's often the case that one types a command and needs some help  
immediately. The default workaround is to type the command in question  
into the upper-right search field. In order to simplify it here my  

[ | := caret position]

 > mean(|)
 > |c
 > data.frame|
 > data.|frame
 > c(me|an())

press CTRL+H to look for the current R command in the docs given by  
the caret position or if a selection is given take the content of that  
selection to look for it (mean, c, data.frame, data.frame, mean).

Attached is the method -(NSString*)getCurrentCommandForCaretPosition  
for RTextView.m.
In addition one has to provide:

#import "HelpManager.h"

at the beginning of RTextView.m

Inside of the keyDown: method one calls it via:

// ^h for help
if ([rc isEqual:@"h"] && (modFlags&(NSShiftKeyMask|NSControlKeyMask| 
NSAlternateKeyMask|NSCommandKeyMask))==NSControlKeyMask) {
	NSString* curWord = [self getCurrentCommandForCaretPosition];
		[[HelpManager sharedController] showHelpFor:curWord];



Hans-Joerg Bibiko
Max Planck Institute for Evolutionary Anthropology
Department of Linguistics
Deutscher Platz 6     phone:   +49 (0) 341 3550 341
D-04103 Leipzig       fax:     +49 (0) 341 3550 333
Germany               e-mail:  bibiko at eva.mpg.de

-------------- next part --------------
A non-text attachment was scrubbed...
Name: getCurrentCommandForCaretPosition.patch.m.zip
Type: application/zip
Size: 1604 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-mac/attachments/20090401/8eed9414/attachment.zip>

More information about the R-SIG-Mac mailing list