emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kaushal Modi <kaushal.modi@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-orgmode@gnu.org, emacs-devel@gnu.org
Subject: Re: Key binding popup interface
Date: Wed, 13 Dec 2017 15:38:43 +0000	[thread overview]
Message-ID: <CAFyQvY0SA=ztThJ21Q2zr+0uxqZgjd4peGAxUJeifSEjtbrzbA@mail.gmail.com> (raw)
In-Reply-To: <jwvbmj3r5bv.fsf-monnier+gmane.emacs.devel@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 4223 bytes --]

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".  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 "<f6>")
>       "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

[-- Attachment #2: Type: text/html, Size: 6504 bytes --]

  reply	other threads:[~2017-12-13 15:38 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-10  0:23 Poll: new keybinding for org-insert-structure-template? Eric Abrahamsen
2017-12-10 11:26 ` Rasmus
2017-12-10 19:37   ` Eric Abrahamsen
2017-12-12  7:48     ` Rasmus
2017-12-12  7:55       ` Nicolas Goaziou
2017-12-12 13:49         ` Rasmus
2017-12-12 14:02           ` Key binding popup interface (Was: Re: Poll: new keybinding for org-insert-structure-template on org mode list) Kaushal Modi
2017-12-12 18:45             ` Key binding popup interface Eric S Fraga
2017-12-12 18:56               ` Kaushal Modi
2017-12-12 19:53                 ` Alan E. Davis
2017-12-12 20:20             ` Eric Abrahamsen
2017-12-12 20:33               ` Kaushal Modi
2017-12-12 20:44                 ` Eric Abrahamsen
2017-12-12 20:56                   ` Kaushal Modi
2017-12-12 21:01             ` Stefan Monnier
2017-12-12 21:19               ` Kaushal Modi
2017-12-12 21:48                 ` Stefan Monnier
2017-12-13 15:38                   ` Kaushal Modi [this message]
2017-12-13 16:18                     ` Stefan Monnier
2017-12-12 23:51               ` Robert Weiner
2017-12-13 15:40                 ` Kaushal Modi
2017-12-13 16:25                   ` Robert Weiner
2017-12-13  6:52               ` John Wiegley
2017-12-13 15:43                 ` Kaushal Modi
2017-12-13  0:45           ` Poll: new keybinding for org-insert-structure-template? Eric Abrahamsen
2017-12-14  9:06             ` Rasmus
2017-12-14 21:19               ` Eric Abrahamsen
2017-12-15 11:22                 ` Rasmus
2017-12-15 12:59                   ` Kaushal Modi
2017-12-15 13:15                     ` Rasmus
2017-12-15 17:40                       ` Eric Abrahamsen
2017-12-18 18:23                         ` Eric Abrahamsen
2017-12-19 11:40                           ` Rasmus
2017-12-20 16:36                             ` Eric Abrahamsen
2017-12-20 16:48                               ` Eric Abrahamsen
2017-12-21  9:16                                 ` Rasmus

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.orgmode.org/

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

  git send-email \
    --in-reply-to='CAFyQvY0SA=ztThJ21Q2zr+0uxqZgjd4peGAxUJeifSEjtbrzbA@mail.gmail.com' \
    --to=kaushal.modi@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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/org-mode.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).