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: Sat, 15 Mar 2008 23:35:27 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-pc-linux-gnu)

>>> 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.

Thanks for your patch.  It seems everything is correct in your patch,
except the unresolved general problem of displaying completion messages
in the minibuffer.  Currently typing TAB displays the message
"[Completing command name...]" and waits 2 sec before displaying the
*Completions* buffer.  Until this problem is solved, minibuffer messages
cause delays that make this feature almost unusable.

But I noticed that this problem is already solved in comint.el for file
name completions.  In `comint-dynamic-complete-as-filename', completion
messages are displayed only when not in the minibuffer, except the error
message "No completions" that is important to display in the minibuffer.
Also it displays "Completing file name..." conditionally outside of
the minibuffer.

I assure this really works well because these messages are not very
important to display in the minibuffer, and the status of completion is
evident from the completions list and the content of the minibuffer
(e.g. partial completion doesn't insert a space after completion,
but complete completion inserts it, etc.)

So until a general way to display messages without a delay in the
minibuffer is found, I propose to use exactly the same solution already
implemented in `comint-dynamic-complete-as-filename' to display messages
conditionally in `comint-dynamic-simple-complete' too (plus one message
in shell.el).

Also using `minibuffer-message' to display two remaining messages
("No completions of ..." and "Type space to flush ...") makes
unneccessary a trick in your patch that redefines the `message' function.

I suggest to install the following patch, and after that to install
your patch with removing now unneccessary `minibuffer-completing-message'
and removing `fset' code in `minibuffer-complete-shell-command'.

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      15 Mar 2008 21:35:00 -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,2965 ****
                         (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))
--- 2966,2973 ----
                         (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))
***************
*** 2967,2973 ****
                    (comint-dynamic-list-completions completions)
                    'listed)
                   (t
!                   (message "Partially completed")
                    'partial)))))))
  
  
--- 2975,2982 ----
                    (comint-dynamic-list-completions completions)
                    'listed)
                   (t
!                   (unless minibuffer-p
!                     (message "Partially completed"))
                    'partial)))))))
  
  
***************
*** 2985,2991 ****
         (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)))))
  
--- 2994,3002 ----
         (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)))))
  
***************
*** 3031,3037 ****
            (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,3050 ----
            (current-window-configuration))
        (with-output-to-temp-buffer "*Completions*"
        (display-completion-list completions))
!       (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       15 Mar 2008 21:34:35 -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/




reply via email to

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