Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: abo-abo/hydra
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.11.0
Choose a base ref
...
head repository: abo-abo/hydra
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Feb 23, 2015

  1. Allow for a custom key format spec in docstrings

    * hydra.el (hydra-key-format-spec): New defcustom.
    (hydra--format): Use `hydra-key-format-spec'. Allow for 0-9 and / in key
    bindings.
    
    Here's an example of how to use a flexible format spec for each key:
    
    (let (hydra-key-format-spec)
      (defhydra hydra-zoom (global-map "<f2>")
        "
    zoom: _g_reater _ -5l_esser re_ 7c_enter zer_0_"
        ("g" text-scale-increase nil)
        ("l" text-scale-decrease nil)
        ("c" recenter-top-bottom nil)
        ("0" (text-scale-set 0) nil :exit t)))
    
    Fixes #50.
    abo-abo committed Feb 23, 2015
    Copy the full SHA
    c413b5f View commit details

Commits on Feb 24, 2015

  1. Simplify the hint part of each head

    * hydra.el (defhydra): All heads that don't have a hint, will get "" as
      hint. The behavior will remain the same.
    (hydra--head-property): Simplify, since plist is now always `cdddr'.
    (hydra--hint): Simplify, heads always have length at least 3. Simplify,
    third element is always a string or nil.
    abo-abo committed Feb 24, 2015
    Copy the full SHA
    f231dc0 View commit details
  2. Copy the full SHA
    3c06695 View commit details
  3. Improve handling of heads with duplicate cmd

    hydra.el (hydra--delete-duplicates): Modify :cmd-name property of
    duplicate head to to name of the head that it duplicates.
    Heads are considered duplicate if their CMD and COLOR is the same.
    The first of the duplicates gets a defun, the rest call it.
    
    * hydra.el (defhydra): Bring heads into a uniform notation. If a
      docstring is missing, set it to "". Set :cmd-name property to the
      head's name.
    
    * hydra-test.el: Add tests.
    
    Fixes #52.
    abo-abo committed Feb 24, 2015
    Copy the full SHA
    55682e7 View commit details
  4. Don't bind nil heads in outside keymaps

    * hydra.el (hydra-exit): New command to be used for nil heads.
    (hydra--delete-duplicates): Update for `hydra-exit'.
    (defhydra): Don't bind `hydra-exit' in outside keymaps.
    
    * hydra-test.el (hydra-blue-toggle): Update test.
    (hydra-amaranth-vi): Update test.
    
    Fixes #48.
    abo-abo committed Feb 24, 2015
    Copy the full SHA
    eb1e0fc View commit details
  5. Copy the full SHA
    e567bd6 View commit details
  6. Remove hydra-exit

    * hydra-test.el: Revert tests.
    
    * hydra.el (hydra-exit): Delete, since `hydra-exit' doesn't run :post.
    (hydra--delete-duplicates): Simplify.
    (defhydra): Simplify.
    
    Hydras with nil body will still not be bound in outside keymaps.
    
    Re #48
    Fixes #53
    abo-abo committed Feb 24, 2015
    Copy the full SHA
    26c3fee View commit details

Commits on Feb 25, 2015

  1. Copy the full SHA
    3040f45 View commit details
  2. hydra.el (hydra-key-format-spec): set default to "%s"

    * hydra-test.el (hydra-format): Update test.
    (hydra-format-with-sexp): Update test.
    abo-abo committed Feb 25, 2015
    Copy the full SHA
    6d6bbd4 View commit details

Commits on Feb 26, 2015

  1. hydra.el (hydra--format): Amend key regex

    Recognize the '=' key.
    ffevotte committed Feb 26, 2015
    Copy the full SHA
    9fc928b View commit details

Commits on Feb 27, 2015

  1. Add hydra-repeat': hydra-specific repeat'

    * hydra.el (hydra-repeat): New defun.
    (hydra-repeat--command): New defvar.
    (hydra-repeat--prefix-arg): New defvar.
    
    Example:
    
    (defhydra hydra-vi ()
      "vi"
      ("h" backward-char)
      ("j" next-line)
      ("k" previous-line)
      ("l" forward-char)
      ("." hydra-repeat))
    (global-set-key (kbd "C-v") 'hydra-vi/body)
    
    "C-v 4l.." will result in movement forward by 4 chars 3 times: first
    time from "4l", the other two from "..".
    
    Fixes #59.
    abo-abo committed Feb 27, 2015
    Copy the full SHA
    7de26d0 View commit details
  2. Add some features for generating tables

    * hydra.el (hydra--pad): New defun.
    (hydra--matrix): New defun.
    (hydra--cell): New defun.
    (hydra--vconcat): New defun.
    (hydra-cell-format): New defcustom.
    (hydra--table): New defun.
    (hydra-reset-radios): New defun.
    (defhydra): Allow docstring to be eval-able.
    (defhydradio): Don't define `.../reset-radios', instead define
    `.../names' that can be passed to `hydra-reset-radios'.
    (hydra-multipop): New defmacro.
    (hydra--radio): Update the order - the docstring is now a mandatory
    second arg, value is the optional third.
    
    * hydra-test.el (defhydradio): Update test.
    (hydra--pad): Add test.
    (hydra--matrix): Add test.
    (hydra--cell): Add test.
    (hydra--vconcat): Add test.
    (hydra--table): Add test.
    abo-abo committed Feb 27, 2015
    Copy the full SHA
    8e90037 View commit details
  3. Don't wrap `hydra-repeat'

    * hydra.el (hydra--delete-duplicates): Update.
    (hydra--vconcat): Trim trailing spaces.
    
    * hydra-test.el (hydra-red-error): Update test.
    (hydra--table): Update test.
    abo-abo committed Feb 27, 2015
    Copy the full SHA
    41f98bd View commit details

Commits on Feb 28, 2015

  1. hydra.el (hydra--format): Amend key regex

    Recognize the '{' and '}' keys.
    hura committed Feb 28, 2015
    Copy the full SHA
    764f4b6 View commit details

Commits on Mar 2, 2015

  1. Add :timeout option to hydra body

    * hydra.el (hydra--make-defun): Call `hydra-timeout' with :timeout if
      it's given.
    (hydra-timer): New var to hold the timer.
    (hydra-timeout): New function to call `hydra-keyboard-quit' with delay.
    (hydra-keyboard-quit): Cancel `hydra-timeout' timer.
    
    Re #34.
    abo-abo committed Mar 2, 2015
    Copy the full SHA
    9c68e0a View commit details

Commits on Mar 4, 2015

  1. Copy the full SHA
    e1e2e3e View commit details
  2. Allow for a %s(test) spec in docstring

    * hydra.el (hydra-set-transient-map): Avoid compiler warnings.
    (hydra--format): Add s? to regex.
    
    - %(test) will translate to (format "%S" (test))
    - %s(test) will translate to (format "%s" (test))
    
    The width specifiers should work for both, e.g. % -10(test) or %
    -10s(test).
    
    Example:
    
    (defhydra hydra-marked-items (dired-mode-map "")
      "
    Number of marked items: %(length (dired-get-marked-files))
    Directory size: %s(shell-command-to-string \"du -hs\")
    "
      ("m" dired-mark "mark"))
    
    Fixes #65.
    abo-abo committed Mar 4, 2015
    Copy the full SHA
    8dec3cd View commit details

Commits on Mar 5, 2015

  1. hydra-ox.el: Emulate org-mode export dispatch

    * hydra-ox.el (hydra-ox): New radiogroup.
    (hydra-ox-html): New hydra.
    (hydra-ox-latex): New hydra.
    (hydra-ox-text): New hydra.
    (hydra-ox): New hydra that includes the above three hydras.
    (org-mode-map): Add test binding.
    
    Re #66.
    abo-abo committed Mar 5, 2015
    8
    Copy the full SHA
    e342c33 View commit details

Commits on Mar 6, 2015

  1. Add option to specify :hint in body

    * hydra.el (hydra-plist-get-default): New defun, extended `plist-get'.
    (hydra--head-property): Use `hydra-plist-get-default'.
    (defhydra): The heads will inherit their hint from body :hint parameter.
    They can override it, of course.
    
    The most use you can get out of this parameter is to specify :hint nil
    for hydras with a format-style docstring.
    
    Example:
    
    (defhydra hydra-org-template (:color blue :hint nil)
      "
    _c_enter  _q_uote    _L_aTeX:
    _l_atex   _e_xample  _i_ndex:
    _a_scii   _v_erse    _I_NCLUDE:
    _s_rc     ^ ^        _H_TML:
    _h_tml    ^ ^        _A_SCII:
    "
      ("s" (hot-expand "<s"))
      ("e" (hot-expand "<e"))
      ("q" (hot-expand "<q"))
      ("v" (hot-expand "<v"))
      ("c" (hot-expand "<c"))
      ("l" (hot-expand "<l"))
      ("h" (hot-expand "<h"))
      ("a" (hot-expand "<a"))
      ("L" (hot-expand "<L"))
      ("i" (hot-expand "<i"))
      ("I" (hot-expand "<I"))
      ("H" (hot-expand "<H"))
      ("A" (hot-expand "<A"))
      ("<" self-insert-command "ins")
      ("o" nil "quit"))
    
    Some setup:
    
    (defun hot-expand (str)
      "Expand org template."
      (insert str)
      (org-try-structure-completion))
    (define-key org-mode-map "<"
      (lambda () (interactive)
         (if (looking-back "^")
             (hydra-org-template/body)
           (self-insert-command 1))))
    abo-abo committed Mar 6, 2015
    Copy the full SHA
    77c8e40 View commit details
  2. hydra-ox.el (hydra-ox): Update parameter list

    The `defhydradio' spec for each parameter was updated to:
    
        (name &optional doc value)
    
    This way, it's easy to define this type of hydra:
    
    (defhydradio hydra-tng ()
      (picard "_p_ Captain Jean Luc Picard:")
      (riker "_r_ Commander William Riker:")
      (data "_d_ Lieutenant Commander Data:")
      (worf "_w_ Worf:")
      (la-forge "_f_ Geordi La Forge:")
      (troi "_t_ Deanna Troi:")
      (dr-crusher "_c_ Doctor Beverly Crusher:")
      (phaser "_h_ Set phasers to " [stun kill]))
    
    (defhydra hydra-tng (:color pink)
      (concat (hydra--table hydra-tng/names 7 2 '("  % -30s %% -3`%s" "%s %%`%s"))
              "\n\n")
      ("p" (hydra-tng/picard) nil)
      ("r" (hydra-tng/riker) nil)
      ("d" (hydra-tng/data) nil)
      ("w" (hydra-tng/worf) nil)
      ("f" (hydra-tng/la-forge) nil)
      ("t" (hydra-tng/troi) nil)
      ("c" (hydra-tng/dr-crusher) nil)
      ("h" (hydra-tng/phaser) nil)
      ("b" beam-down "beam down" :exit t)
      ("o" (hydra-reset-radios hydra-tng/names) "reset")
      ("q" nil "cancel"))
    abo-abo committed Mar 6, 2015
    Copy the full SHA
    9623625 View commit details
  3. Update `golden-ratio-mode' work-around

    * lv.el (lv-window): Update.
    (lv-message): Update.
    
    Re #64.
    abo-abo committed Mar 6, 2015
    Copy the full SHA
    b840227 View commit details

Commits on Mar 9, 2015

  1. Copy the full SHA
    88c7dc4 View commit details

Commits on Mar 10, 2015

  1. "C-g" (`hydra-keyboard-quit' ) should run :post

    * hydra.el (hydra--handle-nonhead): Bind the plain `hydra-keyboard-quit'
      only when there's no :post.
    (defhydra): When there's :post, add another head for keyboard quit.
    
    * hydra-test.el (hydra-amaranth-vi): Update test.
    
    Fixes #67.
    abo-abo committed Mar 10, 2015
    Copy the full SHA
    a867927 View commit details

Commits on Mar 11, 2015

  1. hydra-examples.el: Fixup

    abo-abo committed Mar 11, 2015
    Copy the full SHA
    5c2f420 View commit details
  2. Makefile: Simplify

    * hydra-init.el: Add bare init.
    
    Now, typing:
    
        make compile
    
    in the hydra repository will start an "emacs -q" with all hydras from
    hydra-examples.el defined. Thus you can test that they work for you.
    The simplest one is "<f2> g", you can type that in any buffer.
    
    If you want to test with a different version of emacs, just type e.g.:
    
        make compile emacs=emacs24
    
    Re #70.
    abo-abo committed Mar 11, 2015
    Copy the full SHA
    bca2441 View commit details
  3. Copy the full SHA
    58075f5 View commit details
  4. README.md: update

    abo-abo committed Mar 11, 2015
    Copy the full SHA
    a071b60 View commit details
  5. Copy the full SHA
    622c798 View commit details
  6. Copy the full SHA
    7f4c835 View commit details
  7. README.md: describe docstring

    abo-abo committed Mar 11, 2015
    Copy the full SHA
    c9432e8 View commit details
  8. README.md: Add toc

    Re #71
    abo-abo committed Mar 11, 2015
    Copy the full SHA
    3f11348 View commit details
  9. Copy the full SHA
    556db52 View commit details
  10. README.md: Fix up typos

    abo-abo committed Mar 11, 2015
    Copy the full SHA
    bfe65da View commit details

Commits on Mar 12, 2015

  1. lv.el: Update truncation rules

    * lv.el (lv-window): Defer `truncate-lines' to `lv-message'. Set window
      hscroll to 0, just in case.
    (lv-message): If STR is one-line, set `truncate-lines' to nil, otherwise
    set it to t. Make `window-min-height' buffer-local and set it to the
    amount of newlines in STR.
    
    Re #40.
    abo-abo committed Mar 12, 2015
    Copy the full SHA
    3c4b3fd View commit details
  2. Bind [switch-frame] to `hydra-keyboard-quit'

    * hydra.el (hydra-base-map): Update.
    
    * hydra-test.el: Update.
    
    Fixes #73.
    abo-abo committed Mar 12, 2015
    Copy the full SHA
    9f9dcf9 View commit details

Commits on Mar 13, 2015

  1. Copy the full SHA
    5e8c7f2 View commit details

Commits on Mar 14, 2015

  1. Fix switch-frame handling.

    Calling only `hydra-keyboard-quit' on switch-frame event was
    effectively stopping the original frame switch. This change adds a
    call to the original handler after calling `hydra-keyboard-quit'.
    
    See #73
    
    * hydra.el: Add `hydra--handle-switch-frame'
    
    * hydra-test.el: Update
    
    Fixes #77
    jhonnyseven authored and abo-abo committed Mar 14, 2015
    Copy the full SHA
    543e97b View commit details

Commits on Mar 15, 2015

  1. Copy the full SHA
    3a77bf6 View commit details

Commits on Mar 17, 2015

  1. Add hydra-rectangle example

    * hydra-examples.el (hydra-toggle-simple): Rename from `hydra-toggle'.
    (hydra-rectangle): New hydra.
    abo-abo committed Mar 17, 2015
    Copy the full SHA
    97d6987 View commit details

Commits on Mar 20, 2015

  1. Don't bind `hydra-keyboard-quit' in foreign keymaps

    * hydra.el (defhydra): Update.
    
    Fixes #78.
    abo-abo committed Mar 20, 2015
    Copy the full SHA
    d44bf58 View commit details
  2. Call :post for :timeout

    * hydra.el (hydra--make-defun): When both :timeout and :post are given,
      if `hydra-timeout' runs out, it will call :post before
      `hydra-keyboard-quit'.
    (hydra-timeout): Update to call function if it's given. Always call
    `hydra-keyboard-quit' afterwards.
    
    For this example code:
    
    (global-set-key
     (kbd "C-c t")
     (defhydra test-hydra-b
         (:timeout 2.0 :post (message "test b quit"))
       "test b"
       ("x" (message "x"))
       ("y" (message "y"))
       ("q" nil "quit")))
    
    The message "test b quit" is issued:
    
    - on "q"
    
    - on "x" or "y", after one of them has started the timer, and the timer
      ran out. The timer is set to 2.0 seconds, and is reset each time "x"
      or "y" is pressed.
    
    - not on a plain "C-c t"
    
    Fixes #34
    abo-abo committed Mar 20, 2015
    Copy the full SHA
    eb181fd View commit details
  3. Copy the full SHA
    8e4b1fa View commit details

Commits on Mar 21, 2015

  1. hydra.el (hydra-keyboard-quit): Clean up the message area

    * hydra.el (hydra-keyboard-quit): Update.
    
    Fixes #80.
    abo-abo committed Mar 21, 2015
    Copy the full SHA
    30a073b View commit details
  2. Set pink/amaranth override recursively

    * hydra.el (hydra--modify-keymap): New defun.
    (hydra--handle-nonhead): Update.
    
    Fixes #81.
    abo-abo committed Mar 21, 2015
    Copy the full SHA
    498d78b View commit details

Commits on Mar 22, 2015

  1. Minor fixes

    * hydra.el (hydra--format): Save match data.
    (hydra--handle-nonhead): Don't quote lambda.
    (hydra--cycle-radio): Use cl-incf.
    abo-abo committed Mar 22, 2015
    Copy the full SHA
    7783f89 View commit details
  2. hydra.el: Turn on lexical-binding

    * hydra.el (hydra-set-transient-map): Fix warning.
    (hydra--head-color): Fix warning.
    (hydra--hint): Update signature.
    (hydra--format): Update.
    (hydra--matrix): Fix warning.
    (defhydra): Fix warning.
    (defhydradio): Fix warning.
    abo-abo committed Mar 22, 2015
    Copy the full SHA
    03771f4 View commit details

Commits on Mar 23, 2015

  1. Allow for the "%s`foo" spec.

    * hydra.el (hydra--format): Update. Treat variables in the same way as
      s-expressions.
    
    * hydra-test.el (hydra-format-2): Add test.
    (hydra-format-with-sexp-2): Add test.
    
    Fixes #85
    abo-abo committed Mar 23, 2015
    Copy the full SHA
    f6697f3 View commit details
  2. Fix blue/red heads with same cmd

    * hydra.el (hydra--make-defun): Update.
    (hydra--head-name): Change signature, since body is needed to determine
    the color. When the head will exit, add "-and-exit" to its name (except
    for the nil head and body).
    (defhydra): Update the call to `hydra--head-name', since it's not valid
    until the head has a hint.
    
    * hydra-test.el (hydra-blue-toggle): Update.
    (hydra-amaranth-vi): Update.
    (hydra-zoom-duplicate-1): Update.
    (hydra-zoom-duplicate-2): Update.
    
    Fixes #84
    abo-abo committed Mar 23, 2015
    Copy the full SHA
    c8c6b8c View commit details

Commits on Mar 24, 2015

  1. Fix argument to `replace-match'

    * hydra.el (hydra--format): Update.
    
    * hydra-test.el (hydra-format-3): Add test.
    
    Fixes #91
    abo-abo committed Mar 24, 2015
    Copy the full SHA
    71491b9 View commit details
  2. Mention the leading newline in `defhydra' docstring

    * hydra.el (hydra--handle-switch-frame): Update doc.
    (hydra--format): Update doc.
    (hydra-timeout): Update doc.
    (defhydra): Update doc.
    (defhydradio): Update doc.
    
    Fixes #88.
    abo-abo committed Mar 24, 2015
    Copy the full SHA
    87e4574 View commit details
Showing with 4,707 additions and 1,349 deletions.
  1. +6 −0 .dir-locals.el
  2. +6 −0 .elpaignore
  3. +2 −0 .github/FUNDING.yml
  4. +7 −5 .travis.yml
  5. +8 −5 Makefile
  6. +350 −221 README.md
  7. +69 −0 doc/Changelog.org
  8. +451 −0 doc/fdl-1.3.txt
  9. +674 −0 doc/gpl-3.0.txt
  10. +159 −40 hydra-examples.el
  11. +127 −0 hydra-ox.el
  12. +1,486 −559 hydra-test.el
  13. +1,242 −501 hydra.el
  14. +93 −18 lv.el
  15. +27 −0 targets/hydra-init.el
6 changes: 6 additions & 0 deletions .dir-locals.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")

((emacs-lisp-mode
(bug-reference-url-format . "https://github.com/abo-abo/hydra/issues/%s")
(indent-tabs-mode . nil)))
6 changes: 6 additions & 0 deletions .elpaignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
targets/
.travis.yml
.dir-locals.el
Makefile
README.md
hydra-test.el
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
liberapay: abo-abo
patreon: abo_abo
12 changes: 7 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
language: emacs-lisp
env:
matrix:
- EMACS=emacs24
- EVM_EMACS=emacs-24.5-travis
- EVM_EMACS=emacs-26.3-travis-linux-xenial
- EVM_EMACS=emacs-git-snapshot-travis-linux-xenial

before_install:
- sudo add-apt-repository -y ppa:cassou/emacs
- sudo apt-get update -qq
- sudo apt-get install -qq $EMACS
- git clone https://github.com/rejeep/evm.git $HOME/.evm
- export PATH=$HOME/.evm/bin:$PATH
- evm config path /tmp
- evm install $EVM_EMACS --use --skip

script:
- make test
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
EMACS = emacs
# EMACS = emacs-24.3
emacs ?= emacs

LOAD = -l lv.el -l hydra.el -l hydra-test.el

@@ -8,11 +7,15 @@ LOAD = -l lv.el -l hydra.el -l hydra-test.el
all: test

test:
$(EMACS) -batch $(LOAD) -f ert-run-tests-batch-and-exit
@echo "Using $(shell which $(emacs))..."
$(emacs) -batch $(LOAD) -f ert-run-tests-batch-and-exit

compile:
$(EMACS) -q $(LOAD) -l init.el --eval "(progn (mapc #'byte-compile-file '(\"hydra.el\" \"init.el\")) (switch-to-buffer \"*Compile-Log*\") (ert t))"
run:
$(emacs) -q $(LOAD) -l targets/hydra-init.el
make clean

compile:
$(emacs) -batch $(LOAD) -l targets/hydra-init.el

clean:
rm -f *.elc
571 changes: 350 additions & 221 deletions README.md

Large diffs are not rendered by default.

69 changes: 69 additions & 0 deletions doc/Changelog.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
* 0.15.0
** New Features

*** defhydra

**** New :base-map option in body plist
In case your hydra conflicts with el:hydra-base-map, you can now override it.

Example:
#+begin_src elisp
(defhydra hydra-numbers (:base-map (make-sparse-keymap))
"test"
("0" (message "zero"))
("1" (message "one")))
#+end_src
See [[https://github.com/abo-abo/hydra/issues/285][#285]].

**** Make no docstring equivalent to :hint nil
Example:
#+begin_src elisp
(defhydra hydra-clock (:color blue)
("q" nil "quit" :column "Clock")
("c" org-clock-cancel "cancel" :color pink :column "Do")
("d" org-clock-display "display")
("e" org-clock-modify-effort-estimate "effort")
("i" org-clock-in "in")
("j" org-clock-goto "jump")
("o" org-clock-out "out")
("r" org-clock-report "report"))
#+end_src
See [[https://github.com/abo-abo/hydra/issues/291][#291]].

**** Declare /params and /docstring
See [[https://github.com/abo-abo/hydra/issues/185][#185]].

**** Sexp hints are now supported for :columns
Example
#+begin_src elisp
(defhydra hydra-test ()
"Test"
("j" next-line (format-time-string "%H:%M:%S" (current-time)) :column "One")
("k" previous-line (format-time-string "%H:%M:%S" (current-time)))
("l" backward-char "back" :column "Two"))
#+end_src
See [[https://github.com/abo-abo/hydra/issues/311][#311]].


*** defhydra+
New macro. Allows to add heads to an existing hydra.

Example:
#+begin_src elisp
(defhydra hydra-extendable ()
"extendable"
("j" next-line "down"))

(defhydra+ hydra-extendable ()
("k" previous-line "up"))
#+end_src
See [[https://github.com/abo-abo/hydra/issues/185][#185]].

*** el:hydra-hint-display-type
Customize what to use to display the hint:
- el:message
- el:lv-message
- posframe

el:hydra-lv is now obsolete.
See [[https://github.com/abo-abo/hydra/issues/317][#317]].
451 changes: 451 additions & 0 deletions doc/fdl-1.3.txt

Large diffs are not rendered by default.

674 changes: 674 additions & 0 deletions doc/gpl-3.0.txt

Large diffs are not rendered by default.

199 changes: 159 additions & 40 deletions hydra-examples.el
Original file line number Diff line number Diff line change
@@ -85,9 +85,10 @@

;;** Example 4: toggle rarely used modes
(when (bound-and-true-p hydra-examples-verbatim)
(defvar whitespace-mode nil)
(global-set-key
(kbd "C-c C-v")
(defhydra hydra-toggle (:color blue)
(defhydra hydra-toggle-simple (:color blue)
"toggle"
("a" abbrev-mode "abbrev")
("d" toggle-debug-on-error "debug")
@@ -96,7 +97,7 @@
("w" whitespace-mode "whitespace")
("q" nil "cancel"))))

;; Note that in this case, `defhydra' returns the `hydra-toggle/body'
;; Note that in this case, `defhydra' returns the `hydra-toggle-simple/body'
;; symbol, which is then passed to `global-set-key'.
;;
;; Another new thing is that both the keymap and the body prefix are
@@ -137,7 +138,8 @@
("e" move-end-of-line "end")
("d" delete-region "del" :color blue)
("y" kill-ring-save "yank" :color blue)
("q" nil "quit"))))
("q" nil "quit")))
(hydra-set-property 'hydra-vi :verbosity 1))

;; This example introduces :color amaranth. It's similar to red,
;; except while you can quit red with any binding which isn't a Hydra
@@ -160,73 +162,78 @@
;; This example will bind "C-x `" in `global-map', but it will not
;; bind "C-x j" and "C-x k".
;; You can still "C-x `jjk" though.

;;** Example 7: toggle with Ruby-style docstring
(when (bound-and-true-p hydra-examples-verbatim)
(defhydra hydra-toggle (:color pink)
"
(defvar whitespace-mode nil)
(defhydra hydra-toggle (:color pink)
"
_a_ abbrev-mode: %`abbrev-mode
_d_ debug-on-error: %`debug-on-error
_f_ auto-fill-mode: %`auto-fill-function
_g_ golden-ratio-mode: %`golden-ratio-mode
_t_ truncate-lines: %`truncate-lines
_w_ whitespace-mode: %`whitespace-mode
"
("a" abbrev-mode nil)
("d" toggle-debug-on-error nil)
("f" auto-fill-mode nil)
("g" golden-ratio-mode nil)
("t" toggle-truncate-lines nil)
("w" whitespace-mode nil)
("q" nil "quit"))
(global-set-key (kbd "C-c C-v") 'hydra-toggle/body))
("a" abbrev-mode nil)
("d" toggle-debug-on-error nil)
("f" auto-fill-mode nil)
("t" toggle-truncate-lines nil)
("w" whitespace-mode nil)
("q" nil "quit"))
;; Recommended binding:
;; (global-set-key (kbd "C-c C-v") 'hydra-toggle/body)

;; Here, using e.g. "_a_" translates to "a" with proper face.
;; More interestingly:
;;
;; "foobar %`abbrev-mode" means roughly (format "foobar %S" abbrev-mode)
;;
;; This means that you actually see the state of the mode that you're changing.

;;** Example 8: the whole menu for `Buffer-menu-mode'
(defhydra hydra-buffer-menu (:color pink)
(defhydra hydra-buffer-menu (:color pink
:hint nil)
"
Mark Unmark Actions Search
------------------------------------------------------------------------- (__)
^Mark^ ^Unmark^ ^Actions^ ^Search
^^^^^^^^----------------------------------------------------------------- (__)
_m_: mark _u_: unmark _x_: execute _R_: re-isearch (oo)
_s_: save _U_: unmark up _b_: bury _I_: isearch /------\\/
_d_: delete _g_: refresh _O_: multi-occur / | ||
_D_: delete up _T_: files only: % -28`Buffer-menu-files-only * /\\---/\\
_~_: modified ~~ ~~
_d_: delete ^ ^ _g_: refresh _O_: multi-occur / | ||
_D_: delete up ^ ^ _T_: files only: % -28`Buffer-menu-files-only^^ * /\\---/\\
_~_: modified ^ ^ ^ ^ ^^ ~~ ~~
"
("m" Buffer-menu-mark nil)
("u" Buffer-menu-unmark nil)
("U" Buffer-menu-backup-unmark nil)
("d" Buffer-menu-delete nil)
("D" Buffer-menu-delete-backwards nil)
("s" Buffer-menu-save nil)
("~" Buffer-menu-not-modified nil)
("x" Buffer-menu-execute nil)
("b" Buffer-menu-bury nil)
("g" revert-buffer nil)
("T" Buffer-menu-toggle-files-only nil)
("O" Buffer-menu-multi-occur nil :color blue)
("I" Buffer-menu-isearch-buffers nil :color blue)
("R" Buffer-menu-isearch-buffers-regexp nil :color blue)
("m" Buffer-menu-mark)
("u" Buffer-menu-unmark)
("U" Buffer-menu-backup-unmark)
("d" Buffer-menu-delete)
("D" Buffer-menu-delete-backwards)
("s" Buffer-menu-save)
("~" Buffer-menu-not-modified)
("x" Buffer-menu-execute)
("b" Buffer-menu-bury)
("g" revert-buffer)
("T" Buffer-menu-toggle-files-only)
("O" Buffer-menu-multi-occur :color blue)
("I" Buffer-menu-isearch-buffers :color blue)
("R" Buffer-menu-isearch-buffers-regexp :color blue)
("c" nil "cancel")
("v" Buffer-menu-select "select" :color blue)
("o" Buffer-menu-other-window "other-window" :color blue)
("q" quit-window "quit" :color blue))
;; Recommended binding:
;; (define-key Buffer-menu-mode-map "." 'hydra-buffer-menu/body)

;;** Example 9: s-expressions in the docstring
;; You can inline s-expresssions into the docstring like this:
(defvar dired-mode-map)
(declare-function dired-mark "dired")
(when (bound-and-true-p hydra-examples-verbatim)
(eval-after-load 'dired
(defhydra hydra-marked-items (dired-mode-map "")
"
(require 'dired)
(defhydra hydra-marked-items (dired-mode-map "")
"
Number of marked items: %(length (dired-get-marked-files))
"
("m" dired-mark "mark"))))
("m" dired-mark "mark")))

;; This results in the following dynamic docstring:
;;
@@ -235,7 +242,105 @@ Number of marked items: %(length (dired-get-marked-files))
;;
;; You can use `format'-style width specs, e.g. % 10(length nil).

;;* Windmove helpers
;;** Example 10: apropos family
(defhydra hydra-apropos (:color blue
:hint nil)
"
_a_propos _c_ommand
_d_ocumentation _l_ibrary
_v_ariable _u_ser-option
^ ^ valu_e_"
("a" apropos)
("d" apropos-documentation)
("v" apropos-variable)
("c" apropos-command)
("l" apropos-library)
("u" apropos-user-option)
("e" apropos-value))
;; Recommended binding:
;; (global-set-key (kbd "C-c h") 'hydra-apropos/body)

;;** Example 11: rectangle-mark-mode
(require 'rect)
(defhydra hydra-rectangle (:body-pre (rectangle-mark-mode 1)
:color pink
:post (deactivate-mark))
"
^_k_^ _d_elete _s_tring
_h_ _l_ _o_k _y_ank
^_j_^ _n_ew-copy _r_eset
^^^^ _e_xchange _u_ndo
^^^^ ^ ^ _x_kill
"
("h" rectangle-backward-char nil)
("l" rectangle-forward-char nil)
("k" rectangle-previous-line nil)
("j" rectangle-next-line nil)
("e" hydra-ex-point-mark nil)
("n" copy-rectangle-as-kill nil)
("d" delete-rectangle nil)
("r" (if (region-active-p)
(deactivate-mark)
(rectangle-mark-mode 1)) nil)
("y" yank-rectangle nil)
("u" undo nil)
("s" string-rectangle nil)
("x" kill-rectangle nil)
("o" nil nil))

;; Recommended binding:
;; (global-set-key (kbd "C-x SPC") 'hydra-rectangle/body)

;;** Example 12: org-agenda-view
(defun org-agenda-cts ()
(and (eq major-mode 'org-agenda-mode)
(let ((args (get-text-property
(min (1- (point-max)) (point))
'org-last-args)))
(nth 2 args))))

(defhydra hydra-org-agenda-view (:hint none)
"
_d_: ?d? day _g_: time grid=?g? _a_: arch-trees
_w_: ?w? week _[_: inactive _A_: arch-files
_t_: ?t? fortnight _f_: follow=?f? _r_: clock report=?r?
_m_: ?m? month _e_: entry text=?e? _D_: include diary=?D?
_y_: ?y? year _q_: quit _L__l__c_: log = ?l?"
("SPC" org-agenda-reset-view)
("d" org-agenda-day-view (if (eq 'day (org-agenda-cts)) "[x]" "[ ]"))
("w" org-agenda-week-view (if (eq 'week (org-agenda-cts)) "[x]" "[ ]"))
("t" org-agenda-fortnight-view (if (eq 'fortnight (org-agenda-cts)) "[x]" "[ ]"))
("m" org-agenda-month-view (if (eq 'month (org-agenda-cts)) "[x]" "[ ]"))
("y" org-agenda-year-view (if (eq 'year (org-agenda-cts)) "[x]" "[ ]"))
("l" org-agenda-log-mode (format "% -3S" org-agenda-show-log))
("L" (org-agenda-log-mode '(4)))
("c" (org-agenda-log-mode 'clockcheck))
("f" org-agenda-follow-mode (format "% -3S" org-agenda-follow-mode))
("a" org-agenda-archives-mode)
("A" (org-agenda-archives-mode 'files))
("r" org-agenda-clockreport-mode (format "% -3S" org-agenda-clockreport-mode))
("e" org-agenda-entry-text-mode (format "% -3S" org-agenda-entry-text-mode))
("g" org-agenda-toggle-time-grid (format "% -3S" org-agenda-use-time-grid))
("D" org-agenda-toggle-diary (format "% -3S" org-agenda-include-diary))
("!" org-agenda-toggle-deadlines)
("[" (let ((org-agenda-include-inactive-timestamps t))
(org-agenda-check-type t 'timeline 'agenda)
(org-agenda-redo)
(message "Display now includes inactive timestamps as well")))
("q" (message "Abort") :exit t)
("v" nil))

;; Recommended binding:
;; (define-key org-agenda-mode-map "v" 'hydra-org-agenda-view/body)

;;** Example 13: automatic columns
(defhydra hydra-movement ()
("j" next-line "down" :column "Vertical")
("k" previous-line "up")
("l" forward-char "forward" :column "Horizontal")
("h" backward-char "back"))

;;* Helpers
(require 'windmove)

(defun hydra-move-splitter-left (arg)
@@ -270,5 +375,19 @@ Number of marked items: %(length (dired-get-marked-files))
(shrink-window arg)
(enlarge-window arg)))

(defvar rectangle-mark-mode)
(defun hydra-ex-point-mark ()
"Exchange point and mark."
(interactive)
(if rectangle-mark-mode
(rectangle-exchange-point-and-mark)
(let ((mk (mark)))
(rectangle-mark-mode 1)
(goto-char mk))))

(provide 'hydra-examples)

;; Local Variables:
;; no-byte-compile: t
;; End:
;;; hydra-examples.el ends here
127 changes: 127 additions & 0 deletions hydra-ox.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
;;; hydra-ox.el --- Org mode export widget implemented in Hydra

;; Copyright (C) 2015 Free Software Foundation, Inc.

;; Author: Oleh Krehel

;; This file is part of GNU Emacs.

;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.

;;; Commentary:
;;
;; This shows how a complex dispatch menu can be built with Hydra.

;;; Code:

(require 'hydra)
(require 'org)
(declare-function org-html-export-as-html 'ox-html)
(declare-function org-html-export-to-html 'ox-html)
(declare-function org-latex-export-as-latex 'ox-latex)
(declare-function org-latex-export-to-latex 'ox-latex)
(declare-function org-latex-export-to-pdf 'ox-latex)
(declare-function org-ascii-export-as-ascii 'ox-ascii)
(declare-function org-ascii-export-to-ascii 'ox-ascii)

(defhydradio hydra-ox ()
(body-only "Export only the body.")
(export-scope "Export scope." [buffer subtree])
(async-export "When non-nil, export async.")
(visible-only "When non-nil, export visible only")
(force-publishing "Toggle force publishing"))

(defhydra hydra-ox-html (:color blue)
"ox-html"
("H" (org-html-export-as-html
hydra-ox/async-export
(eq hydra-ox/export-scope 'subtree)
hydra-ox/visible-only
hydra-ox/body-only)
"As HTML buffer")
("h" (org-html-export-to-html
hydra-ox/async-export
(eq hydra-ox/export-scope 'subtree)
hydra-ox/visible-only
hydra-ox/body-only) "As HTML file")
("o" (org-open-file
(org-html-export-to-html
hydra-ox/async-export
(eq hydra-ox/export-scope 'subtree)
hydra-ox/visible-only
hydra-ox/body-only)) "As HTML file and open")
("b" hydra-ox/body "back")
("q" nil "quit"))

(defhydra hydra-ox-latex (:color blue)
"ox-latex"
("L" org-latex-export-as-latex "As LaTeX buffer")
("l" org-latex-export-to-latex "As LaTeX file")
("p" org-latex-export-to-pdf "As PDF file")
("o" (org-open-file (org-latex-export-to-pdf)) "As PDF file and open")
("b" hydra-ox/body "back")
("q" nil "quit"))

(defhydra hydra-ox-text (:color blue)
"ox-text"
("A" (org-ascii-export-as-ascii
nil nil nil nil
'(:ascii-charset ascii))
"As ASCII buffer")

("a" (org-ascii-export-to-ascii
nil nil nil nil
'(:ascii-charset ascii))
"As ASCII file")
("L" (org-ascii-export-as-ascii
nil nil nil nil
'(:ascii-charset latin1))
"As Latin1 buffer")
("l" (org-ascii-export-to-ascii
nil nil nil nil
'(:ascii-charset latin1))
"As Latin1 file")
("U" (org-ascii-export-as-ascii
nil nil nil nil
'(:ascii-charset utf-8))
"As UTF-8 buffer")
("u" (org-ascii-export-to-ascii
nil nil nil nil
'(:ascii-charset utf-8))
"As UTF-8 file")
("b" hydra-ox/body "back")
("q" nil "quit"))

(defhydra hydra-ox ()
"
_C-b_ Body only: % -15`hydra-ox/body-only^^^ _C-v_ Visible only: %`hydra-ox/visible-only
_C-s_ Export scope: % -15`hydra-ox/export-scope _C-f_ Force publishing: %`hydra-ox/force-publishing
_C-a_ Async export: %`hydra-ox/async-export
"
("C-b" (hydra-ox/body-only) nil)
("C-v" (hydra-ox/visible-only) nil)
("C-s" (hydra-ox/export-scope) nil)
("C-f" (hydra-ox/force-publishing) nil)
("C-a" (hydra-ox/async-export) nil)
("h" hydra-ox-html/body "Export to HTML" :exit t)
("l" hydra-ox-latex/body "Export to LaTeX" :exit t)
("t" hydra-ox-text/body "Export to Plain Text" :exit t)
("q" nil "quit"))

(define-key org-mode-map (kbd "C-c C-,") 'hydra-ox/body)

(provide 'hydra-ox)

;;; hydra-ox.el ends here
2,045 changes: 1,486 additions & 559 deletions hydra-test.el

Large diffs are not rendered by default.

1,743 changes: 1,242 additions & 501 deletions hydra.el

Large diffs are not rendered by default.

111 changes: 93 additions & 18 deletions lv.el
Original file line number Diff line number Diff line change
@@ -33,9 +33,41 @@

;;; Code:

(require 'cl-lib)

(defgroup lv nil
"The other echo area."
:group 'minibuffer
:group 'hydra)

(defcustom lv-use-separator nil
"Whether to draw a line between the LV window and the Echo Area."
:group 'lv
:type 'boolean)

(defcustom lv-use-padding nil
"Whether to use horizontal padding in the LV window."
:group 'lv
:type 'boolean)

(defface lv-separator
'((((class color) (background light)) :background "grey80")
(((class color) (background dark)) :background "grey30"))
"Face used to draw line between the lv window and the echo area.
This is only used if option `lv-use-separator' is non-nil.
Only the background color is significant."
:group 'lv)

(defvar lv-wnd nil
"Holds the current LV window.")

(defvar display-line-numbers)
(defvar display-fill-column-indicator)
(defvar tab-line-format)

(defvar lv-window-hook nil
"Hook to run by `lv-window' when a new window is created.")

(defun lv-window ()
"Ensure that LV window is live and return it."
(if (window-live-p lv-wnd)
@@ -44,29 +76,72 @@
buf)
(prog1 (setq lv-wnd
(select-window
(split-window
(frame-root-window) -1 'below)))
(if (setq buf (get-buffer "*LV*"))
(switch-to-buffer buf)
(switch-to-buffer "*LV*")
(setq truncate-lines nil)
(let ((ignore-window-parameters t))
(split-window
(frame-root-window) -1 'below))
'norecord))
(if (setq buf (get-buffer " *LV*"))
(switch-to-buffer buf 'norecord)
(switch-to-buffer " *LV*" 'norecord)
(fundamental-mode)
(set-window-hscroll lv-wnd 0)
(setq window-size-fixed t)
(setq mode-line-format nil)
(setq header-line-format nil)
(setq tab-line-format nil)
(setq cursor-type nil)
(set-window-dedicated-p lv-wnd t))
(select-window ori)))))
(setq display-line-numbers nil)
(setq display-fill-column-indicator nil)
(set-window-dedicated-p lv-wnd t)
(set-window-parameter lv-wnd 'no-other-window t)
(run-hooks 'lv-window-hook))
(select-window ori 'norecord)))))

(defvar golden-ratio-mode)

(defvar lv-force-update nil
"When non-nil, `lv-message' will refresh even for the same string.")

(defun lv--pad-to-center (str width)
"Pad STR with spaces on the left to be centered to WIDTH."
(let* ((strs (split-string str "\n"))
(padding (make-string
(/ (- width (length (car strs))) 2)
?\ )))
(mapconcat (lambda (s) (concat padding s)) strs "\n")))

(defun lv-message (format-string &rest args)
"Set LV window contents to (`format' FORMAT-STRING ARGS)."
(let ((ori (selected-window))
(str (apply #'format format-string args))
deactivate-mark)
(select-window (lv-window))
(unless (string= (buffer-string) str)
(delete-region (point-min) (point-max))
(insert str)
(fit-window-to-buffer nil nil 1))
(goto-char (point-min))
(select-window ori)))
(let* ((str (apply #'format format-string args))
(n-lines (cl-count ?\n str))
deactivate-mark
golden-ratio-mode)
(with-selected-window (lv-window)
(when lv-use-padding
(setq str (lv--pad-to-center str (window-width))))
(unless (and (string= (buffer-string) str)
(null lv-force-update))
(delete-region (point-min) (point-max))
(insert str)
(when (and (window-system) lv-use-separator)
(unless (looking-back "\n" nil)
(insert "\n"))
(insert
(propertize "__" 'face 'lv-separator 'display '(space :height (1)))
(propertize "\n" 'face 'lv-separator 'line-height t)))
(set (make-local-variable 'window-min-height) n-lines)
(setq truncate-lines (> n-lines 1))
(let ((window-resize-pixelwise t)
(window-size-fixed nil))
(fit-window-to-buffer nil nil 1)))
(goto-char (point-min)))))

(defun lv-delete-window ()
"Delete LV window and kill its buffer."
(when (window-live-p lv-wnd)
(let ((buf (window-buffer lv-wnd)))
(delete-window lv-wnd)
(kill-buffer buf))))

(provide 'lv)

27 changes: 27 additions & 0 deletions targets/hydra-init.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
;;; hydra-test.el --- bare hydra init

;; Copyright (C) 2015 Free Software Foundation, Inc.

;; Author: Oleh Krehel

;; This file is part of GNU Emacs.

;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.

(add-to-list 'load-path default-directory)
(require 'hydra)
(setq hydra-examples-verbatim t)
(require 'hydra-examples)
(require 'hydra-test)
(mapc #'byte-compile-file '("hydra.el" "hydra-examples.el" "hydra-ox.el" "hydra-test.el" "lv.el"))