X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/8678d9e413593b0abab296551a20589745c459da..4b9f0b67dae95106356e2cd7c7f03622702026f2:/lisp/eshell/em-cmpl.el diff --git a/lisp/eshell/em-cmpl.el b/lisp/eshell/em-cmpl.el index f3f104c1ed..91311deffc 100644 --- a/lisp/eshell/em-cmpl.el +++ b/lisp/eshell/em-cmpl.el @@ -1,6 +1,6 @@ ;;; em-cmpl.el --- completion using the TAB key -;; Copyright (C) 1999-2011 Free Software Foundation, Inc. +;; Copyright (C) 1999-2013 Free Software Foundation, Inc. ;; Author: John Wiegley @@ -63,29 +63,31 @@ ;; The list of possible completions can be viewed at any point by ;; pressing . ;; -;; Finally, context-related help can be accessed by pressing . +;; Finally, context-related help can be accessed by pressing . ;; This only works well if the completion function has provided Eshell ;; with sufficient pointers to locate the relevant help text. ;;; Code: (eval-when-compile - (require 'cl) + (require 'cl-lib) (require 'eshell)) (require 'esh-util) ;;;###autoload -(eshell-defgroup eshell-cmpl nil +(progn +(defgroup eshell-cmpl nil "This module provides a programmable completion function bound to the TAB key, which allows for completing command names, file names, variable names, arguments, etc." :tag "Argument completion" - :group 'eshell-module) + :group 'eshell-module)) ;;; User Variables: -(defcustom eshell-cmpl-load-hook '(eshell-cmpl-initialize) +(defcustom eshell-cmpl-load-hook nil "A list of functions to run when `eshell-cmpl' is loaded." + :version "24.1" ; removed eshell-cmpl-initialize :type 'hook :group 'eshell-cmpl) @@ -293,13 +295,14 @@ to writing a completion function." 'pcomplete-expand-and-complete) (define-key eshell-command-map [space] 'pcomplete-expand) (define-key eshell-command-map [? ] 'pcomplete-expand) - (define-key eshell-mode-map [tab] 'pcomplete) - (define-key eshell-mode-map [(control ?i)] 'pcomplete) + (define-key eshell-mode-map [tab] 'eshell-pcomplete) + (define-key eshell-mode-map [(control ?i)] 'eshell-pcomplete) + (add-hook 'completion-at-point-functions + #'pcomplete-completions-at-point nil t) ;; jww (1999-10-19): Will this work on anything but X? (if (featurep 'xemacs) (define-key eshell-mode-map [iso-left-tab] 'pcomplete-reverse) - (define-key eshell-mode-map [(shift iso-lefttab)] 'pcomplete-reverse) - (define-key eshell-mode-map [(shift control ?i)] 'pcomplete-reverse)) + (define-key eshell-mode-map [backtab] 'pcomplete-reverse)) (define-key eshell-mode-map [(meta ??)] 'pcomplete-list)) (defun eshell-completion-command-name () @@ -357,7 +360,7 @@ to writing a completion function." (nconc posns (list pos))) (setq pos (1+ pos)))) (setq posns (cdr posns)) - (assert (= (length args) (length posns))) + (cl-assert (= (length args) (length posns))) (let ((a args) (i 0) l final) @@ -369,7 +372,7 @@ to writing a completion function." (and l (setq args (nthcdr (1+ l) args) posns (nthcdr (1+ l) posns)))) - (assert (= (length args) (length posns))) + (cl-assert (= (length args) (length posns))) (when (and args (eq (char-syntax (char-before end)) ? ) (not (eq (char-before (1- end)) ?\\))) (nconc args (list "")) @@ -382,7 +385,7 @@ to writing a completion function." (let ((result (eshell-do-eval (list 'eshell-commands arg) t))) - (assert (eq (car result) 'quote)) + (cl-assert (eq (car result) 'quote)) (cadr result)) arg))) (if (numberp val) @@ -448,6 +451,17 @@ to writing a completion function." (all-completions filename obarray 'functionp)) completions))))))) +(defun eshell-pcomplete (&optional interactively) + "Eshell wrapper for `pcomplete'." + (interactive "p") + ;; Pretend to be pcomplete so that cycling works (bug#13293). + (setq this-command 'pcomplete) + (condition-case nil + (if interactively + (call-interactively 'pcomplete) + (pcomplete)) + (text-read-only (completion-at-point)))) ; Workaround for bug#12838. + (provide 'em-cmpl) ;; Local Variables: