Skip to content

Commit

Permalink
hydra.el: Turn on lexical-binding
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
abo-abo committed Mar 22, 2015
1 parent 7783f89 commit 03771f4
Showing 1 changed file with 27 additions and 30 deletions.
57 changes: 27 additions & 30 deletions hydra.el
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
;;; hydra.el --- Make bindings that stick around
;;; hydra.el --- Make bindings that stick around. -*- lexical-binding: t -*-

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

;; Author: Oleh Krehel <[email protected]>
;; Maintainer: Oleh Krehel <[email protected]>
;; URL: https://github.com/abo-abo/hydra
;; Version: 0.11.0
;; Version: 0.12.0
;; Keywords: bindings
;; Package-Requires: ((cl-lib "0.5"))

Expand Down Expand Up @@ -82,7 +82,7 @@
(defalias 'hydra-set-transient-map
(if (fboundp 'set-transient-map)
'set-transient-map
(lambda (map keep-pred &optional on-exit)
(lambda (map _keep-pred &optional on-exit)
(with-no-warnings
(set-temporary-overlay-map map (hydra--pred on-exit))))))

Expand Down Expand Up @@ -321,26 +321,25 @@ Return DEFAULT if PROP is not in H."
'blue))
(t
(error "Unknown :exit %S" exit)))))
(let ((body-exit (plist-get (cddr body) :exit)))
(cond ((null (cadr h))
(when head-color
(hydra--complain
"Doubly specified blue head - nil cmd is already blue: %S" h))
'blue)
((null head-color)
(hydra--body-color body))
((null foreign-keys)
head-color)
((eq foreign-keys 'run)
(if (eq head-color 'red)
'pink
'blue))
((eq foreign-keys 'warn)
(if (memq head-color '(red amaranth))
'amaranth
'teal))
(t
(error "Unexpected %S %S" h body))))))
(cond ((null (cadr h))
(when head-color
(hydra--complain
"Doubly specified blue head - nil cmd is already blue: %S" h))
'blue)
((null head-color)
(hydra--body-color body))
((null foreign-keys)
head-color)
((eq foreign-keys 'run)
(if (eq head-color 'red)
'pink
'blue))
((eq foreign-keys 'warn)
(if (memq head-color '(red amaranth))
'amaranth
'teal))
(t
(error "Unexpected %S %S" h body)))))

(defun hydra--body-foreign-keys (body)
"Return what BODY does with a non-head binding."
Expand Down Expand Up @@ -420,9 +419,9 @@ Otherwise, add PREFIX to the symbol name."
sym
(intern (concat prefix "/" str)))))

(defun hydra--hint (name body docstring heads)
(defun hydra--hint (body heads)
"Generate a hint for the echo area.
NAME, BODY, DOCSTRING and HEADS are parameters to `defhydra'."
BODY, and HEADS are parameters to `defhydra'."
(let (alist)
(dolist (h heads)
(let ((val (assoc (cadr h) alist))
Expand Down Expand Up @@ -473,8 +472,7 @@ HEAD's binding is returned as a string wrapped with [] or {}."
NAME, BODY, DOCSTRING and HEADS are parameters of `defhydra'.
The expressions can be auto-expanded according to NAME."
(setq docstring (replace-regexp-in-string "\\^" "" docstring))
(let ((rest (hydra--hint name body docstring heads))
(body-color (hydra--body-color body))
(let ((rest (hydra--hint body heads))
(prefix (symbol-name name))
(start 0)
varlist
Expand Down Expand Up @@ -726,7 +724,7 @@ In duplicate HEADS, :cmd-name is modified to whatever they duplicate."
The matrix size is ROWS times COLS."
(let ((ls (copy-sequence lst))
res)
(dotimes (c cols)
(dotimes (_c cols)
(push (hydra--pad (hydra-multipop ls rows) rows) res))
(nreverse res)))

Expand Down Expand Up @@ -881,7 +879,6 @@ result of `defhydra'."
(let ((keymap (copy-keymap hydra-base-map))
(body-name (intern (format "%S/body" name)))
(body-key (cadr body))
(body-color (hydra--body-color body))
(body-pre (plist-get (cddr body) :pre))
(body-body-pre (plist-get (cddr body) :body-pre))
(body-post (plist-get (cddr body) :post))
Expand Down Expand Up @@ -972,7 +969,7 @@ result of `defhydra'."
(or body-body-pre body-pre) body-post
'(setq prefix-arg current-prefix-arg))))))

(defmacro defhydradio (name body &rest heads)
(defmacro defhydradio (name _body &rest heads)
"Create radios with prefix NAME.
BODY specifies the options; there are none currently.
HEADS have the format:
Expand Down

0 comments on commit 03771f4

Please sign in to comment.