From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Kaushal Modi Newsgroups: gmane.emacs.orgmode,gmane.emacs.devel Subject: Re: Key binding popup interface Date: Wed, 13 Dec 2017 15:38:43 +0000 Message-ID: References: <87r2s3ctxh.fsf@ericabrahamsen.net> <87d13m3jt2.fsf@gmx.us> <87efo2wf0s.fsf@ericabrahamsen.net> <87y3m8s7ym.fsf@gmx.us> <87fu8gwfbr.fsf@nicolasgoaziou.fr> <87k1xs2h0h.fsf@gmx.us> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="001a1142e206aebf5105603a9030" X-Trace: blaine.gmane.org 1513179567 12202 195.159.176.226 (13 Dec 2017 15:39:27 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 13 Dec 2017 15:39:27 +0000 (UTC) Cc: emacs-orgmode@gnu.org, emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Wed Dec 13 16:39:23 2017 Return-path: Envelope-to: geo-emacs-orgmode@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eP97y-0002uB-Tx for geo-emacs-orgmode@m.gmane.org; Wed, 13 Dec 2017 16:39:23 +0100 Original-Received: from localhost ([::1]:35981 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eP986-0007zR-3A for geo-emacs-orgmode@m.gmane.org; Wed, 13 Dec 2017 10:39:30 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38756) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eP97Z-0007zE-Te for emacs-orgmode@gnu.org; Wed, 13 Dec 2017 10:38:59 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eP97Y-0006XV-Bc for emacs-orgmode@gnu.org; Wed, 13 Dec 2017 10:38:57 -0500 Original-Received: from mail-yw0-x232.google.com ([2607:f8b0:4002:c05::232]:44011) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eP97Y-0006XN-4O; Wed, 13 Dec 2017 10:38:56 -0500 Original-Received: by mail-yw0-x232.google.com with SMTP id n25so980399ywh.10; Wed, 13 Dec 2017 07:38:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SqaGOvJW/rBeoGyDAFSCsXJd3j278GkBrc79X8eA7/8=; b=qoR5AAoDQ0dK/iRoA/89MKaDny1uN7vqB8eo+OSrZriMjadAjt2pMC8Kc7Yn+xrvBg rCJVpU39rxawkUSUs/22vuS5olmj10iPp75wKLqnRQXk/WjDU40iOavIL1UKbk8X5WdL Yv6LT4dh+mV8yeBZAUeF+UXjiqbMQ1bPGotv6j9DoakQ49xWIHOEEbF/jgRDyDCgxX1B bXvj5vtkSaquEXib5250fDhtg+Pnxn/ENoSqD5Wh8VjJkZNj00DVHye7oZ2HGtOvnJ2L G1TRPuvm+1ELbFaltluw7WoGrloUhxT/nWIoDhBGOCjBol8eed2KcWXrjt1JZPUBhLNs tVsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SqaGOvJW/rBeoGyDAFSCsXJd3j278GkBrc79X8eA7/8=; b=qIGKQBOBzUBDpaGjo+I+MXOfNFuFGLg1TddHgUVLlQ19vo3kn4+wpiJALKmtge2cKB OQdPAvSLiYInUpo8AwEV/MgUa1RrmdoZLcaqFthXOmEstO5EcPDQLZ88sJB/3EfnohMZ DaxezmAXySBpek9M3STqB/QapfR4LQdRz/Hi3wZc8V+QdVAbpjpZZl7khe2tdn49xCzk H9q3pFLZ4Qy2Jrgdp966y38acXRWM58BJxm+dOL3WbwPuJwK6wSBSB9B7A2sNC1+3zZ7 lt0bljGgA8lGw+/9JcqdcvKTpg3TYNyBwKyGZZhUDUZYE5ih4iXLQWC13y3uc+Ya+f6L SXWw== X-Gm-Message-State: AKGB3mJZudM7EB/ELIhI8R1H6LuhQpGuGvygEyh9Y2KetoIJP/1QbuDC BXrJ4rFcLnGm9epUasFWuPST5kOav+AJKti8YP8= X-Google-Smtp-Source: ACJfBovL+Zlv/IlOLAwGWtiX8Nqe07qh4pTqzWm17M5TzGes/PkFmEv4sqaP6z7mxIx/m+J6n1Zp9RVV1uyY9gKMqIo= X-Received: by 10.129.6.215 with SMTP id 206mr1874381ywg.353.1513179535291; Wed, 13 Dec 2017 07:38:55 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4002:c05::232 X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Original-Sender: "Emacs-orgmode" Xref: news.gmane.org gmane.emacs.orgmode:117486 gmane.emacs.devel:220999 Archived-At: --001a1142e206aebf5105603a9030 Content-Type: text/plain; charset="UTF-8" On Tue, Dec 12, 2017 at 4:49 PM Stefan Monnier wrote: > I tend to think of Hydra as "bindings that stick around" (to take the > wording on the first line of hydra.el), rather than "ways to show > available bindings of the current submap". So, yes, I think it does > something else (something more) Well, that's correct .. than what I understand you want. > Though I now think I did a very bad job at constructing that problem statement. But I know for sure that hydra.el fits the bill perfectly (I've been using it ever since Oleh released it). Integrating hydra into emacs with help package developers do these: - Create interfaces for transitional keymaps - The bindings could be sticky or not (can be configured in hydra) - Allow customizing the descriptions of the bindings (@JWiegley as you later suggest which-key, which-key does not allow that.. well it does.. but the user will need to tweak the description, etc.. I see which-end more as a tool only for the end-user. hydra can be used both by package developers and end users). - Pick and choose which bindings to "show" in that interface.. you don't have to show all. The package developer may choose to have duplicate bindings for some function in that keymap, but prefer to show only the preferred binding in the hydra popup (cannot do that in which-key.. it shows *everything*). > And, BTW, if I take a hydra like > > (defhydra hydra-zoom (global-map "") > "zoom" > ("g" text-scale-increase "in") > ("l" text-scale-decrease "out")) > > and I press `f6` I don't get any help in the echo area (nor in the "lv" > area). I only get that help after pressing `f6 g` or `f6 l`, so I need > some other mechanism to find those "initial" key bindings. > That's because you used Style 1 (as explained in this hydra Wiki: https://github.com/abo-abo/hydra/wiki/Binding-Styles). Use the Style 2 to take care of the issue you stated: (defhydra hydra-zoom () "zoom" ("g" text-scale-increase "in") ("l" text-scale-decrease "out")) (global-set-key (kbd "C-c") 'hydra-zoom/body) In Style 1, you allow the hydra to share the "keymap space" with other bindings not related to that hydra. In Style 2, the hydra takes over the whole "keymap space". In above Style 2 example, the "C-c" space is completely ruled by the hydra-zoom hydra. > So in this respect, I think it does something less than what > I understand you'd want. > No. It does everything that I need to do. But of course it has a lot of features, which might be suitable for different applications. See keys like :pre, :post and more described in https://github.com/abo-abo/hydra/wiki/internals. I can see something like this begin added to smerge.el if and when hydra.el gets merged to the core (See the use of :pre and :post): (defhydra hydra-smerge (:color pink :hint nil :pre (smerge-mode 1) ;; Disable `smerge-mode' when quitting hydra if ;; no merge conflicts remain. :post (smerge-auto-leave)) " ^Move^ ^Keep^ ^Diff^ ^Other^ ^^-----------^^-------------------^^---------------------^^------- _n_ext _b_ase _<_: upper/base _C_ombine _p_rev _u_pper _=_: upper/lower _r_esolve ^^ _l_ower _>_: base/lower _k_ill current ^^ _a_ll _R_efine ^^ _RET_: current _E_diff " ("n" smerge-next) ("p" smerge-prev) ("b" smerge-keep-base) ("u" smerge-keep-upper) ("l" smerge-keep-lower) ("a" smerge-keep-all) ("RET" smerge-keep-current) ("\C-m" smerge-keep-current) ("<" smerge-diff-base-upper) ("=" smerge-diff-upper-lower) (">" smerge-diff-base-lower) ("R" smerge-refine) ("E" smerge-ediff) ("C" smerge-combine-with-next) ("r" smerge-resolve) ("k" smerge-kill-current) ("q" nil "cancel" :color blue)) > > I quickly went though hydra.el.. isn't defhydra mainly what it is? What > > would you suggest splitting out of that library? > > I don't know enough about it to have a clear opinion on that. > OK. Thanks. -- Kaushal Modi --001a1142e206aebf5105603a9030 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Tue, Dec 12= , 2017 at 4:49 PM Stefan Monnier <monnier@iro.umontreal.ca> wrote:
I tend to think of Hydra as "bindings that stick around" (to take= the
wording on the first line of hydra.el), rather than "ways to show
available bindings of the current submap".=C2=A0 So, yes, I think it d= oes
something else (something more)

Well, that&= #39;s correct ..

than = what I understand you want.

Though I no= w think I did a very bad job at constructing that problem statement. But I = know for sure that hydra.el fits the bill perfectly (I've been using it= ever since Oleh released it).

Integrating hydra i= nto emacs with help package developers do these:
- Create int= erfaces for transitional keymaps
- The bindings could be sticky o= r not (can be configured in hydra)
- Allow customizing the descri= ptions of the bindings (@JWiegley as you later suggest which-key, which-key= does not allow that.. well it does.. but the user will need to tweak the d= escription, etc.. I see which-end more as a tool only for the end-user. hyd= ra can be used both by package developers and end users).
- Pick = and choose which bindings to "show" in that interface.. you don&#= 39;t have to show all. The package developer may choose to have duplicate b= indings for some function in that keymap, but prefer to show only the prefe= rred binding in the hydra popup (cannot do that in which-key.. it shows *ev= erything*).
=C2=A0
And, BTW, if I take a hydra like

=C2=A0 =C2=A0 (defhydra hydra-zoom (global-map "<f6>")
=C2=A0 =C2=A0 =C2=A0 "zoom"
=C2=A0 =C2=A0 =C2=A0 =C2=A0("g" text-scale-increase "in"= ;)
=C2=A0 =C2=A0 =C2=A0 =C2=A0("l" text-scale-decrease "out&quo= t;))

and I press `f6` I don't get any help in the echo area (nor in the &quo= t;lv"
area).=C2=A0 I only get that help after pressing `f6 g` or `f6 l`, so I nee= d
some other mechanism to find those "initial" key bindings.

That's because you used Style 1 (as expla= ined in this hydra Wiki: https://github.com/abo-abo/hydra/wiki/Binding-Styles). U= se the Style 2 to take care of the issue you stated:

(defhydra hydra-zoom ()
=C2=A0 "zoom"
=C2=A0 ("g&qu= ot; text-scale-increase "in")
=C2=A0 ("l" text-scale= -decrease "out"))

(global-set-key (kbd "C-c") &#= 39;hydra-zoom/body)

In Style 1, you allow the = hydra to share the "keymap space" with other bindings not related= to that hydra.

In Style 2, the hydra takes over t= he whole "keymap space". In above Style 2 example, the "C-c&= quot; space is completely ruled by the hydra-zoom hydra.
=C2= =A0
So in this respect, I think it does something less than what
I understand you'd want.

No. It doe= s everything that I need to do. But of course it has a lot of features, whi= ch might be suitable for different applications. See keys like :pre, :post = and more described in https://github.com/abo-abo/hydra/wiki/internals.

<= /div>
I can see something like this begin added to smerge.el if and whe= n hydra.el gets merged to the core (See the use of :pre and :post):

(defhydra hydra-smerge (:color pink
=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 :hint nil
=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 :pre (smerge-mode 1)
= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ;; Disable = `smerge-mode' when quitting hydra if
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ;; no merge conflicts remain.
=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 :post (smerge-aut= o-leave))
=C2=A0 "
^Move^=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ^K= eep^=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 ^Diff^=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ^Other^
^^-----------^^---= ----------------^^---------------------^^-------
_n_ext=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 _b_ase=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 _<_: upper/base=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 _C_ombine
_p_rev=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 _u_pper=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 _=3D_: upper/lower=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 _r_esolve
^^=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 _l_ower=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 _>_: base/lower=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 _k_ill current
^^=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 _a_ll=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 _R_efine
^^=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 _RET_: current=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 _E_diff
"
=C2=A0 ("n" smerge-next)
=C2=A0= ("p" smerge-prev)
=C2=A0 ("b" smerge-keep-base)
= =C2=A0 ("u" smerge-keep-upper)
=C2=A0 ("l" smerge-ke= ep-lower)
=C2=A0 ("a" smerge-keep-all)
=C2=A0 ("RET&qu= ot; smerge-keep-current)
=C2=A0 ("\C-m" smerge-keep-current)=C2=A0 ("<" smerge-diff-base-upper)
=C2=A0 ("=3D&quo= t; smerge-diff-upper-lower)
=C2=A0 (">" smerge-diff-base-lo= wer)
=C2=A0 ("R" smerge-refine)
=C2=A0 ("E" smerg= e-ediff)
=C2=A0 ("C" smerge-combine-with-next)
=C2=A0 (&quo= t;r" smerge-resolve)
=C2=A0 ("k" smerge-kill-current)
= =C2=A0 ("q" nil "cancel" :color blue))
<= br>

> I quickly went though hydra.el.. isn't defhydra mainly what it is?= What
> would you suggest splitting out of that library?

I don't know enough about it to have a clear opinion on that.

OK.

Thanks.
--

Kaushal Modi

--001a1142e206aebf5105603a9030--