Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

minibuffer input: word completion with custom dictionary

I am trying to accept user input for a command-line utility in emacs. I've got a handful of words that I can use in this command-line (something like the possible target list of a make invocation), and I want to be able to auto-complete words that I know about, allow user to input more than one entry in my dictionary, and also allow the user to write things not in my dictionary. Some library that allows word completion in minibuffer using a custom dictionary would be just the thing.

I do not require a full solution, but a few pointers on where to start looking would be much appreciated. Also, I'd rather avoid using intrusive libraries such as icicles or ido if at all possible - I don't want the users of this package to be limited in how they configure the rest of their setup.

My best solution so far is to use completing-read multiple times for each target until the user enters the empty string.

Solution

event_jr's answer below did the trick. The final code I've used looks like:

(require 'crm)
(let ((crm-separator " ")
      (crm-local-completion-map (copy-keymap crm-local-completion-map)))
  (define-key crm-local-completion-map " " 'self-insert-command)
  (completing-read-multiple "prompt: " '("foo" "foobar" "baz"))))
like image 739
vhallac Avatar asked May 15 '12 10:05

vhallac


1 Answers

How about this:

(completing-read-multiple ": " '("foo" "foo2" "foobar"))
like image 163
event_jr Avatar answered Sep 22 '22 02:09

event_jr