]> code.delx.au - gnu-emacs/blobdiff - lisp/eshell/em-cmpl.el
(nnmail-extra-headers): Add defvar.
[gnu-emacs] / lisp / eshell / em-cmpl.el
index cc54957360438bd3130d6b83f6d6768917b3f8b8..423a93d46e2278300ddad2e51aa63c4aa136225f 100644 (file)
@@ -1,6 +1,9 @@
-;;; em-cmpl --- completion using the TAB key
+;;; em-cmpl.el --- completion using the TAB key
 
-;; Copyright (C) 1999, 2000 Free Software Foundation
+;; Copyright (C) 1999, 2000, 2002, 2003, 2004,
+;;   2005 Free Software Foundation, Inc.
+
+;; Author: John Wiegley <johnw@gnu.org>
 
 ;; This file is part of GNU Emacs.
 
 
 ;; 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.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 (provide 'em-cmpl)
 
 (eval-when-compile (require 'esh-maint))
+(require 'esh-util)
 
 (defgroup eshell-cmpl nil
   "This module provides a programmable completion function bound to
@@ -51,7 +55,7 @@ variable names, arguments, etc."
 ;;
 ;; The completion facility is very easy to use.  Just press TAB.  If
 ;; there are a large number of possible completions, a buffer will
-;; appearing showing a list of them.  Completions may be selected from
+;; appear showing a list of them.  Completions may be selected from
 ;; that buffer using the mouse.  If no completion is selected, and the
 ;; user starts doing something else, the display buffer will
 ;; automatically disappear.
@@ -114,8 +118,9 @@ is non-nil."
     ("CC"       . "\\.[Cc]\\([Cc]\\|[Pp][Pp]\\)?\\'")
     ("acc"      . "\\.[Cc]\\([Cc]\\|[Pp][Pp]\\)?\\'")
     ("bcc"      . "\\.[Cc]\\([Cc]\\|[Pp][Pp]\\)?\\'")
-    ("objdump"  . "\\(\\`[^.]*\\|\\.[ao]\\)\\'")
-    ("nm"       . "\\(\\`[^.]*\\|\\.[ao]\\)\\'")
+    ("readelf"  . "\\(\\`[^.]*\\|\\.\\([ao]\\|so\\)\\)\\'")
+    ("objdump"  . "\\(\\`[^.]*\\|\\.\\([ao]\\|so\\)\\)\\'")
+    ("nm"       . "\\(\\`[^.]*\\|\\.\\([ao]\\|so\\)\\)\\'")
     ("gdb"      . "\\`\\([^.]*\\|a\\.out\\)\\'")
     ("dbx"      . "\\`\\([^.]*\\|a\\.out\\)\\'")
     ("sdb"      . "\\`\\([^.]*\\|a\\.out\\)\\'")
@@ -132,8 +137,7 @@ to writing a completion function."
   :type (get 'pcomplete-file-ignore 'custom-type)
   :group 'eshell-cmpl)
 
-(defcustom eshell-cmpl-dir-ignore
-  (format "\\`\\(\\.\\.?\\|CVS\\)%c\\'" directory-sep-char)
+(defcustom eshell-cmpl-dir-ignore "\\`\\(\\.\\.?\\|CVS\\)/\\'"
   (documentation-property 'pcomplete-dir-ignore
                          'variable-documentation)
   :type (get 'pcomplete-dir-ignore 'custom-type)
@@ -151,7 +155,7 @@ to writing a completion function."
   :type (get 'pcomplete-autolist 'custom-type)
   :group 'eshell-cmpl)
 
-(defcustom eshell-cmpl-suffix-list (list directory-sep-char ?:)
+(defcustom eshell-cmpl-suffix-list (list ?/ ?:)
   (documentation-property 'pcomplete-suffix-list
                          'variable-documentation)
   :type (get 'pcomplete-suffix-list 'custom-type)
@@ -225,7 +229,12 @@ to writing a completion function."
   (documentation-property 'pcomplete-default-completion-function
                          'variable-documentation)
   :type (get 'pcomplete-default-completion-function 'custom-type)
-  :group 'pcomplete)
+  :group 'eshell-cmpl)
+
+(defcustom eshell-cmpl-use-paring t
+  (documentation-property 'pcomplete-use-paring 'variable-documentation)
+  :type (get 'pcomplete-use-paring 'custom-type)
+  :group 'eshell-cmpl)
 
 ;;; Functions:
 
@@ -265,16 +274,16 @@ to writing a completion function."
        eshell-cmpl-cycle-cutoff-length)
   (set (make-local-variable 'pcomplete-restore-window-delay)
        eshell-cmpl-restore-window-delay)
+  (set (make-local-variable 'pcomplete-use-paring)
+       eshell-cmpl-use-paring)
   ;; `pcomplete-arg-quote-list' should only be set after all the
   ;; load-hooks for any other extension modules have been run, which
   ;; is true at the time `eshell-mode-hook' is run
-  (make-local-hook 'eshell-mode-hook)
   (add-hook 'eshell-mode-hook
            (function
             (lambda ()
               (set (make-local-variable 'pcomplete-arg-quote-list)
                    eshell-special-chars-outside-quoting))) nil t)
-  (make-local-hook 'pcomplete-quote-arg-hook)
   (add-hook 'pcomplete-quote-arg-hook 'eshell-quote-backslash nil t)
   (define-key eshell-mode-map [(meta tab)] 'lisp-complete-symbol)
   (define-key eshell-mode-map [(meta control ?i)] 'lisp-complete-symbol)
@@ -297,7 +306,7 @@ to writing a completion function."
   "Return the command name, possibly sans globbing."
   (let ((cmd (file-name-nondirectory (pcomplete-arg 'first))))
     (setq cmd (if (and (> (length cmd) 0)
-                      (eq (aref cmd 0) ?*))
+                      (eq (aref cmd 0) eshell-explicit-command-char))
                  (substring cmd 1)
                cmd))
     (if (eshell-under-windows-p)
@@ -361,7 +370,8 @@ to writing a completion function."
           (setq args (nthcdr (1+ l) args)
                 posns (nthcdr (1+ l) posns))))
     (assert (= (length args) (length posns)))
-    (when (and args (eq (char-syntax (char-before end)) ? ))
+    (when (and args (eq (char-syntax (char-before end)) ? )
+              (not (eq (char-before (1- end)) ?\\)))
       (nconc args (list ""))
       (nconc posns (list (point))))
     (cons (mapcar
@@ -387,7 +397,7 @@ to writing a completion function."
     (if (file-name-directory filename)
        (pcomplete-executables)
       (if (and (> (length filename) 0)
-              (eq (aref filename 0) ?*))
+              (eq (aref filename 0) eshell-explicit-command-char))
          (setq filename (substring filename 1)
                pcomplete-stub filename
                glob-name t))
@@ -440,4 +450,5 @@ to writing a completion function."
 
 ;;; Code:
 
+;;; arch-tag: 0e914699-673a-45f8-8cbf-82e1dbc571bc
 ;;; em-cmpl.el ends here