From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: TSUCHIYA Masatoshi Newsgroups: gmane.emacs.devel Subject: Re: Feature request : Tab-completion for 'shell-comand' Date: Sat, 15 Mar 2008 17:29:52 +0900 Message-ID: <87y78kwfsv.fsf@tsuchiya.vaj.namazu.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> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1205569818 10490 80.91.229.12 (15 Mar 2008 08:30:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 15 Mar 2008 08:30:18 +0000 (UTC) Cc: Juri Linkov , Michael Albinus , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Mar 15 09:30:46 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 1JaRmr-0002us-6a for ged-emacs-devel@m.gmane.org; Sat, 15 Mar 2008 09:30:41 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JaRmH-0005Be-Pf for ged-emacs-devel@m.gmane.org; Sat, 15 Mar 2008 04:30:05 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JaRmB-00057p-1F for emacs-devel@gnu.org; Sat, 15 Mar 2008 04:29:59 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JaRm5-00052R-9O for emacs-devel@gnu.org; Sat, 15 Mar 2008 04:29:57 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JaRm4-00052D-Vw for emacs-devel@gnu.org; Sat, 15 Mar 2008 04:29:53 -0400 Original-Received: from vaj.namazu.org ([202.221.179.42]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JaRm4-0006Xp-7B for emacs-devel@gnu.org; Sat, 15 Mar 2008 04:29:52 -0400 Original-Received: from vaj.namazu.org (vaj.namazu.org [202.221.179.42]) by vaj.namazu.org (Postfix) with ESMTP id 1024920D65; Sat, 15 Mar 2008 17:29:47 +0900 (JST) X-cite: xcite 1.56 X-Cite-Me: =?iso-2022-jp?B?GyRCRVobKEI=?= In-Reply-To: (Stefan Monnier's message of "Tue, 11 Mar 2008 22:12:01 -0400") User-Agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.1 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Linux 2.4-2.6 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:92658 Archived-At: --=-=-= Dear Emacs developers, >> On Tue, 11 Mar 2008 22:12:01 -0400 >> monnier@iro.umontreal.ca (Stefan Monnier) said as follows: >> I have just prepared the minimized patch to support tab-completion >> features for `shell-command' etc. >Could you provide a new version of your patch without the >make-shell-prompt-string? 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. Regards, -- TSUCHIYA Masatoshi --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=completion.diff diff -ur emacs-22.1.orig/lisp/progmodes/compile.el emacs-22.1/lisp/progmodes/compile.el --- emacs-22.1.orig/lisp/progmodes/compile.el 2007-05-25 21:43:33.000000000 +0900 +++ emacs-22.1/lisp/progmodes/compile.el 2008-03-15 17:18:37.000000000 +0900 @@ -902,7 +902,9 @@ (let ((command (eval compile-command))) (if (or compilation-read-command current-prefix-arg) (read-from-minibuffer "Compile command: " - command nil nil + command + minibuffer-complete-shell-command-map + nil (if (equal (car compile-history) command) '(compile-history . 1) 'compile-history)) diff -ur emacs-22.1.orig/lisp/progmodes/grep.el emacs-22.1/lisp/progmodes/grep.el --- emacs-22.1.orig/lisp/progmodes/grep.el 2007-04-08 11:08:48.000000000 +0900 +++ emacs-22.1/lisp/progmodes/grep.el 2008-03-15 17:19:44.000000000 +0900 @@ -541,7 +541,8 @@ (list (read-from-minibuffer "Run grep (like this): " (if current-prefix-arg default grep-command) - nil nil 'grep-history + minibuffer-complete-shell-command-map + nil 'grep-history (if current-prefix-arg nil default)))))) ;; Setting process-setup-function makes exit-message-function work @@ -566,7 +567,9 @@ (grep-compute-defaults) (if grep-find-command (list (read-from-minibuffer "Run find (like this): " - grep-find-command nil nil + grep-find-command + minibuffer-complete-shell-command-map + nil 'grep-find-history)) ;; No default was set (read-string diff -ur emacs-22.1.orig/lisp/simple.el emacs-22.1/lisp/simple.el --- emacs-22.1.orig/lisp/simple.el 2007-05-27 23:35:51.000000000 +0900 +++ emacs-22.1/lisp/simple.el 2008-03-15 17:25:40.000000000 +0900 @@ -1367,6 +1367,42 @@ ;; Return the width of everything before the field at the end of ;; the buffer; this should be 0 for normal buffers. (1- (minibuffer-prompt-end))) + +(defcustom minibuffer-complete-shell-command-functions + '(shell-dynamic-complete-environment-variable + shell-dynamic-complete-command + shell-replace-by-expanded-directory + comint-dynamic-complete-filename) + "*Function list to complete shell commands." + :type 'hook + :group 'shell) + +(defun minibuffer-completing-message (string &rest arguments) + "Alternative function of `message' when completing shell command." + (let ((s (apply (function format) string arguments))) + (minibuffer-message (concat " [" s "]")) + s)) + +(defun minibuffer-complete-shell-command () + "Dynamically complete shell command at point with functions +specified in `minibuffer-complete-shell-command-functions'." + (interactive) + (let ((orig-function (symbol-function 'message))) + (unwind-protect + (progn + (fset 'message 'minibuffer-completing-message) + (require 'shell) + (require 'comint) + (run-hook-with-args-until-success + 'minibuffer-complete-shell-command-functions)) + (fset 'message orig-function)))) + +(defvar minibuffer-complete-shell-command-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map minibuffer-local-map) + (define-key map "\t" 'minibuffer-complete-shell-command) + map) + "Keymap used for completiing shell commands in minibufffer.") ;Put this on C-x u, so we can force that rather than C-_ into startup msg (defalias 'advertised-undo 'undo) @@ -1809,7 +1845,10 @@ specifies the value of ERROR-BUFFER." (interactive (list (read-from-minibuffer "Shell command: " - nil nil nil 'shell-command-history) + nil + minibuffer-complete-shell-command-map + nil + 'shell-command-history) current-prefix-arg shell-command-default-error-buffer)) ;; Look for a handler in case default-directory is a remote file name. @@ -2028,7 +2067,9 @@ ;; and region-end, in case subprocess output ;; relocates them while we are in the minibuffer. (setq string (read-from-minibuffer "Shell command on region: " - nil nil nil + nil + minibuffer-complete-shell-command-map + nil 'shell-command-history)) ;; call-interactively recognizes region-beginning and ;; region-end specially, leaving them in the history. --=-=-=--