emacs-devel
[Top][All Lists]
Advanced

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

Re: completing-read a list of keywords


From: Daniele Nicolodi
Subject: Re: completing-read a list of keywords
Date: Wed, 15 Apr 2020 16:13:51 -0600
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.7.0

On 15-04-2020 13:32, Daniele Nicolodi wrote:
> On 15-04-2020 12:41, Joost Kremers wrote:
>>
>> On Wed, Apr 15 2020, Noam Postavsky wrote:
>>> On Wed, 15 Apr 2020 at 14:21, Daniele Nicolodi <address@hidden>
>>> wrote:
>>>
>>>> Thanks Noam! I didn't know about completing-read-multiple. It comes very
>>>> close to do what I want. However, I am unable to make it work for
>>>> elements separated by ", " as SPC is mapped to the complete action. Is
>>>> there a way to customize this behavior?
>>>
>>> (define-key crm-local-completion-map (kbd "SPC") #'self-insert-command)
>>
>> Or if you don't want to stomp on anyone's keybindings:
>>
>> ```
>> (let ((crm-local-must-match-map (make-composed-keymap '(keymap (32))
>> crm-local-must-match-map)))
>>  (completing-read-multiple ...)
>>  ...
>>  )
>> ```
> 
> Thanks!  Wouldn't it make sense to have a with-define-key macro to
> effectively do the same?

For whom may be interested, this macro may look like:

(defmacro with-define-key (keymap key def &rest body)
  (declare (indent 3) (debug t))
  `(let ((map (make-sparse-keymap)))
     (define-key map ,key ,def)
     (let ((,keymap (make-composed-keymap map ,keymap)))
       (progn ,@body))))

It requires a bit of contortions to get it accept a syntax equivalent to
define-key.

Cheers,
Dan



reply via email to

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