From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: Feature request : Tab-completion for 'shell-comand' Date: Thu, 06 Mar 2008 12:04:36 +0200 Organization: JURTA Message-ID: <87mypccg6r.fsf@jurta.org> References: <874pbmjgsy.fsf@gmx.de> <874pbknt3j.fsf@tsuchiya.vaj.namazu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1204800091 5363 80.91.229.12 (6 Mar 2008 10:41:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 6 Mar 2008 10:41:31 +0000 (UTC) Cc: Michael Albinus , Stefan Monnier , emacs-devel@gnu.org To: TSUCHIYA Masatoshi Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Mar 06 11:41:52 2008 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 1JXDXr-00076L-2T for ged-emacs-devel@m.gmane.org; Thu, 06 Mar 2008 11:41:51 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JXDXJ-0004av-DT for ged-emacs-devel@m.gmane.org; Thu, 06 Mar 2008 05:41:17 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JXDUr-0003Sq-3n for emacs-devel@gnu.org; Thu, 06 Mar 2008 05:38:45 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JXDUn-0003R6-U1 for emacs-devel@gnu.org; Thu, 06 Mar 2008 05:38:42 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JXDUn-0003Qr-C9 for emacs-devel@gnu.org; Thu, 06 Mar 2008 05:38:41 -0500 Original-Received: from relay01.kiev.sovam.com ([62.64.120.200]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JXDUm-00037y-Ev for emacs-devel@gnu.org; Thu, 06 Mar 2008 05:38:41 -0500 Original-Received: from [83.170.232.243] (helo=smtp.svitonline.com) by relay01.kiev.sovam.com with esmtp (Exim 4.67) (envelope-from ) id 1JXDUf-0003nn-69; Thu, 06 Mar 2008 12:38:33 +0200 In-Reply-To: <874pbknt3j.fsf@tsuchiya.vaj.namazu.org> (TSUCHIYA Masatoshi's message of "Thu, 06 Mar 2008 17:40:16 +0900") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-unknown-linux-gnu) X-Scanner-Signature: ca614d1e091d53a46adb2ef7a730c6a6 X-DrWeb-checked: yes X-SpamTest-Envelope-From: juri@jurta.org X-SpamTest-Group-ID: 00000000 X-SpamTest-Header: Not Detected X-SpamTest-Info: Profiles 2364 [Mar 6 2008] X-SpamTest-Info: helo_type=3 X-SpamTest-Info: {HEADERS: header Content-Type found without required header Content-Transfer-Encoding} X-SpamTest-Method: none X-SpamTest-Rate: 11 X-SpamTest-Status: Not detected X-SpamTest-Status-Extended: not_detected X-SpamTest-Version: SMTP-Filter Version 3.0.0 [0278], KAS30/Release X-detected-kernel: by monty-python.gnu.org: FreeBSD 4.8-5.1 (or MacOS X 10.2-10.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:91481 Archived-At: >>This is a useful feature to add to Emacs, and it is a pity it uses defadvices. >>Perhaps defadvices could be replaced by a new shell-command specific >>minibuffer keymap that just redefines TAB to perform completion on commands >>and file names. What I mean basically is: > >>(define-key shell-command-minibuffer-local-map "\t" >> (lambda () >> (interactive) >> (require 'shell) >> (let ((comint-dynamic-complete-functions >> shell-dynamic-complete-functions)) >> (comint-dynamic-complete)))) > > This code is insufficient, because the output of `message' function > which is called from tab-completion functions will bury the current > completing status in minibuffer. Yes, these messages overwrite the minibuffer, but instead of temporarily redefining the function `message' as in shell-command.el, it would be better to fix comint.el and shell.el to not display completion messages when the minibuffer is active. These files already contain places where this check is done this way: (unless (window-minibuffer-p (selected-window)) (message "Completing file name...")) I think we should add the same to more places with the following patch: Index: lisp/comint.el =================================================================== RCS file: /sources/emacs/emacs/lisp/comint.el,v retrieving revision 1.373 diff -u -r1.373 comint.el --- lisp/comint.el 22 Jan 2008 23:53:43 -0000 1.373 +++ lisp/comint.el 6 Mar 2008 10:01:27 -0000 @@ -3014,7 +3014,8 @@ (current-window-configuration)) (with-output-to-temp-buffer "*Completions*" (display-completion-list completions)) - (message "Type space to flush; repeat completion command to scroll")) + (unless (window-minibuffer-p (selected-window)) + (message "Type space to flush; repeat completion command to scroll"))) ;; Read the next key, to process SPC. (let (key first) Index: lisp/shell.el =================================================================== RCS file: /sources/emacs/emacs/lisp/shell.el,v retrieving revision 1.158 diff -u -r1.158 shell.el --- lisp/shell.el 8 Jan 2008 20:44:52 -0000 1.158 +++ lisp/shell.el 6 Mar 2008 10:02:11 -0000 @@ -965,7 +965,8 @@ (save-match-data (not (string-match "[~/]" filename))) (eq (match-beginning 0) (save-excursion (shell-backward-command 1) (point)))) - (prog2 (message "Completing command name...") + (prog2 (unless (window-minibuffer-p (selected-window)) + (message "Completing command name...")) (shell-dynamic-complete-as-command))))) > And more, the customize hook like `shell-command-complete-functions' > will be necessary, in order to enable users to customize tab-completion > functions. I agree that this user option `shell-command-complete-functions' is necessary for users to customize, and I think its default value should be the same as the default value of `shell-dynamic-complete-functions'. Also I see that shell-command.el changes the shell-command prompt. I think this is a separate feature that is better to implement as a minor mode that uses `minibuffer-setup-hook' to add shell-command specific information to the created prompt. Please see a mode like minibuffer-electric-default-mode or file-name-shadow-mode for the ideas how this could be implemented. -- Juri Linkov http://www.jurta.org/emacs/