On Tue, 31 Oct 2006 15:22:09 -0500 John Sullivan <[EMAIL PROTECTED]> wrote:
#> I mean built-in functions, like #> http://docs.python.org/lib/built-in-funcs.html. #> #> Running down that list now, some of them work and some of them don't. #> #> For example, pow() and ord() work. open() and property() and #> reversed() do not. I gather this is because the latter are classes in #> __builtin__, and so their doc strings look different. OK, thanks... I have only checked a couple I remembered by heart and they were all "normal" functions, so they worked. In fact, things like open() and property() are "types", not functions. I am not *entirely* sure we want to display eldoc messages for types in general, but I do not see anything terribly wrong with that... The patch below makes all of built-ins listed on the page you mention to echo eldoc messages for me (except for "help" which actually evaluates to *string*). ********************************************************************** --- /EmacsCVS/etc/emacs.py 2006-10-26 23:25:56.225217600 +0200 +++ /Emacs/etc/emacs.py 2006-11-01 00:13:29.307024000 +0100 @@ -50,12 +50,11 @@ if len (parts) > 1: exec 'import ' + parts[0] # might fail func = eval (name) - if inspect.isbuiltin (func): + if inspect.isbuiltin (func) or type(func) is type: doc = func.__doc__ if doc.find (' ->') != -1: print '_emacs_out', doc.split (' ->')[0] - elif doc.find ('\n') != -1: - print '_emacs_out', doc.split ('\n')[0] + print '_emacs_out', doc.split ('\n')[0] return if inspect.ismethod (func): func = func.im_func ********************************************************************** Here is changelog entry: 2006-11-01 Slawomir Nowaczyk <[EMAIL PROTECTED]> * emacs.py: (eargs) Provide eldoc message for builtin types. Make sure eargs always outputs sentinel, to avoid emacs freeze. ********************************************************************** #>> What would you like to see displayed for things like import or #>> except? The output of "help('import')" is pretty long... First #>> sentence might make some sense, but I am not sure if it would be #>> useful? #> The Python Pocket Reference gives an abbreviated version of the #> grammar (from the beginning of the docstrings) for import. By "Python Pocket Reference", do you mean the book? I think it would be better to get the text from actual Python interpreter installed on user machine, just in case there is a version mismatch. #> Even that's a little long, so maybe just "import module [, #> module]*..." would be good. Maybe... where should this info come from? The output of help("import") starts with: 6.12 The import statement import_stmt ::= "import" module[1] ["as" name[2]] ( "," module[3] ["as" name[4]] )* | "from" module[5] "import" identifier[6] ["as" name[7]] ( "," identifier[8] ["as" name[9]] )* | "from" module[10] "import" "(" identifier[11] ["as" name[12]] ( "," identifier[13] ["as" name[14]] )* [","] ")" | "from" module[15] "import" "*" module ::= (identifier[16] ".")* identifier[17] I do not think any (part) of this is suitable for eldoc. Or do you suggest we actually write some hardcoded eldoc messages? Do we do it for current version only or should we cater for older versions as well (like 2.2 where "yield" was not a keyword)? -- Best wishes, Slawomir Nowaczyk ( [EMAIL PROTECTED] ) If at first you don't succeed, skydiving is not for you. _______________________________________________ emacs-pretest-bug mailing list [email protected] http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug
