]> code.delx.au - gnu-emacs/blobdiff - lisp/eshell/em-cmpl.el
Doc fix for `kbd'
[gnu-emacs] / lisp / eshell / em-cmpl.el
index 91311deffcffa3f8e65df4f6e3cefa58bad92867..47467678a68af229c4afd4cf4bd0cdf885697997 100644 (file)
@@ -1,6 +1,6 @@
-;;; em-cmpl.el --- completion using the TAB key
+;;; em-cmpl.el --- completion using the TAB key  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1999-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2016 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <johnw@gnu.org>
 
 ;; with sufficient pointers to locate the relevant help text.
 
 ;;; Code:
+(require 'pcomplete)
+
+(require 'esh-mode)
+(require 'esh-util)
 
 (eval-when-compile
   (require 'cl-lib)
   (require 'eshell))
-(require 'esh-util)
 
 ;;;###autoload
 (progn
@@ -240,10 +243,14 @@ to writing a completion function."
 
 ;;; Functions:
 
+(defun eshell-complete-lisp-symbol ()
+  "Try to complete the text around point as a Lisp symbol."
+  (interactive)
+  (let ((completion-at-point-functions '(lisp-completion-at-point)))
+    (completion-at-point)))
+
 (defun eshell-cmpl-initialize ()
   "Initialize the completions module."
-  (unless (fboundp 'pcomplete)
-    (load "pcmpl-auto" t t))
   (set (make-local-variable 'pcomplete-command-completion-function)
        eshell-command-completion-function)
   (set (make-local-variable 'pcomplete-command-name-function)
@@ -278,17 +285,17 @@ to writing a completion function."
        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
+  ;; `comint-file-name-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
   (add-hook 'eshell-mode-hook
            (function
             (lambda ()
-              (set (make-local-variable 'pcomplete-arg-quote-list)
+              (set (make-local-variable 'comint-file-name-quote-list)
                    eshell-special-chars-outside-quoting))) nil t)
   (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)
+  (define-key eshell-mode-map [(meta tab)] 'eshell-complete-lisp-symbol)
+  (define-key eshell-mode-map [(meta control ?i)] 'eshell-complete-lisp-symbol)
   (define-key eshell-command-map [(meta ?h)] 'eshell-completion-help)
   (define-key eshell-command-map [tab] 'pcomplete-expand-and-complete)
   (define-key eshell-command-map [(control ?i)]
@@ -346,7 +353,7 @@ to writing a completion function."
               (setq begin (1+ (cadr delim))
                     args (eshell-parse-arguments begin end)))
              ((eq (car delim) ?\()
-              (lisp-complete-symbol)
+              (eshell-complete-lisp-symbol)
               (throw 'pcompleted t))
              (t
               (insert-and-inherit "\t")
@@ -363,7 +370,7 @@ to writing a completion function."
     (cl-assert (= (length args) (length posns)))
     (let ((a args)
          (i 0)
-         l final)
+         l)
       (while a
        (if (and (consp (car a))
                 (eq (caar a) 'eshell-operator))
@@ -398,7 +405,9 @@ to writing a completion function."
   "Generate list of applicable, visible commands."
   (let ((filename (pcomplete-arg)) glob-name)
     (if (file-name-directory filename)
-       (pcomplete-executables)
+        (if eshell-force-execution
+            (pcomplete-dirs-or-entries nil 'file-readable-p)
+          (pcomplete-executables))
       (if (and (> (length filename) 0)
               (eq (aref filename 0) eshell-explicit-command-char))
          (setq filename (substring filename 1)
@@ -409,6 +418,8 @@ to writing a completion function."
                   (expand-file-name default-directory)))
             (path "") (comps-in-path ())
             (file "") (filepath "") (completions ()))
+        (if (eshell-under-windows-p)
+            (push "." paths))
        ;; Go thru each path in the search path, finding completions.
        (while paths
          (setq path (file-name-as-directory
@@ -424,7 +435,9 @@ to writing a completion function."
            (if (and (not (member file completions)) ;
                     (or (string-equal path cwd)
                         (not (file-directory-p filepath)))
-                    (file-executable-p filepath))
+                     (if eshell-force-execution
+                         (file-readable-p filepath)
+                       (file-executable-p filepath)))
                (setq completions (cons file completions)))
            (setq comps-in-path (cdr comps-in-path)))
          (setq paths (cdr paths)))