branch: master commit 74573cb0ee5802bad3aef630979d1b1f7a88b9c6 Merge: f972634 fb86435 Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
Merge commit 'fb864353cd8dc91591942f398ef971ba7714b50f' from hydra --- packages/hydra/Makefile | 5 ++- packages/hydra/hydra-init.el | 4 +- packages/hydra/hydra-test.el | 90 +++++++++++++++++++++--------------------- packages/hydra/hydra.el | 20 +++++----- 4 files changed, 60 insertions(+), 59 deletions(-) diff --git a/packages/hydra/Makefile b/packages/hydra/Makefile index 43bcb5a..dd3a762 100644 --- a/packages/hydra/Makefile +++ b/packages/hydra/Makefile @@ -11,9 +11,12 @@ test: @echo "Using $(shell which $(emacs))..." $(emacs) -batch $(LOAD) -f ert-run-tests-batch-and-exit -compile: +run: $(emacs) -q $(LOAD) -l hydra-init.el make clean +compile: + $(emacs) -batch $(LOAD) -l hydra-init.el + clean: rm -f *.elc diff --git a/packages/hydra/hydra-init.el b/packages/hydra/hydra-init.el index 80b4159..881ceb6 100644 --- a/packages/hydra/hydra-init.el +++ b/packages/hydra/hydra-init.el @@ -24,6 +24,4 @@ (setq hydra-examples-verbatim t) (require 'hydra-examples) (require 'hydra-test) -(mapc #'byte-compile-file '("hydra.el")) -(switch-to-buffer "*Compile-Log*") -(ert t) +(mapc #'byte-compile-file '("hydra.el" "hydra-examples.el" "hydra-ox.el" "hydra-test.el" "lv.el")) diff --git a/packages/hydra/hydra-test.el b/packages/hydra/hydra-test.el index 15eabcf..9385ee6 100644 --- a/packages/hydra/hydra-test.el +++ b/packages/hydra/hydra-test.el @@ -92,6 +92,16 @@ "rep" :bind nil :exit nil)))) + (set + (defvar hydra-error/hint nil + "Dynamic hint for hydra-error.") + (quote + (format + #("error: [h]: first, [j]: next, [k]: prev, [SPC]: rep." + 8 9 (face hydra-face-red) + 20 21 (face hydra-face-red) + 31 32 (face hydra-face-red) + 42 45 (face hydra-face-red))))) (defun hydra-error/first-error nil "Create a hydra with a \"M-g\" body and the heads: @@ -215,16 +225,6 @@ Call the head: `previous-error'." (define-key global-map [134217831 107] (function hydra-error/previous-error)) - (set - (defvar hydra-error/hint nil - "Dynamic hint for hydra-error.") - (quote - (format - #("error: [h]: first, [j]: next, [k]: prev, [SPC]: rep." - 8 9 (face hydra-face-red) - 20 21 (face hydra-face-red) - 31 32 (face hydra-face-red) - 42 45 (face hydra-face-red))))) (defun hydra-error/body nil "Create a hydra with a \"M-g\" body and the heads: @@ -313,6 +313,16 @@ The body can be accessed via `hydra-error/body'." "abbrev" :exit t) ("q" nil "cancel" :exit t)))) + (set + (defvar hydra-toggle/hint nil + "Dynamic hint for hydra-toggle.") + (quote + (format + #("toggle: [t]: truncate, [f]: fill, [a]: abbrev, [q]: cancel." + 9 10 (face hydra-face-blue) + 24 25 (face hydra-face-blue) + 35 36 (face hydra-face-blue) + 48 49 (face hydra-face-blue))))) (defun hydra-toggle/toggle-truncate-lines-and-exit nil "Create a hydra with no body and the heads: @@ -385,16 +395,6 @@ Call the head: `nil'." (interactive) (hydra-default-pre) (hydra-keyboard-quit)) - (set - (defvar hydra-toggle/hint nil - "Dynamic hint for hydra-toggle.") - (quote - (format - #("toggle: [t]: truncate, [f]: fill, [a]: abbrev, [q]: cancel." - 9 10 (face hydra-face-blue) - 24 25 (face hydra-face-blue) - 35 36 (face hydra-face-blue) - 48 49 (face hydra-face-blue))))) (defun hydra-toggle/body nil "Create a hydra with no body and the heads: @@ -479,6 +479,15 @@ The body can be accessed via `hydra-toggle/body'." "" :exit nil) ("q" nil "quit" :exit t)))) + (set + (defvar hydra-vi/hint nil + "Dynamic hint for hydra-vi.") + (quote + (format + #("vi: j, k, [q]: quit." + 4 5 (face hydra-face-amaranth) + 7 8 (face hydra-face-amaranth) + 11 12 (face hydra-face-teal))))) (defun hydra-vi/next-line nil "Create a hydra with no body and the heads: @@ -563,15 +572,6 @@ Call the head: `nil'." (hydra-default-pre) (set-cursor-color "#e52b50") (hydra-keyboard-quit)) - (set - (defvar hydra-vi/hint nil - "Dynamic hint for hydra-vi.") - (quote - (format - #("vi: j, k, [q]: quit." - 4 5 (face hydra-face-amaranth) - 7 8 (face hydra-face-amaranth) - 11 12 (face hydra-face-teal))))) (defun hydra-vi/body nil "Create a hydra with no body and the heads: @@ -656,6 +656,14 @@ The body can be accessed via `hydra-vi/body'." nil :bind nil :exit t)))) + (set + (defvar hydra-zoom/hint nil + "Dynamic hint for hydra-zoom.") + (quote + (format + #("zoom: [r 0]: reset." + 7 8 (face hydra-face-red) + 9 10 (face hydra-face-blue))))) (defun hydra-zoom/lambda-r nil "Create a hydra with no body and the heads: @@ -709,14 +717,6 @@ Call the head: `(text-scale-set 0)'." (lambda nil (interactive) (text-scale-set 0))))) - (set - (defvar hydra-zoom/hint nil - "Dynamic hint for hydra-zoom.") - (quote - (format - #("zoom: [r 0]: reset." - 7 8 (face hydra-face-red) - 9 10 (face hydra-face-blue))))) (defun hydra-zoom/body nil "Create a hydra with no body and the heads: @@ -801,6 +801,14 @@ The body can be accessed via `hydra-zoom/body'." nil :bind nil :exit nil)))) + (set + (defvar hydra-zoom/hint nil + "Dynamic hint for hydra-zoom.") + (quote + (format + #("zoom: [r 0]: reset." + 7 8 (face hydra-face-red) + 9 10 (face hydra-face-blue))))) (defun hydra-zoom/lambda-r nil "Create a hydra with no body and the heads: @@ -854,14 +862,6 @@ Call the head: `(text-scale-set 0)'." (lambda nil (interactive) (text-scale-set 0))))) - (set - (defvar hydra-zoom/hint nil - "Dynamic hint for hydra-zoom.") - (quote - (format - #("zoom: [r 0]: reset." - 7 8 (face hydra-face-red) - 9 10 (face hydra-face-blue))))) (defun hydra-zoom/body nil "Create a hydra with no body and the heads: diff --git a/packages/hydra/hydra.el b/packages/hydra/hydra.el index 27d48d5..86f4883 100644 --- a/packages/hydra/hydra.el +++ b/packages/hydra/hydra.el @@ -5,7 +5,7 @@ ;; Author: Oleh Krehel <ohwoeo...@gmail.com> ;; Maintainer: Oleh Krehel <ohwoeo...@gmail.com> ;; URL: https://github.com/abo-abo/hydra -;; Version: 0.13.0 +;; Version: 0.13.1 ;; Keywords: bindings ;; Package-Requires: ((cl-lib "0.5")) @@ -442,7 +442,7 @@ HEAD's binding is returned as a string with a colored face." (teal 'hydra-face-teal) (t (error "Unknown color for %S" head)))))) -(defun hydra-fontify-head-greyscale (head body) +(defun hydra-fontify-head-greyscale (head _body) "Produce a pretty string from HEAD and BODY. HEAD's binding is returned as a string wrapped with [] or {}." (format @@ -548,7 +548,7 @@ HEAD is one of the HEADS passed to `defhydra'. BODY-PRE is added to the start of the wrapper. BODY-BEFORE-EXIT will be called before the hydra quits. BODY-AFTER-EXIT is added to the end of the wrapper." - (let ((name (hydra--head-name head name body)) + (let ((name (hydra--head-name head name)) (cmd (when (car head) (hydra--make-callable (cadr head)))) @@ -604,8 +604,8 @@ BODY-AFTER-EXIT is added to the end of the wrapper." `(when (and ,sym (symbolp ,sym)) (setq ,sym `(funcall #',,sym)))) -(defun hydra--head-name (h name body) - "Return the symbol for head H of hydra with NAME and BODY." +(defun hydra--head-name (h name) + "Return the symbol for head H of hydra with NAME." (let ((str (format "%S/%s" name (if (symbolp (cadr h)) (cadr h) @@ -868,7 +868,7 @@ result of `defhydra'." (if (eq h-exit 'default) body-exit h-exit)))))))))) - (plist-put (cl-cdddr h) :cmd-name (hydra--head-name h name body)) + (plist-put (cl-cdddr h) :cmd-name (hydra--head-name h name)) (when (null (cadr h)) (plist-put (cl-cdddr h) :exit t))) (let ((doc (hydra--doc body-key body-name heads)) (heads-nodup (hydra--delete-duplicates heads))) @@ -904,6 +904,10 @@ result of `defhydra'." (cl-remf (cl-cdddr j) :cmd-name) j)) heads)) + (set + (defvar ,(intern (format "%S/hint" name)) nil + ,(format "Dynamic hint for %S." name)) + ',(hydra--format name body docstring heads)) ;; create defuns ,@(mapcar (lambda (head) @@ -941,10 +945,6 @@ result of `defhydra'." (t (error "Invalid :bind property `%S' for head %S" bind head))))))) heads)) - (set - (defvar ,(intern (format "%S/hint" name)) nil - ,(format "Dynamic hint for %S." name)) - ',(hydra--format name body docstring heads)) ,(hydra--make-defun name body doc '(nil body) keymap-name