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, 20 Mar 2008 22:55:12 +0200 Organization: JURTA Message-ID: <87ve3hundb.fsf@jurta.org> References: <874pbmjgsy.fsf@gmx.de> <874pbknt3j.fsf@tsuchiya.vaj.namazu.org> <87mypccg6r.fsf@jurta.org> <87r6ekm1wr.fsf@tsuchiya.vaj.namazu.org> <87ejajajbt.fsf@jurta.org> <87lk4rmodu.fsf@tsuchiya.vaj.namazu.org> <87lk4r74gt.fsf@jurta.org> <87skywrame.fsf@tsuchiya.vaj.namazu.org> <87y78kwfsv.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 1206046782 12096 80.91.229.12 (20 Mar 2008 20:59:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 20 Mar 2008 20:59:42 +0000 (UTC) Cc: Michael Albinus , TSUCHIYA Masatoshi , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Mar 20 22:00:10 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 1JcRrs-00049m-SW for ged-emacs-devel@m.gmane.org; Thu, 20 Mar 2008 22:00:09 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JcRrI-0004UR-N5 for ged-emacs-devel@m.gmane.org; Thu, 20 Mar 2008 16:59:32 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JcRrE-0004Ty-FS for emacs-devel@gnu.org; Thu, 20 Mar 2008 16:59:28 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JcRrD-0004TP-9m for emacs-devel@gnu.org; Thu, 20 Mar 2008 16:59:27 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JcRrD-0004TM-5g for emacs-devel@gnu.org; Thu, 20 Mar 2008 16:59:27 -0400 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 1JcRrC-0003Vu-Hx for emacs-devel@gnu.org; Thu, 20 Mar 2008 16:59:26 -0400 Original-Received: from [83.170.232.243] (helo=smtp.svitonline.com) by relay01.kiev.sovam.com with esmtp (Exim 4.67) (envelope-from ) id 1JcRr3-000FCw-T9; Thu, 20 Mar 2008 22:59:22 +0200 In-Reply-To: (Stefan Monnier's message of "Thu, 20 Mar 2008 15:58:27 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-pc-linux-gnu) X-Scanner-Signature: 9733fe9a83ca81746226be428b8a047e 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 2450 [Mar 20 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:93067 Archived-At: >> Thanks for your comments. I have just prepared the re-minimized version >> and attach it at the end of this message. I believe that this patch >> meets all of your comments. > > Thanks. I've installed a slightly different version. > Now we need to fix the minibuffer messages (and use read-shell-command > wherever it can be used). The following patch fixes the minibuffer messages. I tried it for a week, and it works really well. There is no need to display most of the completion messages (except "No completions") in the minibuffer because it is self-evident what completion does from its result (this is like completion in shells that doesn't display special messages but it is clear what it does without messages). This patch also fixes incorrect highlighting of the common completion substring by adding a new optional argument `common-substring' to `comint-dynamic-list-completions': Index: lisp/comint.el =================================================================== RCS file: /sources/emacs/emacs/lisp/comint.el,v retrieving revision 1.375 diff -c -r1.375 comint.el *** lisp/comint.el 12 Mar 2008 17:56:57 -0000 1.375 --- lisp/comint.el 20 Mar 2008 20:52:54 -0000 *************** *** 2871,2877 **** (directory (if filedir (comint-directory filedir) default-directory)) (completion (file-name-completion filenondir directory))) (cond ((null completion) ! (message "No completions of %s" filename) (setq success nil)) ((eq completion t) ; Means already completed "file". (insert filesuffix) --- 2871,2879 ---- (directory (if filedir (comint-directory filedir) default-directory)) (completion (file-name-completion filenondir directory))) (cond ((null completion) ! (if minibuffer-p ! (minibuffer-message (format " [No completions of %s]" filename)) ! (message "No completions of %s" filename)) (setq success nil)) ((eq completion t) ; Means already completed "file". (insert filesuffix) *************** *** 2935,2953 **** See also `comint-dynamic-complete-filename'." (let* ((completion-ignore-case (memq system-type '(ms-dos windows-nt cygwin))) (suffix (cond ((not comint-completion-addsuffix) "") ((not (consp comint-completion-addsuffix)) " ") (t (cdr comint-completion-addsuffix)))) (completions (all-completions stub candidates))) (cond ((null completions) ! (message "No completions of %s" stub) nil) ((= 1 (length completions)) ; Gotcha! (let ((completion (car completions))) (if (string-equal completion stub) ! (message "Sole completion") (insert (substring completion (length stub))) ! (message "Completed")) (insert suffix) 'sole)) (t ; There's no unique completion. --- 2937,2960 ---- See also `comint-dynamic-complete-filename'." (let* ((completion-ignore-case (memq system-type '(ms-dos windows-nt cygwin))) + (minibuffer-p (window-minibuffer-p (selected-window))) (suffix (cond ((not comint-completion-addsuffix) "") ((not (consp comint-completion-addsuffix)) " ") (t (cdr comint-completion-addsuffix)))) (completions (all-completions stub candidates))) (cond ((null completions) ! (if minibuffer-p ! (minibuffer-message (format " [No completions of %s]" stub)) ! (message "No completions of %s" stub)) nil) ((= 1 (length completions)) ; Gotcha! (let ((completion (car completions))) (if (string-equal completion stub) ! (unless minibuffer-p ! (message "Sole completion")) (insert (substring completion (length stub))) ! (unless minibuffer-p ! (message "Completed"))) (insert suffix) 'sole)) (t ; There's no unique completion. *************** *** 2959,2973 **** (member completion completions)) ;; It's not unique, but user wants shortest match. (insert suffix) ! (message "Completed shortest") 'shortest) ((or comint-completion-autolist (string-equal stub completion)) ;; It's not unique, list possible completions. ! (comint-dynamic-list-completions completions) 'listed) (t ! (message "Partially completed") 'partial))))))) --- 2966,2982 ---- (member completion completions)) ;; It's not unique, but user wants shortest match. (insert suffix) ! (unless minibuffer-p ! (message "Completed shortest")) 'shortest) ((or comint-completion-autolist (string-equal stub completion)) ;; It's not unique, list possible completions. ! (comint-dynamic-list-completions completions stub) 'listed) (t ! (unless minibuffer-p ! (message "Partially completed")) 'partial))))))) *************** *** 2985,2993 **** (directory (if filedir (comint-directory filedir) default-directory)) (completions (file-name-all-completions filenondir directory))) (if (not completions) ! (message "No completions of %s" filename) (comint-dynamic-list-completions ! (mapcar 'comint-quote-filename completions))))) ;; This is bound locally in a *Completions* buffer to the list of --- 2994,3005 ---- (directory (if filedir (comint-directory filedir) default-directory)) (completions (file-name-all-completions filenondir directory))) (if (not completions) ! (if (window-minibuffer-p (selected-window)) ! (minibuffer-message (format " [No completions of %s]" filename)) ! (message "No completions of %s" filename)) (comint-dynamic-list-completions ! (mapcar 'comint-quote-filename completions) ! filenondir)))) ;; This is bound locally in a *Completions* buffer to the list of *************** *** 2997,3003 **** (defvar comint-dynamic-list-completions-config nil) ! (defun comint-dynamic-list-completions (completions) "List in help buffer sorted COMPLETIONS. Typing SPC flushes the help buffer." (let ((window (get-buffer-window "*Completions*" 0))) --- 3009,3015 ---- (defvar comint-dynamic-list-completions-config nil) ! (defun comint-dynamic-list-completions (completions &optional common-substring) "List in help buffer sorted COMPLETIONS. Typing SPC flushes the help buffer." (let ((window (get-buffer-window "*Completions*" 0))) *************** *** 3030,3037 **** (setq comint-dynamic-list-completions-config (current-window-configuration)) (with-output-to-temp-buffer "*Completions*" ! (display-completion-list completions)) ! (message "Type space to flush; repeat completion command to scroll")) ;; Read the next key, to process SPC. (let (key first) --- 3042,3051 ---- (setq comint-dynamic-list-completions-config (current-window-configuration)) (with-output-to-temp-buffer "*Completions*" ! (display-completion-list completions common-substring)) ! (if (window-minibuffer-p (selected-window)) ! (minibuffer-message " [Type space to flush; repeat completion command to scroll]") ! (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 -c -r1.158 shell.el *** lisp/shell.el 8 Jan 2008 20:44:52 -0000 1.158 --- lisp/shell.el 20 Mar 2008 20:54:09 -0000 *************** *** 965,971 **** (save-match-data (not (string-match "[~/]" filename))) (eq (match-beginning 0) (save-excursion (shell-backward-command 1) (point)))) ! (prog2 (message "Completing command name...") (shell-dynamic-complete-as-command))))) --- 965,972 ---- (save-match-data (not (string-match "[~/]" filename))) (eq (match-beginning 0) (save-excursion (shell-backward-command 1) (point)))) ! (prog2 (unless (window-minibuffer-p (selected-window)) ! (message "Completing command name...")) (shell-dynamic-complete-as-command))))) *************** *** 1040,1046 **** (interactive) (let ((variable (shell-match-partial-variable))) (if (and variable (string-match "^\\$" variable)) ! (prog2 (message "Completing variable name...") (shell-dynamic-complete-as-environment-variable))))) --- 1041,1048 ---- (interactive) (let ((variable (shell-match-partial-variable))) (if (and variable (string-match "^\\$" variable)) ! (prog2 (unless (window-minibuffer-p (selected-window)) ! (message "Completing variable name...")) (shell-dynamic-complete-as-environment-variable))))) -- Juri Linkov http://www.jurta.org/emacs/