diff options
Diffstat (limited to 'doc/misc')
| -rw-r--r-- | doc/misc/eshell.texi | 523 |
1 files changed, 391 insertions, 132 deletions
diff --git a/doc/misc/eshell.texi b/doc/misc/eshell.texi index e05048cb6b5..9fcaa5cd6cf 100644 --- a/doc/misc/eshell.texi +++ b/doc/misc/eshell.texi | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | @c %**start of header | 2 | @c %**start of header |
| 3 | @setfilename ../../info/eshell | 3 | @setfilename ../../info/eshell |
| 4 | @settitle Eshell: The Emacs Shell | 4 | @settitle Eshell: The Emacs Shell |
| 5 | @defindex cm | ||
| 5 | @synindex vr fn | 6 | @synindex vr fn |
| 6 | @c %**end of header | 7 | @c %**end of header |
| 7 | 8 | ||
| @@ -44,7 +45,7 @@ developing GNU and promoting software freedom.'' | |||
| 44 | @c -release- | 45 | @c -release- |
| 45 | @end ignore | 46 | @end ignore |
| 46 | @sp 3 | 47 | @sp 3 |
| 47 | @center John Wiegley | 48 | @center John Wiegley & Aidan Gauland |
| 48 | @c -date- | 49 | @c -date- |
| 49 | 50 | ||
| 50 | @page | 51 | @page |
| @@ -77,16 +78,15 @@ handling the sort of tasks accomplished by those tools. | |||
| 77 | * What is Eshell?:: A brief introduction to the Emacs Shell. | 78 | * What is Eshell?:: A brief introduction to the Emacs Shell. |
| 78 | * Command basics:: The basics of command usage. | 79 | * Command basics:: The basics of command usage. |
| 79 | * Commands:: | 80 | * Commands:: |
| 80 | * Arguments:: | 81 | * Expansion:: |
| 81 | * Input/Output:: | 82 | * Input/Output:: |
| 82 | * Process control:: | ||
| 83 | * Extension modules:: | 83 | * Extension modules:: |
| 84 | * Extras and Goodies:: | ||
| 85 | * Bugs and ideas:: Known problems, and future ideas. | 84 | * Bugs and ideas:: Known problems, and future ideas. |
| 86 | * GNU Free Documentation License:: The license for this documentation. | 85 | * GNU Free Documentation License:: The license for this documentation. |
| 87 | * Concept Index:: | 86 | * Concept Index:: |
| 88 | * Function and Variable Index:: | 87 | * Function and Variable Index:: |
| 89 | * Key Index:: | 88 | * Key Index:: |
| 89 | * Command Index:: | ||
| 90 | @end menu | 90 | @end menu |
| 91 | 91 | ||
| 92 | @node What is Eshell? | 92 | @node What is Eshell? |
| @@ -280,47 +280,183 @@ on your mind. Have fun! | |||
| 280 | @node Commands | 280 | @node Commands |
| 281 | @chapter Commands | 281 | @chapter Commands |
| 282 | 282 | ||
| 283 | In a command shell, everything is done by invoking commands. This | ||
| 284 | chapter covers command invocations in Eshell, including the command | ||
| 285 | history and invoking commands in a script file. | ||
| 286 | |||
| 283 | @menu | 287 | @menu |
| 284 | * Invocation:: | 288 | * Invocation:: |
| 285 | * Completion:: | 289 | * Arguments:: |
| 290 | * Variables:: | ||
| 291 | * Built-ins:: | ||
| 286 | * Aliases:: | 292 | * Aliases:: |
| 287 | * History:: | 293 | * History:: |
| 294 | * Completion:: | ||
| 295 | * for loop:: | ||
| 288 | * Scripts:: | 296 | * Scripts:: |
| 289 | * Built-ins:: | ||
| 290 | @end menu | 297 | @end menu |
| 291 | 298 | ||
| 292 | Essentially, a command shell is all about invoking commands---and | ||
| 293 | everything that entails. So understanding how Eshell invokes commands | ||
| 294 | is the key to comprehending how it all works. | ||
| 295 | |||
| 296 | @node Invocation | 299 | @node Invocation |
| 297 | @section Invocation | 300 | @section Invocation |
| 298 | |||
| 299 | Unlike regular system shells, Eshell never invokes kernel functions | 301 | Unlike regular system shells, Eshell never invokes kernel functions |
| 300 | directly, such as @code{exec(3)}. Instead, it uses the Lisp functions | 302 | directly, such as @code{exec(3)}. Instead, it uses the Lisp functions |
| 301 | available in the Emacs Lisp library. It does this by transforming the | 303 | available in the Emacs Lisp library. It does this by transforming the |
| 302 | command you specify into a callable Lisp form.@footnote{To see the Lisp | 304 | input line into a callable Lisp form.@footnote{To see the Lisp form that will be invoked, type: @samp{eshell-parse-command "echo hello"}} |
| 303 | form that will be invoked, type: @samp{eshell-parse-command "echo | 305 | |
| 304 | hello"}} | 306 | The command can be either an Elisp function or an external command. |
| 307 | Eshell looks first for an @ref{Aliases, alias} with the same name as the | ||
| 308 | command, then a @ref{Built-ins, built-in command} or a function with the | ||
| 309 | same name; if there is no match, it then tries to execute it as an | ||
| 310 | external command. | ||
| 311 | |||
| 312 | The semicolon (@code{;}) can be used to separate multiple command | ||
| 313 | invocations on a single line. A command invocation followed by an | ||
| 314 | ampersand (@code{&}) will be run in the background. Eshell has no job | ||
| 315 | control, so you can not suspend or background the current process, or | ||
| 316 | bring a background process into the foreground. That said, background | ||
| 317 | processes invoked from Eshell can be controlled the same way as any | ||
| 318 | other background process in Emacs. | ||
| 305 | 319 | ||
| 306 | This transformation, from the string of text typed at the command | 320 | @node Arguments |
| 307 | prompt, to the ultimate invocation of either a Lisp function or external | 321 | @section Arguments |
| 308 | command, follows these steps: | 322 | Command arguments are passed to the functions as either strings or |
| 323 | numbers, depending on what the parser thinks they look like. If you | ||
| 324 | need to use a function that takes some other data type, you will need to | ||
| 325 | call it in an Elisp expression (which can also be used with | ||
| 326 | @ref{Expansion, expansions}). As with other shells, you can | ||
| 327 | escape special characters and spaces with the backslash (@code{\}) and | ||
| 328 | the single (@code{''}) and double (@code{""}) quotes. | ||
| 309 | 329 | ||
| 310 | @enumerate | 330 | @node Built-ins |
| 311 | @item Parse the command string into separate arguments. | ||
| 312 | @item | ||
| 313 | @end enumerate | ||
| 314 | 331 | ||
| 315 | @node Completion | 332 | @section Built-in commands |
| 316 | @section Completion | 333 | Several commands are built-in in Eshell. In order to call the |
| 334 | external variant of a built-in command @code{foo}, you could call | ||
| 335 | @code{*foo}. Usually, this should not be necessary. You can check | ||
| 336 | what will be applied by the @code{which} command: | ||
| 317 | 337 | ||
| 318 | @node Aliases | 338 | @example |
| 319 | @section Aliases | 339 | ~ $ which ls |
| 340 | eshell/ls is a compiled Lisp function in `em-ls.el' | ||
| 341 | ~ $ which *ls | ||
| 342 | /bin/ls | ||
| 343 | @end example | ||
| 320 | 344 | ||
| 321 | @node History | 345 | @vindex eshell-prefer-lisp-functions |
| 322 | @section History | 346 | If you would prefer to use the built-in commands instead of the external |
| 347 | commands, set @var{eshell-prefer-lisp-functions} to @code{t}. | ||
| 348 | |||
| 349 | Some of the built-in commands have different behaviour from their | ||
| 350 | external counterparts, and some have no external counterpart. Most of | ||
| 351 | these will print a useage message when given the @code{--help} option. | ||
| 352 | |||
| 353 | @table @code | ||
| 354 | |||
| 355 | @item addpath | ||
| 356 | @cmindex addpath | ||
| 357 | Adds a given path or set of paths to the PATH environment variable, or, | ||
| 358 | with no arguments, prints the current paths in this variable. | ||
| 359 | |||
| 360 | @item alias | ||
| 361 | @cmindex alias | ||
| 362 | Define an alias (@pxref{Aliases}). This does not add it to the aliases | ||
| 363 | file. | ||
| 364 | |||
| 365 | @item date | ||
| 366 | @cmindex date | ||
| 367 | Similar to, but slightly different from, the GNU Coreutils | ||
| 368 | @command{date} command. | ||
| 369 | |||
| 370 | @item define | ||
| 371 | @cmindex define | ||
| 372 | Define a varalias. @xref{Variable Aliases, , , elisp}. | ||
| 373 | |||
| 374 | @item diff | ||
| 375 | @cmindex diff | ||
| 376 | Use Emacs's internal @code{diff} (not to be confused with | ||
| 377 | @code{ediff}). @xref{Comparing Files, , , elisp}. | ||
| 378 | |||
| 379 | @item grep | ||
| 380 | @cmindex grep | ||
| 381 | @itemx agrep | ||
| 382 | @cmindex agrep | ||
| 383 | @itemx egrep | ||
| 384 | @cmindex egrep | ||
| 385 | @itemx fgrep | ||
| 386 | @cmindex fgrep | ||
| 387 | @itemx glimpse | ||
| 388 | @cmindex glimpse | ||
| 389 | The @command{grep} commands are compatible with GNU @command{grep}, but | ||
| 390 | use Emacs's internal @code{grep} instead. | ||
| 391 | |||
| 392 | @item info | ||
| 393 | @cmindex info | ||
| 394 | Same as the external @command{info} command, but uses Emacs's internal | ||
| 395 | Info reader. | ||
| 396 | |||
| 397 | @item jobs | ||
| 398 | @cmindex jobs | ||
| 399 | List subprocesses of the Emacs process, if any, using the function | ||
| 400 | @code{list-processes}. | ||
| 401 | |||
| 402 | @item kill | ||
| 403 | @cmindex kill | ||
| 404 | Kill processes. Takes a PID or a process object and an optional | ||
| 405 | signal specifier. | ||
| 406 | |||
| 407 | @item listify | ||
| 408 | @cmindex listify | ||
| 409 | Eshell version of @code{list}. Allows you to create a list using Eshell | ||
| 410 | syntax, rather than Elisp syntax. For example, @samp{listify foo bar} | ||
| 411 | and @code{("foo" "bar")} both evaluate to @code{("foo" "bar")}. | ||
| 412 | |||
| 413 | @item locate | ||
| 414 | @cmindex locate | ||
| 415 | Alias to Emacs's @code{locate} function, which simply runs the external | ||
| 416 | @command{locate} command and parses the results. @xref{Dired and `find', , , elisp}. | ||
| 417 | |||
| 418 | @item make | ||
| 419 | @cmindex make | ||
| 420 | Run @command{make} through @code{compile}. @xref{Running Compilations under Emacs, , , elisp}. | ||
| 421 | |||
| 422 | @item occur | ||
| 423 | @cmindex occur | ||
| 424 | Alias to Emacs's @code{occur}. @xref{Other Search-and-Loop Commands, , , elisp}. | ||
| 425 | |||
| 426 | @item printnl | ||
| 427 | @cmindex printnl | ||
| 428 | Print the arguments separated by newlines. | ||
| 323 | 429 | ||
| 430 | @item cd | ||
| 431 | @cmindex cd | ||
| 432 | This command changes the current working directory. Usually, it is | ||
| 433 | invoked as @samp{cd foo} where @file{foo} is the new working directory. | ||
| 434 | But @command{cd} knows about a few special arguments: | ||
| 435 | |||
| 436 | When it receives no argument at all, it changes to the home directory. | ||
| 437 | |||
| 438 | Giving the command @samp{cd -} changes back to the previous working | ||
| 439 | directory (this is the same as @samp{cd $-}). | ||
| 440 | |||
| 441 | The command @samp{cd =} shows the directory stack. Each line is | ||
| 442 | numbered. | ||
| 443 | |||
| 444 | With @samp{cd =foo}, Eshell searches the directory stack for a directory | ||
| 445 | matching the regular expression @samp{foo} and changes to that | ||
| 446 | directory. | ||
| 447 | |||
| 448 | With @samp{cd -42}, you can access the directory stack by number. | ||
| 449 | |||
| 450 | @item su | ||
| 451 | @cmindex su | ||
| 452 | @itemx sudo | ||
| 453 | @cmindex sudo | ||
| 454 | Uses TRAMP's @command{su} or @command{sudo} method to run a command via | ||
| 455 | @command{su} or @command{sudo}. | ||
| 456 | |||
| 457 | @end table | ||
| 458 | |||
| 459 | @section Built-in variables | ||
| 324 | Eshell knows a few built-in variables: | 460 | Eshell knows a few built-in variables: |
| 325 | 461 | ||
| 326 | @table @code | 462 | @table @code |
| @@ -350,51 +486,28 @@ Lisp functions, based on successful completion). | |||
| 350 | 486 | ||
| 351 | @end table | 487 | @end table |
| 352 | 488 | ||
| 353 | @node Scripts | 489 | @node Variables |
| 354 | @section Scripts | 490 | @section Variables |
| 355 | 491 | Since Eshell is just an Emacs REPL@footnote{Read-Eval-Print Loop}, it | |
| 356 | 492 | does not have its own scope, and simply stores variables the same you | |
| 357 | @node Built-ins | 493 | would in an Elisp program. Eshell provides a command version of |
| 358 | @section Built-in commands | 494 | @code{setq} for convenience. |
| 359 | |||
| 360 | Several commands are built-in in Eshell. In order to call the | ||
| 361 | external variant of a built-in command @code{foo}, you could call | ||
| 362 | @code{*foo}. Usually, this should not be necessary. You can check | ||
| 363 | what will be applied by the @code{which} command: | ||
| 364 | |||
| 365 | @example | ||
| 366 | ~ $ which ls | ||
| 367 | eshell/ls is a compiled Lisp function in `em-ls.el' | ||
| 368 | ~ $ which *ls | ||
| 369 | /bin/ls | ||
| 370 | @end example | ||
| 371 | |||
| 372 | Some of the built-in commands have a special behaviour in Eshell: | ||
| 373 | |||
| 374 | @table @code | ||
| 375 | |||
| 376 | @item cd | ||
| 377 | @findex cd | ||
| 378 | This command changes the current working directory. Usually, it is | ||
| 379 | invoked as @samp{cd foo} where @file{foo} is the new working | ||
| 380 | directory. But @code{cd} knows about a few special arguments: | ||
| 381 | |||
| 382 | When it receives no argument at all, it changes to the home directory. | ||
| 383 | |||
| 384 | Giving the command @samp{cd -} changes back to the previous working | ||
| 385 | directory (this is the same as @samp{cd $-}). | ||
| 386 | |||
| 387 | The command @samp{cd =} shows the directory stack. Each line is | ||
| 388 | numbered. | ||
| 389 | 495 | ||
| 390 | With @samp{cd =foo}, Eshell searches the directory stack for a | 496 | @node Aliases |
| 391 | directory matching the regular expression @samp{foo} and changes to | 497 | @section Aliases |
| 392 | that directory. | ||
| 393 | 498 | ||
| 394 | With @samp{cd -42}, you can access the directory stack by number. | 499 | Aliases are commands that expand to a longer input line. For example, |
| 500 | @command{ll} is a common alias for @code{ls -l}, and would be defined | ||
| 501 | with the command invocation @samp{alias ll ls -l}; with this defined, | ||
| 502 | running @samp{ll foo} in Eshell will actually run @samp{ls -l foo}. | ||
| 503 | Aliases defined (or deleted) by the @command{alias} command are | ||
| 504 | automatically written to the file named by @var{eshell-aliases-file}, | ||
| 505 | which you can also edit directly (although you will have to manually | ||
| 506 | reload it). | ||
| 395 | 507 | ||
| 396 | @item history | 508 | @node History |
| 397 | @findex history | 509 | @section History |
| 510 | @cmindex history | ||
| 398 | The @samp{history} command shows all commands kept in the history ring | 511 | The @samp{history} command shows all commands kept in the history ring |
| 399 | as numbered list. If the history ring contains | 512 | as numbered list. If the history ring contains |
| 400 | @code{eshell-history-size} commands, those numbers change after every | 513 | @code{eshell-history-size} commands, those numbers change after every |
| @@ -410,70 +523,226 @@ of the history ring. | |||
| 410 | argument of the last command beginning with @code{foo} is accessible | 523 | argument of the last command beginning with @code{foo} is accessible |
| 411 | by @code{!foo:n}. | 524 | by @code{!foo:n}. |
| 412 | 525 | ||
| 413 | @item su | 526 | The history ring is loaded from a file at the start of every session, |
| 414 | @findex su | 527 | and written back to the file at the end of every session. The file path |
| 415 | @itemx sudo | 528 | is specified in @var{eshell-history-file-name}. Unlike other shells, |
| 416 | @findex sudo | 529 | such as Bash, Eshell can not be configured to keep a history ring of a |
| 417 | @code{su} and @code{sudo} work as expected: they apply the following | 530 | different size than that of the history file. |
| 418 | commands (@code{su}), or the command being an argument (@code{sudo}) | 531 | |
| 419 | under the permissions of somebody else. | 532 | Since the default buffer navigation and searching key-bindings are |
| 420 | 533 | still present in the Eshell buffer, the commands for history | |
| 421 | This does not work only on | 534 | navigation and searching are bound to different keys: |
| 422 | the local host, but even on a remote one, when | 535 | |
| 423 | @code{default-directory} is a remote file name. The necessary | 536 | @table @kbd |
| 424 | proxy configuration of Tramp is performed | 537 | @item M-r |
| 425 | @ifinfo | 538 | @itemx M-s |
| 426 | automatically, @ref{Multi-hops, , , tramp}. | 539 | History I-search. |
| 427 | @end ifinfo | 540 | |
| 428 | @ifnotinfo | 541 | @item M-p |
| 429 | automatically. | 542 | @itemx M-n |
| 430 | @end ifnotinfo | 543 | Previous and next history line. If there is anything on the input |
| 431 | Example: | 544 | line when you run these commands, they will instead jump to the |
| 545 | precious or next line that begins with that string. | ||
| 546 | @end table | ||
| 547 | |||
| 548 | @node Completion | ||
| 549 | @section Completion | ||
| 550 | Eshell uses the pcomplete package for programmable completion, similar | ||
| 551 | to that of other command shells. Argument completion differs depending | ||
| 552 | on the preceding command: for example, possible completions for | ||
| 553 | @command{rmdir} are only directories, while @command{rm} completions can | ||
| 554 | be directories @emph{and} files. Eshell provides predefined completions | ||
| 555 | for the built-in functions and some common external commands, and you | ||
| 556 | can define your own for any command. | ||
| 557 | |||
| 558 | Eshell completion also works for lisp forms and glob patterns. If the | ||
| 559 | point is on a lisp form, then @key{TAB} will behave similarly to completion | ||
| 560 | in @code{elisp-mode} and @code{lisp-interaction-mode}. For glob | ||
| 561 | patterns, If there are few enough possible completions of the patterns, | ||
| 562 | they will be cycled when @key{TAB} is pressed, otherwise it will be removed | ||
| 563 | from the input line and the possible completions will be listed. | ||
| 564 | |||
| 565 | If you want to see the entire list of possible completions when it's | ||
| 566 | below the cycling threshold, press @kbd{M-?}. | ||
| 567 | |||
| 568 | @subsection pcomplete | ||
| 569 | Pcomplete, short for programmable completion, is the completion | ||
| 570 | library originally written for Eshell, but usable for command | ||
| 571 | completion@footnote{Command completion as opposed to code completion, | ||
| 572 | which is a beyond the scope of pcomplete.} in other modes. | ||
| 573 | |||
| 574 | Completions are defined as functions (with @code{defun}) named | ||
| 575 | @code{pcomplete/COMMAND}, where @code{COMMAND} is the name of the | ||
| 576 | command for which this function provides completions; you can also name | ||
| 577 | the function @code{pcomplete/MAJOR-MODE/COMMAND} to define completions | ||
| 578 | for a specific major mode. | ||
| 579 | |||
| 580 | @node for loop | ||
| 581 | @section @code{for} loop | ||
| 582 | Because Eshell commands can not (easily) be combined with lisp forms, | ||
| 583 | Eshell provides a command-oriented @command{for}-loop for convenience. | ||
| 584 | The syntax is as follows: | ||
| 432 | 585 | ||
| 433 | @example | 586 | @example |
| 434 | ~ $ cd /ssh:otherhost:/etc | 587 | @code{for VAR in TOKENS @{ command invocation(s) @}} |
| 435 | /ssh:user@@otherhost:/etc $ sudo find-file shadow | ||
| 436 | @end example | 588 | @end example |
| 437 | 589 | ||
| 438 | @end table | 590 | where @samp{TOKENS} is a space-separated sequence of values of |
| 439 | 591 | @var{VAR} for each iteration. This can even be the output of a | |
| 592 | command if @samp{TOKENS} is replaced with @samp{@{ command invocation @}}. | ||
| 440 | 593 | ||
| 441 | @node Arguments | 594 | @node Scripts |
| 442 | @chapter Arguments | 595 | @section Scripts |
| 596 | @cmindex source | ||
| 597 | @fnindex eshell-source-file | ||
| 598 | You can run Eshell scripts much like scripts for other shells; the main | ||
| 599 | difference is that since Eshell is not a system command, you have to run | ||
| 600 | it from within Emacs. An Eshell script is simply a file containing a | ||
| 601 | sequence of commands, as with almost any other shell script. Scripts | ||
| 602 | are invoked from Eshell with @command{source}, or from anywhere in Emacs | ||
| 603 | with @code{eshell-source-file}. | ||
| 604 | |||
| 605 | @cmindex . | ||
| 606 | If you wish to load a script into your @emph{current} environment, | ||
| 607 | rather than in a subshell, use the @code{.} command. | ||
| 608 | |||
| 609 | @node Expansion | ||
| 610 | @chapter Expansion | ||
| 611 | Expansion in a command shell is somewhat like macro expansion in macro | ||
| 612 | parsers (such as @command{cpp} and @command{m4}), but in a command | ||
| 613 | shell, they are less often used for constants, and usually for using | ||
| 614 | variables and string manipulation.@footnote{Eshell has no | ||
| 615 | string-manipulation expansions because the Elisp library already | ||
| 616 | provides many functions for this.} For example, @code{$var} on a line | ||
| 617 | expands to the value of the variable @code{var} when the line is | ||
| 618 | executed. Expansions are usually passed as arguments, but may also be | ||
| 619 | used as commands.@footnote{e.g. Entering just @samp{$var} at the prompt | ||
| 620 | is equivalent to entering the value of @code{var} at the prompt.} | ||
| 443 | 621 | ||
| 444 | @menu | 622 | @menu |
| 445 | * The Parser:: | 623 | * Dollars Expansion:: |
| 446 | * Variables:: | ||
| 447 | * Substitution:: | ||
| 448 | * Globbing:: | 624 | * Globbing:: |
| 449 | * Predicates:: | ||
| 450 | @end menu | 625 | @end menu |
| 451 | 626 | ||
| 452 | @node The Parser | 627 | @node Dollars Expansion |
| 453 | @section The Parser | 628 | @section Dollars Expansion |
| 629 | Eshell has different @code{$} expansion syntax from other shells. There | ||
| 630 | are some similarities, but don't let these lull you into a false sense | ||
| 631 | of familiarity. | ||
| 454 | 632 | ||
| 455 | @node Variables | 633 | @table @code |
| 456 | @section Variables | ||
| 457 | 634 | ||
| 458 | @node Substitution | 635 | @item $var |
| 459 | @section Substitution | 636 | Expands to the value bound to @code{var}. This is the main way to use |
| 637 | variables in command invocations. | ||
| 460 | 638 | ||
| 461 | @node Globbing | 639 | @item $#var |
| 462 | @section Globbing | 640 | Expands to the length of the value bound to @code{var}. Raises an error |
| 641 | if the value is not a sequence (@pxref{Sequences Arrays and Vectors, Sequences, , elisp}). | ||
| 463 | 642 | ||
| 464 | @node Predicates | 643 | @item $(lisp) |
| 465 | @section Predicates | 644 | Expands to the result of evaluating the S-expression @code{(lisp)}. On |
| 645 | its own, this is identical to just @code{(lisp)}, but with the @code{$}, | ||
| 646 | it can be used in a string, such as @samp{/some/path/$(lisp).txt}. | ||
| 466 | 647 | ||
| 648 | @item $@{command@} | ||
| 649 | Returns the output of @command{command}, which can be any valid Eshell | ||
| 650 | command invocation, and may even contain expansions. | ||
| 467 | 651 | ||
| 468 | @node Input/Output | 652 | @item $var[i] |
| 469 | @chapter Input/Output | 653 | Expands to the @code{i}th element of the value bound to @code{var}. If |
| 654 | the value is a string, it will be split at whitespace to make it a list. | ||
| 655 | Again, raises an error if the value is not a sequence. | ||
| 656 | |||
| 657 | @item $var[: i] | ||
| 658 | As above, but now splitting occurs at the colon character. | ||
| 659 | |||
| 660 | @item $var[: i j] | ||
| 661 | As above, but instead of returning just a string, it now returns a list | ||
| 662 | of two strings. If the result is being interpolated into a larger | ||
| 663 | string, this list will be flattened into one big string, with each | ||
| 664 | element separated by a space. | ||
| 470 | 665 | ||
| 471 | @node Process control | 666 | @item $var["\\\\" i] |
| 472 | @chapter Process control | 667 | Separate on backslash characters. Actually, the first argument -- if it |
| 668 | doesn't have the form of a number, or a plain variable name -- can be | ||
| 669 | any regular expression. So to split on numbers, use @samp{$var["[0-9]+" 10 20]}. | ||
| 473 | 670 | ||
| 671 | @item $var[hello] | ||
| 672 | Calls @code{assoc} on @code{var} with @code{"hello"}, expecting it to be | ||
| 673 | an alist (@pxref{Association List Type, Association Lists, , elisp}). | ||
| 674 | |||
| 675 | @item $#var[hello] | ||
| 676 | Returns the length of the cdr of the element of @code{var} who car is equal | ||
| 677 | to @code{"hello"}. | ||
| 678 | |||
| 679 | @end table | ||
| 680 | |||
| 681 | @node Globbing | ||
| 682 | @section Globbing | ||
| 683 | Eshell's globbing syntax is very similar to that of Zsh. Users coming | ||
| 684 | from Bash can still use Bash-style globbing, as there are no | ||
| 685 | incompatibilities. Most globbing is pattern-based expansion, but there | ||
| 686 | is also predicate-based expansion. See @ref{Filename Generation, , , zsh} | ||
| 687 | for full syntax. To customize the syntax and behaviour of globbing in | ||
| 688 | Eshell see the Customize@footnote{@xref{Customization Settings, Customize, , elisp}.} | ||
| 689 | groups ``eshell-glob'' and ``eshell-pred''. | ||
| 690 | |||
| 691 | @node Input/Output | ||
| 692 | @chapter Input/Output | ||
| 693 | Since Eshell does not communicate with a terminal like most command | ||
| 694 | shells, IO is a little different. If you try to run programs from | ||
| 695 | within Eshell that are not line-oriented, such as programs that use | ||
| 696 | ncurses, you will just get garbage output, since the Eshell buffer is | ||
| 697 | not a terminal emulator. Eshell solves this problem by running | ||
| 698 | specified commands in Emacs's terminal emulator; to let Eshell know | ||
| 699 | which commands need to be run in a terminal, add them to the list | ||
| 700 | @var{eshell-visual-commands}. | ||
| 701 | |||
| 702 | Redirection is mostly the same in Eshell as it is in other command | ||
| 703 | shells. The output redirection operators @code{>} and @code{>>} as well | ||
| 704 | as pipes are supported, but there is not yet any support for input | ||
| 705 | redirection. Output can also be redirected to Elisp functions, using | ||
| 706 | virtual devices. | ||
| 707 | |||
| 708 | @var{eshell-virtual-targets} is a list of mappings of virtual device | ||
| 709 | names to functions. Eshell comes with two virtual devices: | ||
| 710 | @file{/dev/kill}, which sends the text to the kill ring, and | ||
| 711 | @file{/dev/clip}, which sends text to the clipboard. | ||
| 712 | |||
| 713 | You can, of course, define your own virtual targets. They are defined | ||
| 714 | by adding a list of the form @code{("/dev/name" function mode)} to | ||
| 715 | @var{eshell-virtual-targets}. The first element is the device name; | ||
| 716 | @code{function} may be either a lambda or a function name. If | ||
| 717 | @code{mode} is nil, then the function is the output function; if it is | ||
| 718 | non-nil, then the function is passed the redirection mode as a | ||
| 719 | symbol--@code{overwrite}, @code{append}, or @code{insert}--and the | ||
| 720 | function is expected to return the output function. | ||
| 721 | |||
| 722 | The output function is called once on each line of output until | ||
| 723 | @code{nil} is passed, indicating end of output. | ||
| 474 | 724 | ||
| 475 | @node Extension modules | 725 | @node Extension modules |
| 476 | @chapter Extension modules | 726 | @chapter Extension modules |
| 727 | Eshell provides a facility for defining extension modules so that they | ||
| 728 | can be disabled and enabled without having to unload and reload them, | ||
| 729 | and to provide a common parent Customize group for the | ||
| 730 | modules.@footnote{ERC provides a similar module facility.} An Eshell | ||
| 731 | module is defined the same as any other library but one requirement: the | ||
| 732 | module must define a Customize@footnote{@xref{Customization Settings, Customize, , elisp}.} | ||
| 733 | group using @code{eshell-defgroup} (in place of @code{defgroup}) with | ||
| 734 | @code{eshell-module} as the parent group.@footnote{If the module has | ||
| 735 | no user-customizable options, then there is no need to define it as an | ||
| 736 | Eshell module.} You also need to load the following as shown: | ||
| 737 | |||
| 738 | @example | ||
| 739 | (eval-when-compile | ||
| 740 | (require 'cl) | ||
| 741 | (require 'esh-mode) | ||
| 742 | (require 'eshell)) | ||
| 743 | |||
| 744 | (require 'esh-util) | ||
| 745 | @end example | ||
| 477 | 746 | ||
| 478 | @menu | 747 | @menu |
| 479 | * Writing a module:: | 748 | * Writing a module:: |
| @@ -482,7 +751,6 @@ Example: | |||
| 482 | * Key rebinding:: | 751 | * Key rebinding:: |
| 483 | * Smart scrolling:: | 752 | * Smart scrolling:: |
| 484 | * Terminal emulation:: | 753 | * Terminal emulation:: |
| 485 | * Built-in UNIX commands:: | ||
| 486 | @end menu | 754 | @end menu |
| 487 | 755 | ||
| 488 | @node Writing a module | 756 | @node Writing a module |
| @@ -503,13 +771,6 @@ Example: | |||
| 503 | @node Terminal emulation | 771 | @node Terminal emulation |
| 504 | @section Terminal emulation | 772 | @section Terminal emulation |
| 505 | 773 | ||
| 506 | @node Built-in UNIX commands | ||
| 507 | @section Built-in UNIX commands | ||
| 508 | |||
| 509 | |||
| 510 | @node Extras and Goodies | ||
| 511 | @chapter Extras and Goodies | ||
| 512 | |||
| 513 | @node Bugs and ideas | 774 | @node Bugs and ideas |
| 514 | @chapter Bugs and ideas | 775 | @chapter Bugs and ideas |
| 515 | @cindex reporting bugs and ideas | 776 | @cindex reporting bugs and ideas |
| @@ -518,6 +779,8 @@ Example: | |||
| 518 | @cindex email to the author | 779 | @cindex email to the author |
| 519 | @cindex FAQ | 780 | @cindex FAQ |
| 520 | @cindex problems, list of common | 781 | @cindex problems, list of common |
| 782 | @cindex known bugs | ||
| 783 | @cindex bugs, known | ||
| 521 | 784 | ||
| 522 | If you find a bug or misfeature, don't hesitate to let me know! Send | 785 | If you find a bug or misfeature, don't hesitate to let me know! Send |
| 523 | email to @email{johnw@@gnu.org}. Feature requests should also be sent | 786 | email to @email{johnw@@gnu.org}. Feature requests should also be sent |
| @@ -528,16 +791,7 @@ If you have ideas for improvements, or if you have written some | |||
| 528 | extensions to this package, I would like to hear from you. I hope you | 791 | extensions to this package, I would like to hear from you. I hope you |
| 529 | find this package useful! | 792 | find this package useful! |
| 530 | 793 | ||
| 531 | @menu | 794 | Below is a complete list of known problems with Eshell version 2.4.2, |
| 532 | * Known problems:: | ||
| 533 | @end menu | ||
| 534 | |||
| 535 | @node Known problems | ||
| 536 | @section Known problems | ||
| 537 | @cindex known bugs | ||
| 538 | @cindex bugs, known | ||
| 539 | |||
| 540 | Below is complete list of known problems with Eshell version 2.4.2, | ||
| 541 | which is the version included with Emacs 22. | 795 | which is the version included with Emacs 22. |
| 542 | 796 | ||
| 543 | @table @asis | 797 | @table @asis |
| @@ -545,7 +799,7 @@ which is the version included with Emacs 22. | |||
| 545 | 799 | ||
| 546 | @item Differentiate between aliases and functions | 800 | @item Differentiate between aliases and functions |
| 547 | 801 | ||
| 548 | Allow for a bash-compatible syntax, such as: | 802 | Allow for a Bash-compatible syntax, such as: |
| 549 | 803 | ||
| 550 | @example | 804 | @example |
| 551 | alias arg=blah | 805 | alias arg=blah |
| @@ -829,7 +1083,7 @@ them; @code{min} would display the smallest figure, etc. | |||
| 829 | It would provide syntax, abbrev, highlighting and indenting support like | 1083 | It would provide syntax, abbrev, highlighting and indenting support like |
| 830 | @code{emacs-lisp-mode} and @code{shell-mode}. | 1084 | @code{emacs-lisp-mode} and @code{shell-mode}. |
| 831 | 1085 | ||
| 832 | @item In the history mechanism, finish the @command{bash}-style support | 1086 | @item In the history mechanism, finish the Bash-style support |
| 833 | 1087 | ||
| 834 | This means @samp{!n}, @samp{!#}, @samp{!:%}, and @samp{!:1-} as separate | 1088 | This means @samp{!n}, @samp{!#}, @samp{!:%}, and @samp{!:1-} as separate |
| 835 | from @samp{!:1*}. | 1089 | from @samp{!:1*}. |
| @@ -999,6 +1253,11 @@ Since it keeps the cursor up where the command was invoked. | |||
| 999 | 1253 | ||
| 1000 | @printindex fn | 1254 | @printindex fn |
| 1001 | 1255 | ||
| 1256 | @node Command Index | ||
| 1257 | @unnumbered Command Index | ||
| 1258 | |||
| 1259 | @printindex cm | ||
| 1260 | |||
| 1002 | @node Key Index | 1261 | @node Key Index |
| 1003 | @unnumbered Key Index | 1262 | @unnumbered Key Index |
| 1004 | 1263 | ||