]> code.delx.au - gnu-emacs/blobdiff - lisp/eshell/em-alias.el
Merge from emacs-24; up to 2012-12-11T09:51:12Z!dmantipov@yandex.ru
[gnu-emacs] / lisp / eshell / em-alias.el
index ff6d66eb9e91d344569d56a253a6fd6171001aef..aa89177c2dec950a1775cc74974a9ef51505744a 100644 (file)
@@ -1,15 +1,15 @@
 ;;; em-alias.el --- creation and management of command aliases
 
-;; Copyright (C) 1999, 2000 Free Software Foundation
+;; Copyright (C) 1999-2013 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <johnw@gnu.org>
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
-
-(provide 'em-alias)
-
-(eval-when-compile (require 'esh-maint))
-
-(defgroup eshell-alias nil
-  "Command aliases allow for easy definition of alternate commands."
-  :tag "Command aliases"
-  :link '(info-link "(eshell)Command aliases")
-  :group 'eshell-module)
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
 ;;
 ;; Aliases are written to disk immediately after being defined or
 ;; deleted.  The filename in which they are kept is defined by the
-;; following variable:
-
-(defcustom eshell-aliases-file (concat eshell-directory-name "alias")
-  "*The file in which aliases are kept.
-Whenever an alias is defined by the user, using the `alias' command,
-it will be written to this file.  Thus, alias definitions (and
-deletions) are always permanent.  This approach was chosen for the
-sake of simplicity, since that's pretty much the only benefit to be
-gained by using this module."
-  :type 'file
-  :group 'eshell-alias)
+;; variable eshell-aliases-file.
 
-;;;
 ;; The format of this file is quite basic.  It specifies the alias
 ;; definitions in almost exactly the same way that the user entered
 ;; them, minus any argument quoting (since interpolation is not done
@@ -97,22 +74,15 @@ gained by using this module."
 ;; session, it is likely that they are experiencing a spelling
 ;; difficulty associated with a certain command.  To combat this,
 ;; Eshell will offer to automatically define an alias for that
-;; mispelled command, once a given tolerance threshold has been
+;; misspelled command, once a given tolerance threshold has been
 ;; reached.
 
-(defcustom eshell-bad-command-tolerance 3
-  "*The number of failed commands to ignore before creating an alias."
-  :type 'integer
-  :link '(custom-manual "(eshell)Auto-correction of bad commands")
-  :group 'eshell-alias)
-
-;;;
-;; Whenever the same bad command name is encountered this many times,
-;; the user will be prompted in the minibuffer to provide an alias
-;; name.  An alias definition will then be created which will result
-;; in an equal call to the correct name.  In this way, Eshell
-;; gradually learns about the commands that the user mistypes
-;; frequently, and will automatically correct them!
+;; Whenever the same bad command name is encountered
+;; `eshell-bad-command-tolerance' times, the user will be prompted in
+;; the minibuffer to provide an alias name.  An alias definition will
+;; then be created which will result in an equal call to the correct
+;; name.  In this way, Eshell gradually learns about the commands that
+;; the user mistypes frequently, and will automatically correct them!
 ;;
 ;; Note that a '$*' is automatically appended at the end of the alias
 ;; definition, so that entering it is unnecessary when specifying the
@@ -120,8 +90,37 @@ gained by using this module."
 
 ;;; Code:
 
-(defcustom eshell-alias-load-hook '(eshell-alias-initialize)
-  "*A hook that gets run when `eshell-alias' is loaded."
+(eval-when-compile
+  (require 'esh-util))
+(require 'eshell)
+
+;;;###autoload
+(progn
+(defgroup eshell-alias nil
+  "Command aliases allow for easy definition of alternate commands."
+  :tag "Command aliases"
+  ;; :link '(info-link "(eshell)Command aliases")
+  :group 'eshell-module))
+
+(defcustom eshell-aliases-file (expand-file-name "alias" eshell-directory-name)
+  "The file in which aliases are kept.
+Whenever an alias is defined by the user, using the `alias' command,
+it will be written to this file.  Thus, alias definitions (and
+deletions) are always permanent.  This approach was chosen for the
+sake of simplicity, since that's pretty much the only benefit to be
+gained by using this module."
+  :type 'file
+  :group 'eshell-alias)
+
+(defcustom eshell-bad-command-tolerance 3
+  "The number of failed commands to ignore before creating an alias."
+  :type 'integer
+  ;; :link '(custom-manual "(eshell)Auto-correction of bad commands")
+  :group 'eshell-alias)
+
+(defcustom eshell-alias-load-hook nil
+  "A hook that gets run when `eshell-alias' is loaded."
+  :version "24.1"                      ; removed eshell-alias-initialize
   :type 'hook
   :group 'eshell-alias)
 
@@ -134,10 +133,10 @@ Each element of this alias is a list of the form:
 Where NAME is the textual name of the alias, and DEFINITION is the
 command string to replace that command with.
 
-Note: this list should not be modified in your '.emacs' file.  Rather,
-any desired alias definitions should be declared using the `alias'
-command, which will automatically write them to the file named by
-`eshell-aliases-file'.")
+Note: this list should not be modified in your init file.
+Rather, any desired alias definitions should be declared using
+the `alias' command, which will automatically write them to the
+file named by `eshell-aliases-file'.")
 
 (put 'eshell-command-aliases-list 'risky-local-variable t)
 
@@ -159,7 +158,7 @@ command, which will automatically write them to the file named by
 (defun eshell/alias (&optional alias &rest definition)
   "Define an ALIAS in the user's alias list using DEFINITION."
   (if (not alias)
-      (eshell-for alias eshell-command-aliases-list
+      (dolist (alias eshell-command-aliases-list)
        (eshell-print (apply 'format "alias %s %s\n" alias)))
     (if (not definition)
        (setq eshell-command-aliases-list
@@ -178,6 +177,9 @@ command, which will automatically write them to the file named by
     (eshell-write-aliases-list))
   nil)
 
+(defvar pcomplete-stub)
+(autoload 'pcomplete-here "pcomplete")
+
 (defun pcomplete/eshell-mode/alias ()
   "Completion function for Eshell's `alias' command."
   (pcomplete-here (eshell-alias-completions pcomplete-stub)))
@@ -238,7 +240,7 @@ command, which will automatically write them to the file named by
   "Find all possible completions for NAME.
 These are all the command aliases which begin with NAME."
   (let (completions)
-    (eshell-for alias eshell-command-aliases-list
+    (dolist (alias eshell-command-aliases-list)
       (if (string-match (concat "^" name) (car alias))
          (setq completions (cons (car alias) completions))))
     completions))
@@ -272,4 +274,10 @@ These are all the command aliases which begin with NAME."
                                        eshell-prevent-alias-expansion))))
                     (eshell-parse-command alias))))))))))
 
+(provide 'em-alias)
+
+;; Local Variables:
+;; generated-autoload-file: "esh-groups.el"
+;; End:
+
 ;;; em-alias.el ends here