From: TSUCHIYA Masatoshi <tsuchiya@namazu.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Juri Linkov <juri@jurta.org>,
Michael Albinus <michael.albinus@gmx.de>,
emacs-devel@gnu.org
Subject: Re: Feature request : Tab-completion for 'shell-comand'
Date: Sat, 15 Mar 2008 17:29:52 +0900 [thread overview]
Message-ID: <87y78kwfsv.fsf@tsuchiya.vaj.namazu.org> (raw)
In-Reply-To: <jwvod9khffq.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Tue, 11 Mar 2008 22:12:01 -0400")
[-- Attachment #1: Type: text/plain, Size: 524 bytes --]
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: completion.diff --]
[-- Type: text/x-diff, Size: 4267 bytes --]
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.")
\f
;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.
next prev parent reply other threads:[~2008-03-15 8:29 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-04 16:42 Feature request : Tab-completion for 'shell-comand' paul r
2008-03-04 21:54 ` Michael Albinus
2008-03-04 23:17 ` Juri Linkov
2008-03-05 1:55 ` Stefan Monnier
2008-03-06 8:40 ` TSUCHIYA Masatoshi
2008-03-06 10:04 ` Juri Linkov
2008-03-06 16:04 ` Stefan Monnier
2008-03-06 16:14 ` Drew Adams
2008-03-06 17:31 ` Miles Bader
2008-03-06 17:46 ` Drew Adams
2008-03-06 18:21 ` Stefan Monnier
2008-03-07 2:14 ` Miles Bader
2008-03-06 23:48 ` Juri Linkov
2008-03-06 17:48 ` Juri Linkov
2008-03-06 23:45 ` Juri Linkov
2008-03-06 23:47 ` Juri Linkov
2008-03-08 17:39 ` Richard Stallman
2008-03-08 22:21 ` Juri Linkov
2008-03-08 22:38 ` Lennart Borgman (gmail)
2008-03-08 22:57 ` Juri Linkov
2008-03-09 0:21 ` Lennart Borgman (gmail)
2008-03-08 23:27 ` Stefan Monnier
2008-03-09 16:39 ` Richard Stallman
2008-03-09 17:45 ` Juri Linkov
2008-03-10 6:12 ` Richard Stallman
2008-03-10 14:44 ` Cannot build the trunk since unicode (was: Feature request : Tab-completion for 'shell-comand') Stefan Monnier
2008-03-11 9:24 ` Richard Stallman
2008-03-11 9:40 ` Andreas Schwab
2008-03-10 22:35 ` Feature request : Tab-completion for 'shell-comand' Juri Linkov
2008-03-11 20:24 ` Richard Stallman
2008-03-12 0:31 ` Juri Linkov
2008-03-12 23:13 ` Johan Bockgård
2008-03-12 23:19 ` David Kastrup
2008-03-12 23:36 ` Johan Bockgård
2008-03-13 2:14 ` Juri Linkov
2008-03-13 9:28 ` Johan Bockgård
2008-03-13 14:54 ` Stefan Monnier
2008-03-13 19:02 ` martin rudalics
2008-03-14 2:54 ` Richard Stallman
2008-03-14 7:46 ` martin rudalics
2008-03-14 15:07 ` Stefan Monnier
2008-03-15 3:23 ` Richard Stallman
2008-03-15 3:24 ` Richard Stallman
2008-03-14 3:21 ` Stefan Monnier
2008-03-14 7:47 ` martin rudalics
2008-03-14 15:05 ` Stefan Monnier
2008-03-14 18:33 ` martin rudalics
2008-03-14 19:20 ` Stefan Monnier
2008-03-14 22:31 ` martin rudalics
2008-03-15 0:59 ` Stefan Monnier
2008-03-16 14:24 ` martin rudalics
2008-03-16 18:28 ` Stefan Monnier
2008-03-17 7:36 ` martin rudalics
2008-03-17 15:00 ` Stefan Monnier
2008-03-14 1:04 ` Juri Linkov
2008-03-09 14:01 ` TSUCHIYA Masatoshi
2008-03-09 17:48 ` Juri Linkov
2008-03-10 0:08 ` TSUCHIYA Masatoshi
2008-03-10 0:57 ` Drew Adams
2008-03-10 1:29 ` Juri Linkov
2008-03-10 2:20 ` Johan Bockgård
2008-03-10 2:37 ` Lennart Borgman (gmail)
2008-03-10 22:31 ` Juri Linkov
2008-03-12 1:31 ` TSUCHIYA Masatoshi
2008-03-12 2:12 ` Stefan Monnier
2008-03-12 10:42 ` Juri Linkov
2008-03-15 8:29 ` TSUCHIYA Masatoshi [this message]
2008-03-15 10:24 ` paul r
2008-03-15 21:35 ` Juri Linkov
2008-03-20 19:58 ` Stefan Monnier
2008-03-20 20:55 ` Juri Linkov
2008-03-21 17:17 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y78kwfsv.fsf@tsuchiya.vaj.namazu.org \
--to=tsuchiya@namazu.org \
--cc=emacs-devel@gnu.org \
--cc=juri@jurta.org \
--cc=michael.albinus@gmx.de \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.