From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Psionic K Newsgroups: gmane.emacs.devel Subject: Re: Delegating user-reserved key binding space definition to users Date: Wed, 30 Nov 2022 00:23:02 -0600 Message-ID: References: <57b69c22e167d429d21bb969feb22887@webmail.orcon.net.nz> <877czikyfa.fsf@localhost> <87o7sthrwx.fsf@localhost> <83fse1nc9h.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000a3faea05eeaa23bd" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27260"; mail-complaints-to="usenet@ciao.gmane.io" Cc: monnier@iro.umontreal.ca, yantar92@posteo.net, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Nov 30 07:24:23 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p0GW6-0006sL-Qu for ged-emacs-devel@m.gmane-mx.org; Wed, 30 Nov 2022 07:24:23 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0GV9-0002Y1-Hs; Wed, 30 Nov 2022 01:23:23 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p0GV5-0002Xl-0t for emacs-devel@gnu.org; Wed, 30 Nov 2022 01:23:19 -0500 Original-Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p0GV1-0004Vc-Tc for emacs-devel@gnu.org; Wed, 30 Nov 2022 01:23:18 -0500 Original-Received: by mail-pf1-x42b.google.com with SMTP id 9so15916278pfx.11 for ; Tue, 29 Nov 2022 22:23:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=positron.solutions; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=0GbZIwuORNX3wde1jl9nBtlYSLQQgxZiU0DPc+7sMhw=; b=nMqrRqRZfiS7qGjoiC5eCXnZnciBSUf43lEYhsG07tN6czhoYPjug6qNI9c+kJO1Sy 85GSIpWQxotis6y7/BfczuvWSk293sR608+o0j2HOWW2AIJOV068Oh9mIjokcqz29fNM HsPdrPYYvr1ElP67MaRdeo+uhE0unqVH454UGZeYjQL5IXAY/nQ+mO1ocTL0mHTxhy+5 p9quXUeAHmsJUsGCUguQ/nLmvKo132wxwHvAlFQ+11zdX91CUdWQS5KUA0HqxNS0HktO HMZFTt5trA5lhZVFbsP2KMwa6FGAcjrgkqg/VKqm0KqBrbdwXiFaXQ6sEjiv7yof2+r8 lmDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0GbZIwuORNX3wde1jl9nBtlYSLQQgxZiU0DPc+7sMhw=; b=2Tzo7gXFIt5e+WI9g2A6IuVnIgAaxnVaFVee/tWM88flSud0ENsIhC+yAVXZ1XbVQA 5nC4TrhhuKZdL2YKAIpI8uMxSwPccVu7eeXZoiNm8aKPD/BYs1PFediH5NLswm50HtLt LgDKjv04m2YL2OFduzWtE7kyEUvxbLLB3yVr3nW3ZMpn6P/v8NJE4B88pQoav5ZIXvwh OvD/Et1HnwKZZqVGH//nI86gyfmyNTiE0otXAPsrnFHPgeFCk4UwpRws401T2AdCE+pW bjLQDGfIWckN/zr9xBB6g4bmJsGPfUHRe+Y+TTPpHvM4HfXA4pFCodaUQGsy3KfTgFd4 3cQA== X-Gm-Message-State: ANoB5pmcrwPMk2DS3e69T6VL4endYUcdpqxWe7oBMdV4PS4Cbz/7qk3G oxbcjKetVu17b3+D9J1MS8fD+0ODdu83B9rbJ+sUoA== X-Google-Smtp-Source: AA0mqf53vkiY2qo15zI5c8Ki8iyQx4Q0kNlP2PBzlYUN3emTPyPSeW3vcw5pmiwoPqiEvqu43Ux0Nvi62swo7yxaA9E= X-Received: by 2002:a63:580a:0:b0:477:12e3:6e1c with SMTP id m10-20020a63580a000000b0047712e36e1cmr37399938pgb.126.1669789393345; Tue, 29 Nov 2022 22:23:13 -0800 (PST) In-Reply-To: <83fse1nc9h.fsf@gnu.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=exec@positron.solutions; helo=mail-pf1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:300753 Archived-At: --000000000000a3faea05eeaa23bd Content-Type: text/plain; charset="UTF-8" > (local-set-key ?\M-n #'magit-section-next) This is a good edge case solution. It is not a good solution for moving or removing bindings coherently across all current and future modes. On Tue, Nov 29, 2022 at 7:03 AM Eli Zaretskii wrote: > > From: Psionic K > > Date: Mon, 28 Nov 2022 23:22:24 -0600 > > Cc: Ihor Radchenko , > > Emacs developers > > > > ;; The user will specify concept / abstract commands -> key sequences > > (setq-custom concept-sequences '((user-next ?\M-n) (user-prev ?\M-p))) > > ;; The package will specify concepts / abstract commands -> concrete > commands > > ;; So, something like a magit section mode intended to be derived from, > the package author writes: > > (setq-local concept-commands '((user-next #'magit-section-next) > (user-prev #'magit-section-prev))) > > ;; And then the package tells the implementation to consume the > declarations, which might occur after the > > mode hook to let the user intervene > > (emacs-function-setup-concept-keymap) > > > > `emacs-function-setup-concept-keymap' would be an implementation that > ties the user's declaration of > > sequence -> concept mappings together with the package's concept -> > command mappings. The result is > > that the local map should contain some command remap shadows > corresponding to what the user and the > > package declared. > > > > I neglected overloading in my example, but basically a user might be > okay with several concepts being able > > to map to one key and the package might be okay with mapping the same > command to one of several > > concepts. > > > > IMO these declarations one-to-many declarations should only be used with > two specific conventions: > > > > 1 Package authors specify a list of increasingly more generic concepts, > ending with `user-generic' which > > would just mean "any key that the user has bestowed upon packages by > default.". An example of more > > abstract definitions would be a declaration like (#'magit-section-next > (user-next user-navigation)). The > > implementation could try to map to user-next and if that's not > available, use an available sequence from > > user-navigation. > > 2 The user's convention for one-to-many mappings is different. They > might want to map a generic concept > > onto several key sequences in order, so they might declare something > like '(user-navigation (?\M-p ?\M-n > > ?\M-f ?\M-b)). If a package declares a user-next, user-prev, and two > more user-navigation commands, > > the implementation will give them all keymap elements. > > > > > I get the impression that your > > > SOME-INFO includes info for several commands. > > > > Yes. The reason commands should not handle this declaration is because > the implementation would have > > to discover the commands, and this would be fragile if the user starts > replacing commands or wants to > > specify commands that the package has no idea about. > > > > I'm also preoccupied with automating the user-driven re-mapping of > commands to key sequences when > > those commands express an extremely similar idea, such as "next". I see > this as a prerequisite for what I > > think you want. I don't think I agree with what I think you want, and > this could be messing with my > > interpretation, but it is a prerequisite still. > > > > We have lots of convention, lots of similarity in mode keymaps, but we > it's ad-hoc, and we just need to make > > it official so that the conventions are useful and user's can change one > declaration to move, for example, > > C-g. > > I think this discussion started from the wrong starting point, and that's > why the common understanding is difficult and misunderstandings abundant: > there's no reason to believe you and Stefan (and myself, and others who > read this) have the same goals and the same issues in mind. > > The basic problem here is that we don't have a clear commonly-shared idea > of > what we want to support with these features. > > My suggestion is to start from clarifying these requirements. A good > method > of understanding requirements is to describe typical use-cases and their > variations, as you probably know. With that in mind, would you or someone > else please describe such use-cases? Specifically: > > . what does the user specify? > . what should happen with key bindings to various commands as result of > the user specifications? > > For instance, with your example: > > > ;; The user will specify concept / abstract commands -> key sequences > > (setq-custom concept-sequences '((user-next ?\M-n) (user-prev ?\M-p))) > > ;; The package will specify concepts / abstract commands -> concrete > commands > > ;; So, something like a magit section mode intended to be derived from, > the package author writes: > > (setq-local concept-commands '((user-next #'magit-section-next) > (user-prev #'magit-section-prev))) > > ;; And then the package tells the implementation to consume the > declarations, which might occur after the > > mode hook to let the user intervene > > (emacs-function-setup-concept-keymap) > > I have no idea what will be the binding of magit-section-next. And, since > you only gave a single command as an example, I have no idea how is what > you > propose better than just saying > > (local-set-key ?\M-n #'magit-section-next) > > I understand what Stefan says about "letters" (probably meaning that 'n' > should be used in "next-FOO" commands and 'p' in "prev-FOO"), but I don't > understand what you are saying, because you didn't tell enough about your > eventual goal, in practical terms. > -- Psionic K Software Engineer *Positron Solutions * --000000000000a3faea05eeaa23bd Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
> =C2=A0 (local-set-key ?\M-n #'magit-sec= tion-next)

This is a good edge case solution.=C2=A0 It is not a good= solution for moving or removing bindings coherently across all current and= future modes.

On Tue, Nov 29, 2022 at 7:03 AM Eli Zaretskii <= ;eliz@gnu.org> wro= te:
> From: P= sionic K <psionik@positron.solutions>
> Date: Mon, 28 Nov 2022 23:22:24 -0600
> Cc: Ihor Radchenko <yantar92@posteo.net>,
>=C2=A0 Emacs developers <emacs-devel@gnu.org>
>
> ;; The user will specify concept / abstract commands -> key sequenc= es
> (setq-custom concept-sequences '((user-next ?\M-n) (user-prev ?\M-= p)))
> ;; The package will specify concepts / abstract commands -> concret= e commands
> ;; So, something like a magit section mode intended to be derived from= , the package author writes:
> (setq-local concept-commands '((user-next #'magit-section-next= ) (user-prev #'magit-section-prev)))
> ;; And then the package tells the implementation to consume the declar= ations, which might occur after the
> mode hook to let the user intervene
> (emacs-function-setup-concept-keymap)
>
> `emacs-function-setup-concept-keymap' would be an implementation t= hat ties the user's declaration of
> sequence -> concept mappings together with the package's concep= t -> command mappings.=C2=A0 The result is
> that the local map should contain some command remap shadows correspon= ding to what the user and the
> package declared.
>
> I neglected overloading in my example, but basically a user might be o= kay with several concepts being able
> to map to one key and the package might be okay with mapping the same = command to one of several
> concepts.
>
> IMO these declarations one-to-many declarations should only be used wi= th two specific conventions:=C2=A0
>
> 1 Package authors specify a list of increasingly more generic concepts= , ending with `user-generic' which
>=C2=A0 would just mean "any key that the user has bestowed upon pa= ckages by default.".=C2=A0 An example of more
>=C2=A0 abstract definitions would be a declaration like (#'magit-se= ction-next (user-next user-navigation)).=C2=A0 =C2=A0The
>=C2=A0 implementation could try to map to user-next and if that's n= ot available, use an available sequence from
>=C2=A0 user-navigation.
> 2 The user's convention for one-to-many mappings is different.=C2= =A0 They might want to map a generic concept
>=C2=A0 onto several key sequences in order, so they might declare somet= hing like '(user-navigation (?\M-p ?\M-n
>=C2=A0 ?\M-f ?\M-b)).=C2=A0 If a package declares a user-next, user-pre= v, and two more user-navigation commands,
>=C2=A0 the implementation will give them all keymap elements.
>
> > I get the impression that your
> > SOME-INFO includes info for several commands.
>
> Yes.=C2=A0 The reason commands should not handle this declaration is b= ecause the implementation would have
> to discover the commands, and this would be fragile if the user starts= replacing commands or wants to
> specify commands that the package has no idea about.
>
> I'm also preoccupied with automating the user-driven re-mapping of= commands to key sequences when
> those commands express an extremely similar idea, such as "next&q= uot;.=C2=A0 I see this as a prerequisite for what I
> think you want.=C2=A0 I don't think I agree with what I think you = want, and this could be messing with my
> interpretation, but it is a prerequisite still.
>
> We have lots of convention, lots of similarity in mode keymaps, but we= it's ad-hoc, and we just need to make
> it official so that the conventions are useful and user's can chan= ge one declaration to move, for example,
> C-g.

I think this discussion started from the wrong starting point, and that'= ;s
why the common understanding is difficult and misunderstandings abundant: there's no reason to believe you and Stefan (and myself, and others who=
read this) have the same goals and the same issues in mind.

The basic problem here is that we don't have a clear commonly-shared id= ea of
what we want to support with these features.

My suggestion is to start from clarifying these requirements.=C2=A0 A good = method
of understanding requirements is to describe typical use-cases and their variations, as you probably know.=C2=A0 With that in mind, would you or som= eone
else please describe such use-cases?=C2=A0 Specifically:

=C2=A0 . what does the user specify?
=C2=A0 . what should happen with key bindings to various commands as result= of
=C2=A0 =C2=A0 the user specifications?

For instance, with your example:

> ;; The user will specify concept / abstract commands -> key sequenc= es
> (setq-custom concept-sequences '((user-next ?\M-n) (user-prev ?\M-= p)))
> ;; The package will specify concepts / abstract commands -> concret= e commands
> ;; So, something like a magit section mode intended to be derived from= , the package author writes:
> (setq-local concept-commands '((user-next #'magit-section-next= ) (user-prev #'magit-section-prev)))
> ;; And then the package tells the implementation to consume the declar= ations, which might occur after the
> mode hook to let the user intervene
> (emacs-function-setup-concept-keymap)

I have no idea what will be the binding of magit-section-next.=C2=A0 And, s= ince
you only gave a single command as an example, I have no idea how is what yo= u
propose better than just saying

=C2=A0 (local-set-key ?\M-n #'magit-section-next)

I understand what Stefan says about "letters" (probably meaning t= hat 'n'
should be used in "next-FOO" commands and 'p' in "pr= ev-FOO"), but I don't
understand what you are saying, because you didn't tell enough about yo= ur
eventual goal, in practical terms.


--
=
--000000000000a3faea05eeaa23bd--