From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Using pcomplete for read-shell-command Date: Tue, 24 Nov 2009 16:10:37 -0500 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1259097247 9103 80.91.229.12 (24 Nov 2009 21:14:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 24 Nov 2009 21:14:07 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Nov 24 22:14:00 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1ND2gK-0003sk-1f for ged-emacs-devel@m.gmane.org; Tue, 24 Nov 2009 22:12:16 +0100 Original-Received: from localhost ([127.0.0.1]:36557 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ND2gI-0001v0-Kg for ged-emacs-devel@m.gmane.org; Tue, 24 Nov 2009 16:12:14 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ND2f9-0001Yg-RK for emacs-devel@gnu.org; Tue, 24 Nov 2009 16:11:03 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ND2f6-0001W9-3Q for emacs-devel@gnu.org; Tue, 24 Nov 2009 16:11:03 -0500 Original-Received: from [199.232.76.173] (port=43662 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ND2f5-0001W3-Mp for emacs-devel@gnu.org; Tue, 24 Nov 2009 16:10:59 -0500 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]:47060) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1ND2f5-0007iJ-DF for emacs-devel@gnu.org; Tue, 24 Nov 2009 16:10:59 -0500 Original-Received: from faina.iro.umontreal.ca (faina.iro.umontreal.ca [132.204.26.177]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id nAOLAbG2007358; Tue, 24 Nov 2009 16:10:37 -0500 Original-Received: by faina.iro.umontreal.ca (Postfix, from userid 20848) id 0A6C73A1B6; Tue, 24 Nov 2009 16:10:37 -0500 (EST) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV3413=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:117706 Archived-At: I don't use shell-mode much, but I enter shell commands occasionally and find the completion behavior to be a bit poor sometimes. Pcomplete is a bit more clever, since it knows about the arguments of various commands. I've been using the patch below for that reason. Using pcomplete there was proposed a long time ago and was rejected because the behavior was too different from our normal completion, but the patch below uses the new pcomplete-std-complete which uses pcomplete's infrastructure but with the normal UI on top of it. As mentioned, I only enter commands occasionally, so it hasn't been tested extensively. The only problem I already know with it is that it doesn't do partial-completion of file names (tho I have a patch for it in pcomplete.el, but it's a bit risky, so I'd rather leave it for later). Stefan Using submit branch file:///home/monnier/src/emacs/bzr/trunk/ === modified file 'lisp/simple.el' --- lisp/simple.el 2009-11-20 03:58:42 +0000 +++ lisp/simple.el 2009-11-24 20:50:45 +0000 @@ -2038,11 +2093,18 @@ (defun minibuffer-complete-shell-command () "Dynamically complete shell command at point." (interactive) + ;; Do a mini shell-mode setup. (require 'shell) - (let ((comint-delimiter-argument-list shell-delimiter-argument-list) - (comint-file-name-chars shell-file-name-chars) - (comint-file-name-quote-list shell-file-name-quote-list)) - (run-hook-with-args-until-success 'shell-dynamic-complete-functions))) + (set (make-local-variable 'comint-delimiter-argument-list) + shell-delimiter-argument-list) + (set (make-local-variable 'comint-file-name-chars) shell-file-name-chars) + (set (make-local-variable 'comint-file-name-quote-list) + shell-file-name-quote-list) + (set (make-local-variable 'comint-dynamic-complete-functions) + shell-dynamic-complete-functions) + (pcomplete-shell-setup) + ;; Perform the actual completion. + (pcomplete-std-complete)) (defvar minibuffer-local-shell-command-map (let ((map (make-sparse-keymap)))