emacs-devel
[Top][All Lists]
Advanced

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

RE: key binding question


From: Drew Adams
Subject: RE: key binding question
Date: Sat, 3 Nov 2007 09:34:20 -0700

> > How can I, in Lisp, bind command `bar' to `foo's key, but with
> > the Control and Meta modifiers added. So, for example, if
> > `foo' = [S-iso-lefftab], then the code would bind `bar' to
> > [C-M-S-iso-lefttab].
>
> You first have to define what "add control and meta modifiers" mean when
> applied not to a key but to a key-sequence.

Apply them only to the first key of the sequence (in my case).

> Then you might be able to use something like
>
>   (define-key map
>       (apply 'vector
>              (mapcar (lambda (k)
>                         (list 'meta 'control k)) foo))
>       'bar)

Thank you. This seems to do it:

(define-key map
    (apply 'vector
           (let ((k (elt foo 0)))
             (cons (if (listp k)
                       `(control meta ,@k)
                     `(control meta ,k))
                   (mapcar #'identity (substring foo 1)))))
    'bar)

(It seems that any extra `control' and `meta' don't matter, so I didn't
bother to remove them.)






reply via email to

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