help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Question to completion


From: Klaus Berndl
Subject: Re: Question to completion
Date: 08 Nov 2003 15:14:52 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

Until now i have written a first solution which does what i want:

(defun offer-some-choices ()
  (interactive)
  ;; With these 3 TAB-events we ensure that
  ;; 1. The longest possible common substring is display in the minibuffer
  ;; 2. All possible completions are displayed
  (setq unread-command-events (cons 9 unread-command-events))
  (setq unread-command-events (cons 9 unread-command-events))
  (setq unread-command-events (cons 9 unread-command-events))
  (let ((file (completing-read
               "Select a file: "
               '(("c:/Programme/emacs-21/site-lisp/semantic/semanticdb-test.el" 
. t)
                 ("c:/Programme/emacs-21/site-lisp/ecb-navigate.el" . t)))))
    (message "Choosen file: %s" file)))

Now my question: Is this completely an ugly hack and what to do to write this
better?

Thanks for help,
Klaus

On 08 Nov 2003, Klaus Berndl wrote:

>  
>  Suppose i have s command like follows:
>  
>  (defun offer-some-choices ()
>    (interactive)
>    (completing-read "Select a name: " '(("Klaus" . t) ("Berndl" . t))))
>  
>  Then this displays in the minibuffer "Select a name: " and then wait for
>  input from the user.
>  
>  How can i achieve that always - *without* the user has to hit TAB - the
>  possible completions are displayed immediately? Or with other words: How to
>  simulate that the user has already pressed TAB as often as necessary to
>  display all possible completions? Best would be if the longest common
>  substring of all possible completions is displayed immediately in the
>  minibuffer (OK, this i could precompute with `try-completion' and then
>  insert as argument INITIAL-INPUT - but AFAIK this is deprecated?!).
>  
>  But most important is that the user has not to hit any key to see all
>  possible completions. How to do this with completing-read - or is there a
>  better way to do this?
>  
>  What i want is to (mis?)use the completion-feature of Emacs to offer the
>  user some choices which he can select either via mouse or via keyboard from
>  the minibuffer.
>  
>  Thanks a lot in advance!
>  Klaus

-- 
Klaus Berndl                    mailto: address@hidden
sd&m AG                         http://www.sdm.de
software design & management    
Carl-Wery-Str. 42, 81739 Muenchen, Germany
Tel +49 89 63812-392, Fax -220


reply via email to

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