all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: TSUCHIYA Masatoshi <tsuchiya@namazu.org>
Cc: Stefan Monnier <monnier@iro.umontreal.ca>, emacs-devel@gnu.org
Subject: Re: Feature request : Tab-completion for 'shell-comand'
Date: Sat, 15 Mar 2008 23:35:27 +0200	[thread overview]
Message-ID: <87k5k3u70z.fsf@jurta.org> (raw)
In-Reply-To: <87y78kwfsv.fsf@tsuchiya.vaj.namazu.org> (TSUCHIYA Masatoshi's message of "Sat, 15 Mar 2008 17:29:52 +0900")

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




  parent reply	other threads:[~2008-03-15 21:35 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
2008-03-15 10:24                     ` paul r
2008-03-15 21:35                     ` Juri Linkov [this message]
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=87k5k3u70z.fsf@jurta.org \
    --to=juri@jurta.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=tsuchiya@namazu.org \
    /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.