emacs-devel
[Top][All Lists]
Advanced

[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: Mon, 10 Mar 2008 03:29:02 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-unknown-linux-gnu)

> But I still think my idea to use a minibuffer as two areas is effective.
> Could you evaluate the following code after loading shell-command.el and
> try `shell-command' again?
>
> (defun shell-command-read-minibuffer
>   (format-string current-directory &optional initial-contents
>                user-keymap read hist)
>   "Read a command string in the minibuffer, with completion."
>   (let ((keymap (make-sparse-keymap))
>       (prompt (shell-command-make-prompt-string
>                format-string current-directory)))
>     (set-keymap-parent keymap (or user-keymap minibuffer-local-map))
>     (define-key keymap "\t"
>       (lambda ()
>       (interactive)
>       (let ((orig-function (symbol-function 'message)))
>         (unwind-protect
>             (progn
>               (defun message (string &rest arguments)
>                 (let* ((s1 (concat prompt
>                                    (buffer-substring
>                                     (shell-command/minibuffer-prompt-end)
>                                     (point-max))))
>                        (s2 (apply (function format) string arguments))
>                        (w (- (window-width)
>                              (string-width s1)
>                              (string-width s2)
>                              3)))
>                   (funcall orig-function
>                            (if (>= w 0)
>                                (concat s1 " [" s2 "]")
>                              s2))
>                   (if (sit-for 2) (funcall orig-function s1))
>                   s2))
>               (require 'shell)
>               (require 'comint)
>               (run-hook-with-args-until-success
>                'shell-command-complete-functions))
>           (fset 'message orig-function)))))
>     (read-from-minibuffer prompt initial-contents keymap read hist)))
>
> I think that the above code still have a problem: the above code moves a
> cursor to the end of line temporarily.  I think that such temoporal
> movement will confuse users.

Yes, it would be too bad to move the cursor to the end of the line.
But `minibuffer-message' doesn't do this: it leaves the cursor before
the additional message appended to the minibuffer.

However, I still don't see a solution for the problem how to display
the message (such as "[Completing command name...]") without a delay,
and leave it visible to the user persistently without interfering
with the user input.

-- 
Juri Linkov
http://www.jurta.org/emacs/




reply via email to

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