[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Feature request : Tab-completion for 'shell-comand'

From: Juri Linkov
Subject: Re: Feature request : Tab-completion for 'shell-comand'
Date: Thu, 06 Mar 2008 12:04:36 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-unknown-linux-gnu)

>>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 @@
       (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..."))

> 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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]