emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-26 ba9139c 2/2: Revert "Don't lose arguments to eshe


From: Noam Postavsky
Subject: [Emacs-diffs] emacs-26 ba9139c 2/2: Revert "Don't lose arguments to eshell aliases (Bug#27954)"
Date: Sat, 30 Sep 2017 20:11:49 -0400 (EDT)

branch: emacs-26
commit ba9139c501ed8220980e898f127e293e8f263ea1
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>

    Revert "Don't lose arguments to eshell aliases (Bug#27954)"
    
    It broke the established argument handling methods provided by eshell
    aliases (Bug#28568).
    * doc/misc/eshell.texi (Aliases): Fix example, call out use of
    arguments in aliases.
    * lisp/eshell/em-alias.el (eshell-maybe-replace-by-alias): Ignore
    ARGS.
---
 doc/misc/eshell.texi    | 9 ++++++++-
 lisp/eshell/em-alias.el | 6 +++---
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/doc/misc/eshell.texi b/doc/misc/eshell.texi
index 8963826..8a607ef 100644
--- a/doc/misc/eshell.texi
+++ b/doc/misc/eshell.texi
@@ -431,13 +431,20 @@ would in an Elisp program.  Eshell provides a command 
version of
 
 Aliases are commands that expand to a longer input line.  For example,
 @command{ll} is a common alias for @code{ls -l}, and would be defined
-with the command invocation @samp{alias ll ls -l}; with this defined,
+with the command invocation @kbd{alias ll 'ls -l $*'}; with this defined,
 running @samp{ll foo} in Eshell will actually run @samp{ls -l foo}.
 Aliases defined (or deleted) by the @command{alias} command are
 automatically written to the file named by @code{eshell-aliases-file},
 which you can also edit directly (although you will have to manually
 reload it).
 
+Note that unlike aliases in Bash, arguments must be handled
+explicitly.  Typically the alias definition would end in @samp{$*} to
+pass all arguments along.  More selective use of arguments via
address@hidden, @samp{$2}, etc., is also possible.  For example,
address@hidden mcd 'mkdir $1 && cd $1'} would cause @kbd{mcd foo} to
+create and switch to a directory called @samp{foo}.
+
 @node History
 @section History
 @cmindex history
diff --git a/lisp/eshell/em-alias.el b/lisp/eshell/em-alias.el
index f951efa65..7422345 100644
--- a/lisp/eshell/em-alias.el
+++ b/lisp/eshell/em-alias.el
@@ -214,8 +214,8 @@ file named by `eshell-aliases-file'.")
 
 (defvar eshell-prevent-alias-expansion nil)
 
-(defun eshell-maybe-replace-by-alias (command args)
-  "If COMMAND has an alias definition, call that instead using ARGS."
+(defun eshell-maybe-replace-by-alias (command _args)
+  "Call COMMAND's alias definition, if it exists."
   (unless (and eshell-prevent-alias-expansion
               (member command eshell-prevent-alias-expansion))
     (let ((alias (eshell-lookup-alias command)))
@@ -225,7 +225,7 @@ file named by `eshell-aliases-file'.")
                         (eshell-command-arguments ',eshell-last-arguments)
                         (eshell-prevent-alias-expansion
                          ',(cons command eshell-prevent-alias-expansion)))
-                    ,(eshell-parse-command (nth 1 alias) args)))))))
+                    ,(eshell-parse-command (nth 1 alias))))))))
 
 (defun eshell-alias-completions (name)
   "Find all possible completions for NAME.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]