GNU ELPA - frog-menu


Quickly pick items from ad hoc menus
frog-menu-0.2.10.el, 2019-Aug-19, 25.9 KiB
Home page
Browse ELPA's repository
CGit or Gitweb

To install this package, run in Emacs:

M-x package-install RET frog-menu RET

Full description

<a href=""><img alt="GNU ELPA" src=""/></a>
<a href=""><img alt="Travis CI" src=""/></a>

* Description

This package lets you quickly pick strings from ad hoc menus. Just like a frog
would catch a fly. The menu is built "on the fly" from a collection of
strings. It's presented to the user to choose one of them by pressing a single
key. One example where this kind of menu is useful are spelling correction


The user can specify a prompt and additional action keys as you can see in the
bottom of the menu. Usage in the terminal is also supported:


Inspired by [[][ace-popup-menu]].

* Example

To invoke the menu users can call =frog-menu-read=. How items are displayed
and choosen depends on =frog-menu-type=. For graphical displays the type
=avy-posframe= uses [[][avy]] and [[][posframe]]. In terminals the type =avy-side-window=
is used. The implemented handler functions can be used as reference if you
want to define your own =frog-menu-type=.

Here is an example how you would invoke a frog menu:

#+begin_src elisp
(frog-menu-read "Choose a string"
                '("a" "list" "of strings"))

It is also possible to define additional action keys (as shown in the
screenshot). Here is an example how you could use =frog-menu-read= to
implement a [[][flyspell-correct-interface]]:

#+begin_src elisp
(require 'flyspell-correct)

(defun frog-menu-flyspell-correct (candidates word)
  "Run `frog-menu-read' for the given CANDIDATES.

List of CANDIDATES is given by flyspell for the WORD.

Return selected word to use as a replacement or a tuple
of (command . word) to be used by `flyspell-do-correct'."
  (let* ((corrects (if flyspell-sort-corrections
                       (sort candidates 'string<)
         (actions `(("C-s" "Save word"         (save    . ,word))
                    ("C-a" "Accept (session)"  (session . ,word))
                    ("C-b" "Accept (buffer)"   (buffer  . ,word))
                    ("C-c" "Skip"              (skip    . ,word))))
         (prompt   (format "Dictionary: [%s]"  (or ispell-local-dictionary
         (res      (frog-menu-read prompt corrects actions)))
    (unless res
      (error "Quit"))

(setq flyspell-correct-interface #'frog-menu-flyspell-correct)

Afterwards calling =M-x flyspell-correct-wrapper= will prompt you with a

Old versions

frog-menu-0.2.9.el2019-Jun-2825.7 KiB
frog-menu-0.2.8.el2019-May-0125.6 KiB
frog-menu-0.2.7.el2019-Apr-3025.2 KiB
frog-menu-0.2.6.el2019-Apr-3023.2 KiB
frog-menu-0.2.5.el2019-Apr-2921.9 KiB
frog-menu-0.2.3.el2019-Apr-2322.6 KiB
frog-menu-0.2.2.el2019-Apr-0322.0 KiB
frog-menu-0.2.1.el2019-Mar-2522.0 KiB
frog-menu-0.2.el2019-Mar-2522.0 KiB
frog-menu-0.1.1.el2019-Mar-2422.0 KiB