X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/fbf349734468d48b421c3d03074bb66dfcf3115b..004a00f4ae0d64a86265c0fa6d6d52f0fa3d9434:/lisp/pcomplete.el diff --git a/lisp/pcomplete.el b/lisp/pcomplete.el index 785c62290c..8116ad91fd 100644 --- a/lisp/pcomplete.el +++ b/lisp/pcomplete.el @@ -1,7 +1,7 @@ ;;; pcomplete.el --- programmable completion ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 -;; 2005 Free Sofware Foundation, Inc. +;; 2005, 2006, 2007 Free Software Foundation, Inc. ;; Author: John Wiegley ;; Keywords: processes abbrev @@ -10,7 +10,7 @@ ;; 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) +;; the Free Software Foundation; either version 3, or (at your option) ;; any later version. ;; GNU Emacs is distributed in the hope that it will be useful, @@ -33,7 +33,6 @@ ;; To use pcomplete with shell-mode, for example, you will need the ;; following in your .emacs file: ;; -;; (load "pcmpl-auto") ;; (add-hook 'shell-mode-hook 'pcomplete-shell-setup) ;; ;; Most of the code below simply provides support mechanisms for @@ -282,6 +281,10 @@ to all arguments, such as variable names after a $." :type 'hook :group 'pcomplete) +(defsubst pcomplete-executables (&optional regexp) + "Complete amongst a list of directories and executables." + (pcomplete-entries regexp 'file-executable-p)) + (defcustom pcomplete-command-completion-function (function (lambda () @@ -600,6 +603,8 @@ this is `comint-dynamic-complete-functions'." "Setup shell-mode to use pcomplete." (pcomplete-comint-setup 'shell-dynamic-complete-functions)) +(declare-function comint-bol "comint" (&optional arg)) + (defun pcomplete-parse-comint-arguments () "Parse whitespace separated arguments in the current region." (let ((begin (save-excursion (comint-bol nil) (point))) @@ -712,6 +717,7 @@ If PREDICATE is non-nil, it will also be used to refine the match If no directory information can be extracted from the completed component, `default-directory' is used as the basis for completion." (let* ((name (substitute-env-vars pcomplete-stub)) + (completion-ignore-case pcomplete-ignore-case) (default-directory (expand-file-name (or (file-name-directory name) default-directory))) @@ -780,10 +786,6 @@ component, `default-directory' is used as the basis for completion." "Complete amongst a list of directories." (pcomplete-entries regexp 'file-directory-p)) -(defsubst pcomplete-executables (&optional regexp) - "Complete amongst a list of directories and executables." - (pcomplete-entries regexp 'file-executable-p)) - ;; generation of completion lists (defun pcomplete-find-completion-function (command) @@ -935,7 +937,7 @@ generate the completions list. This means that the hook (if pcomplete-last-window-config (let* ((cbuf (get-buffer "*Completions*")) (cwin (and cbuf (get-buffer-window cbuf)))) - (when (and cwin (window-live-p cwin)) + (when (window-live-p cwin) (bury-buffer cbuf) (set-window-configuration pcomplete-last-window-config)))) (setq pcomplete-last-window-config nil @@ -944,18 +946,16 @@ generate the completions list. This means that the hook ;; Abstractions so that the code below will work for both Emacs 20 and ;; XEmacs 21 -(unless (fboundp 'event-matches-key-specifier-p) - (defalias 'event-matches-key-specifier-p 'eq)) +(defalias 'pcomplete-event-matches-key-specifier-p + (if (featurep 'xemacs) + 'event-matches-key-specifier-p + 'eq)) -(if (fboundp 'read-event) - (defsubst pcomplete-read-event (&optional prompt) - (read-event prompt)) - (defsubst pcomplete-read-event (&optional prompt) +(defun pcomplete-read-event (&optional prompt) + (if (fboundp 'read-event) + (read-event prompt) (aref (read-key-sequence prompt) 0))) -(unless (fboundp 'event-basic-type) - (defalias 'event-basic-type 'event-key)) - (defun pcomplete-show-completions (completions) "List in help buffer sorted COMPLETIONS. Typing SPC flushes the help buffer." @@ -974,16 +974,20 @@ Typing SPC flushes the help buffer." (while (with-current-buffer (get-buffer "*Completions*") (setq event (pcomplete-read-event))) (cond - ((event-matches-key-specifier-p event ? ) + ((pcomplete-event-matches-key-specifier-p event ?\s) (set-window-configuration pcomplete-last-window-config) (setq pcomplete-last-window-config nil) (throw 'done nil)) - ((event-matches-key-specifier-p event 'tab) - (save-selected-window - (select-window (get-buffer-window "*Completions*")) - (if (pos-visible-in-window-p (point-max)) - (goto-char (point-min)) - (scroll-up))) + ((or (pcomplete-event-matches-key-specifier-p event 'tab) + ;; Needed on a terminal + (pcomplete-event-matches-key-specifier-p event 9)) + (let ((win (or (get-buffer-window "*Completions*" 0) + (display-buffer "*Completions*" + 'not-this-window)))) + (with-selected-window win + (if (pos-visible-in-window-p (point-max)) + (goto-char (point-min)) + (scroll-up)))) (message "")) (t (setq unread-command-events (list event)) @@ -1138,7 +1142,7 @@ If specific documentation can't be given, be generic." (fboundp 'Info-goto-node)) (listp pcomplete-help))) (if (listp pcomplete-help) - (message (eval pcomplete-help)) + (message "%s" (eval pcomplete-help)) (save-window-excursion (info)) (switch-to-buffer-other-window "*info*") (funcall (symbol-function 'Info-goto-node) pcomplete-help))