From: Drew Adams <drew.adams@oracle.com>
To: Michael Heerdegen <michael_heerdegen@web.de>,
Tianxiang Xiong <tianxiang.xiong@gmail.com>
Cc: Emacs developers <emacs-devel@gnu.org>
Subject: RE: Have `define-key` return the keymap
Date: Sat, 13 May 2017 07:58:04 -0700 (PDT) [thread overview]
Message-ID: <9915c795-9efd-4cd8-aa0d-bc072eb340ee@default> (raw)
In-Reply-To: <87d1bd7xr2.fsf@drachen>
> > If `define-key` returned the keymap, calls to it could be chained together
> > in convenient ways, e.g.
> >
> > (thread-first (make-sparse-keymap)
> > (define-key (kbd "a") #'foo)
> > (define-key (kbd "b") #'bar))
>
> A different solution would be to define something analog to
> `thread-first' that substitutes always the first value as first argument
> instead of the subsequent return values (in this case, this is always
> the same object).
>
> A variant of this approach that works without such a new macro:
>
> (defun my-keybinder (map)
> (apply-partially #'define-key map))
>
> (let ((map (make-sparse-keymap)))
> (cl-flet ((define-key (my-keybinder map)))
> (define-key (kbd "a") #'foo)
> (define-key (kbd "b") #'bar)
> map))
I'm probably missing something, but (to me, so far) all of this
has the scent of a solution looking for a problem to solve.
next prev parent reply other threads:[~2017-05-13 14:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-13 8:19 Have `define-key` return the keymap Tianxiang Xiong
2017-05-13 8:32 ` Andreas Schwab
2017-05-13 9:11 ` Tianxiang Xiong
2017-05-13 12:21 ` Michael Heerdegen
2017-05-13 14:58 ` Drew Adams [this message]
2017-05-13 15:12 ` Kaushal Modi
2017-05-13 15:13 ` 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=9915c795-9efd-4cd8-aa0d-bc072eb340ee@default \
--to=drew.adams@oracle.com \
--cc=emacs-devel@gnu.org \
--cc=michael_heerdegen@web.de \
--cc=tianxiang.xiong@gmail.com \
/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.