Wilfred / helpful

A better Emacs *help* buffer
1.12k stars 62 forks source link

Enhancement: provide documentation for eshell command line commands #149

Open heikkil opened 6 years ago

heikkil commented 6 years ago

Helpful recognises eshell functions in the form 'eshell/nnn' since they are standard elisp functions, but it reports "Not bound: nnn" for command line commands.

Could helpful check if the the string passed to it is an eshell alias or an eshell alias function:

(eshell-lookup-alias "ll")  ; => ("ll" "ls -laGF  $*")
(eshell-find-alias-function "alias") ; => ashell/alias

These extensions should check for 'eshell-mode' before executing. This would extend the use of 'helpful-at-point' other functions to eshell buffers.

(Interactively, eshell provides its own version of 'which' to report on kind of commands it knows about.)

Wilfred commented 6 years ago

Hm, this an interesting idea!

I think looking up aliases is command aliases like ll is different from just understanding that which in eshell buffers really calls eshell/which. It's obvious what we show in the latter case.

What data would you expect to see for M-x helpful-at-point RET ll RET in an eshell buffer? Could you give me an example? (eshell-lookup-alias "ll") returns nil in my Emacs.

heikkil commented 6 years ago

Alias is a feature in eshell that starts with an empty list. Any alias defined at eshell prompt stores the alias permanently in 'eshell-aliases-file'. You need to define aliases with two arguments, the first is the alias name and the corresponding command line in string single quotes.

E.g. give command

$ alias ll 'ls -laGF  $*'

Actually, I just realised that the built in function 'eshell/which' is aware of both functions and aliases, so the the basic output from 'helpful-at-point' should start with the same. In case of alias, the output should also show the which output from the original command. E.g.:

$ which du
du is an alias, defined as "du -h"
$ which eshell/du
eshell/du is a compiled Lisp function in ‘em-unix.el’.