unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Stefan Monnier" <monnier+gnu/emacs@RUM.cs.yale.edu>
Cc: "Stefan Monnier" <monnier+gnu/emacs@rum.cs.yale.edu>,
	emacs-devel@gnu.org
Subject: Re: Enhancements to "minor-mode-map-alist" functionality.
Date: Mon, 22 Apr 2002 05:28:42 -0400	[thread overview]
Message-ID: <200204220928.g3M9Sgq32304@rum.cs.yale.edu> (raw)
In-Reply-To: 5xy9fhj66p.fsf@kfs2.cua.dk

> "Stefan Monnier" <monnier+gnu/emacs@rum.cs.yale.edu> writes:
> 
> > > "Stefan Monnier" <monnier+gnu/emacs@rum.cs.yale.edu> writes:
> > > > I haven't heard any comment about my proposal to use `menu-item'
> > > > bindings with a :enable setting in order to get conditional bindings
> > > > (this doesn't currently work, but it should be pretty easy to make
> > > > it work).
> > > > Would it help you solve your problems ?
> > > 
> > > Considering that cua has approx 100 bindings in 7 keymaps,
> > > it seems like absolute overkill IMO to condition each of those
> > > 100 bindings individually instead of just the 7 keymaps which
> > > contain those bindings...
> > 
> > Is that 7*100 bindings or 7*14 bindings ?
> 
> It is 8 + 7 + 2 + 10 + 17 + 60 + 16 bindings...

So, more like 7*14.
How many of those bindings are in submaps (rather in the toplevel maps)
such that the :enable condition could be put on the prefix and thus shared ?

> > How much overlap ?
> None.

You mean that C-x is only bound in one of those 7 keymaps ?
But if there's no overlap, then the order of those maps relative
to each other is irrelevant.

> > How many different conditions would there be ?
> There are 7 different conditions.

If there's really no overlap and thus only 7 conditions, then the only
difference between my proposal and yours is that in my proposition
the condition is put on each binding inside the toplevel map rather
than being "outside the toplevel".

So the situation is very much like the use of :filter.  Actually
we could use :filter to get the :enable behavior without any change
to the C code at all.  I.e. if a binding was made like

	(define-key cua-foo-map key bind)

and assuming that the conditional corresponding to cua-foo-map is
cua-foo-predicate, the new code would simply do:

	(defun cua-foo-filter (b) (if (eval cua-foo-predicate) b))
	(define-key cua-mode-map key
	  '(menu-item "bla" bind :filter cua-foo-filter))

> > For the sake of describe-key, I think it's better to have fewer bindings
> > (with the dispatch done more often in the bound function rather
> > than in the :enable conditionals) so that the docstring can describe what
> > happens when.
> 
> I don't think you will see any difference whether this is done
> via conditions in the minor-mode-map-alist (or emulation-mode-map-alist),
> or by conditioning each command individually.

I was assuming that there would be overlap between the maps such that
C-x is bound in several of your maps, so that C-h k would point you
to a different function/docstring depending on the circumstance.
Whereas if the conditional is tested inside the C code, then C-h k
gets you to the function that can then conveniently describe the
difference circumstances and their effect.

Of course, if there's no overlap, there's indeed no difference.

> Also, I don't see why it is better to eval the various conditions 100 times
> rather than just 7 times?

I don't see why the condition should be evaluated more times with my
proposal than with yours.  Actually, in your proposal, 7 conditions
are being evaluated for each command (they're evaluated right at the
beginning, in order to know which keymaps to look up), whereas in
mine only between 1 and 7 conditions would be evaluated (if there's
no overlap between the 7 maps, only 1, but if the current key pressed
is present in all 7 of your maps, then 7).


	Stefan

  reply	other threads:[~2002-04-22  9:28 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-11 22:56 Enhancements to "minor-mode-map-alist" functionality Kim F. Storm
2002-04-11 22:43 ` Stefan Monnier
2002-04-12  9:31   ` Kim F. Storm
2002-04-12 13:20     ` Kim F. Storm
2002-04-12 18:46       ` Stefan Monnier
     [not found]         ` <5xofgoobzr.fsf@kfs2.cua.dk>
     [not found]           ` <200204122021.g3CKLh217680@rum.cs.yale.edu>
2002-04-14 22:32             ` Kim F. Storm
2002-04-16 20:18               ` Richard Stallman
2002-04-16 22:34                 ` Kim F. Storm
2002-04-18 18:46                   ` Richard Stallman
2002-04-18 23:07                     ` Kim F. Storm
2002-04-19 13:43                       ` Stefan Monnier
2002-04-19 15:36                         ` Kim F. Storm
2002-04-19 14:46                           ` Stefan Monnier
2002-04-21 17:46                             ` Kim F. Storm
2002-04-22  9:28                               ` Stefan Monnier [this message]
2002-04-22 15:15                                 ` Kim F. Storm
2002-04-19 18:42                       ` Richard Stallman
2002-04-19 22:05                         ` Kim F. Storm
2002-04-20 17:27                           ` Richard Stallman
2002-04-21 11:08                             ` Kim F. Storm
2002-04-22  7:47                               ` Richard Stallman
2002-04-22 13:53                                 ` Kim F. Storm
2002-04-22 22:36                               ` Richard Stallman
2002-04-23 10:58                                 ` Kim F. Storm
2002-04-22 22:36                               ` Richard Stallman
2002-04-23 11:02                                 ` Kim F. Storm
2002-04-24 17:55                                   ` Richard Stallman
2002-04-26 13:44                                     ` Kim F. Storm
2002-04-27 22:41                                       ` Richard Stallman
2002-04-29  9:17                                         ` Kai Großjohann
2002-04-30  5:18                                           ` Richard Stallman
2002-04-30 21:25                                             ` Kim F. Storm
2002-05-01  7:14                                               ` Richard Stallman
2002-05-01 17:37                                                 ` Kim F. Storm
2002-04-14 23:11         ` Kim F. Storm
2002-04-12 18:20     ` Stefan Monnier
2002-04-12 21:05       ` Kim F. Storm
2002-04-12 20:30         ` Stefan Monnier
2002-04-12 22:08           ` Kim F. Storm
2002-04-13 19:05     ` Richard Stallman
2002-04-13 19:05 ` Richard Stallman
2002-04-13 23:30   ` Kim F. Storm
2002-04-15 12:34     ` Stefan Monnier
2002-04-17 16:03       ` Richard Stallman
2002-04-15 21:54     ` Richard Stallman
2002-04-15 23:55       ` Kim F. Storm

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200204220928.g3M9Sgq32304@rum.cs.yale.edu \
    --to=monnier+gnu/emacs@rum.cs.yale.edu \
    --cc=emacs-devel@gnu.org \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).