diff options
| author | Paul Eggert <eggert@cs.ucla.edu> | 2012-01-09 09:36:10 -0800 |
|---|---|---|
| committer | Paul Eggert <eggert@cs.ucla.edu> | 2012-01-09 09:36:10 -0800 |
| commit | 35cf62d95cdcd5323dcea4a5385942c342ff1d9c (patch) | |
| tree | 90358cbb033a126c4d48793a80fd804b7baaca24 /lisp/shell.el | |
| parent | 59815c02506eb39b61e672528ed03885749ba529 (diff) | |
| parent | 7655cb66d86564e792b825f1a0e1a4de7d6e6db5 (diff) | |
| download | emacs-35cf62d95cdcd5323dcea4a5385942c342ff1d9c.tar.gz | |
Merge from trunk.
Diffstat (limited to 'lisp/shell.el')
| -rw-r--r-- | lisp/shell.el | 44 |
1 files changed, 12 insertions, 32 deletions
diff --git a/lisp/shell.el b/lisp/shell.el index fdfc8b3cf19..e7a8953ecbe 100644 --- a/lisp/shell.el +++ b/lisp/shell.el @@ -1,6 +1,6 @@ ;;; shell.el --- specialized comint.el for running the shell -*- lexical-binding: t -*- -;; Copyright (C) 1988, 1993-1997, 2000-2011 Free Software Foundation, Inc. +;; Copyright (C) 1988, 1993-1997, 2000-2012 Free Software Foundation, Inc. ;; Author: Olin Shivers <shivers@cs.cmu.edu> ;; Simon Marshall <simon@gnu.org> @@ -189,7 +189,6 @@ This is a fine thing to set in your `.emacs' file.") shell-c-a-p-replace-by-expanded-directory pcomplete-completions-at-point shell-filename-completion - ;; Not sure when this one would still be useful. --Stef comint-filename-completion) "List of functions called to perform completion. This variable is used to initialize `comint-dynamic-complete-functions' in the @@ -372,18 +371,6 @@ Thus, this does not include the shell's current directory.") ;;; Basic Procedures -(defcustom shell-dir-cookie-re nil - "Regexp matching your prompt, including some part of the current directory. -If your prompt includes the current directory or the last few elements of it, -set this to a pattern that matches your prompt and whose subgroup 1 matches -the directory part of it. -This is used by `shell-dir-cookie-watcher' to try and use this info -to track your current directory. It can be used instead of or in addition -to `dirtrack-mode'." - :group 'shell - :type '(choice (const nil) regexp) - :version "24.1") - (defun shell-parse-pcomplete-arguments () "Parse whitespace separated arguments in the current region." (let ((begin (save-excursion (shell-backward-command 1) (point))) @@ -418,6 +405,15 @@ to `dirtrack-mode'." (push (mapconcat #'identity (nreverse arg) "") args))) (cons (nreverse args) (nreverse begins))))) +(defun shell-command-completion-function () + "Completion function for shell command names. +This is the value of `pcomplete-command-completion-function' for +Shell buffers. It implements `shell-completion-execonly' for +`pcomplete' completion." + (pcomplete-here (pcomplete-entries nil + (if shell-completion-execonly + 'file-executable-p)))) + (defun shell-completion-vars () "Setup completion vars for `shell-mode' and `read-shell-command'." (set (make-local-variable 'comint-completion-fignore) @@ -439,6 +435,8 @@ to `dirtrack-mode'." comint-completion-addsuffix) ((not (consp comint-completion-addsuffix)) " ") (t (cdr comint-completion-addsuffix)))) + (set (make-local-variable 'pcomplete-command-completion-function) + #'shell-command-completion-function) ;; Don't use pcomplete's defaulting mechanism, rely on ;; shell-dynamic-complete-functions instead. (set (make-local-variable 'pcomplete-default-completion-function) #'ignore) @@ -546,10 +544,6 @@ buffer." (when (string-equal shell "bash") (add-hook 'comint-preoutput-filter-functions 'shell-filter-ctrl-a-ctrl-b nil t))) - (when shell-dir-cookie-re - ;; Watch for magic cookies in the output to track the current dir. - (add-hook 'comint-output-filter-functions - 'shell-dir-cookie-watcher nil t)) (comint-read-input-ring t))) (defun shell-filter-ctrl-a-ctrl-b (string) @@ -710,20 +704,6 @@ Otherwise, one argument `-i' is passed to the shell. ;; replace it with a process filter that watches for and strips out ;; these messages. -(defun shell-dir-cookie-watcher (text) - ;; This is fragile: the TEXT could be split into several chunks and we'd - ;; miss it. Oh well. It's a best effort anyway. I'd expect that it's - ;; rather unusual to have the prompt split into several packets, but - ;; I'm sure Murphy will prove me wrong. - (when (and shell-dir-cookie-re (string-match shell-dir-cookie-re text)) - (let ((dir (match-string 1 text))) - (cond - ((file-name-absolute-p dir) (shell-cd dir)) - ;; Let's try and see if it seems to be up or down from where we were. - ((string-match "\\`\\(.*\\)\\(?:/.*\\)?\n\\(.*/\\)\\1\\(?:/.*\\)?\\'" - (setq text (concat dir "\n" default-directory))) - (shell-cd (concat (match-string 2 text) dir))))))) - (defun shell-directory-tracker (str) "Tracks cd, pushd and popd commands issued to the shell. This function is called on each input passed to the shell. |
