emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 986226f 18/45: Simplify `keyboard-quit'


From: Oleh Krehel
Subject: [elpa] master 986226f 18/45: Simplify `keyboard-quit'
Date: Thu, 16 Apr 2015 12:45:46 +0000

branch: master
commit 986226f8652743881d282bd2de81b7bc11ddaf31
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    Simplify `keyboard-quit'
    
    * hydra.el (hydra--clearfun): Update.
    (hydra-keyboard-quit): Remove defcustom.
    (defhydra): Update.
    
    * hydra-test.el: Update tests.
    (hydra-integration-1): Catch the 'quit signal, since now "C-g" is just a
    plain `keyboard-quit'.
---
 hydra-test.el |   33 +++++----------------------------
 hydra.el      |   14 ++------------
 2 files changed, 7 insertions(+), 40 deletions(-)

diff --git a/hydra-test.el b/hydra-test.el
index 0ac6a8f..9fe3fb1 100644
--- a/hydra-test.el
+++ b/hydra-test.el
@@ -45,7 +45,6 @@
                       (107 . hydra-error/previous-error)
                       (106 . hydra-error/next-error)
                       (104 . hydra-error/first-error)
-                      (7 . hydra-keyboard-quit)
                       (kp-subtract . hydra--negative-argument)
                       (kp-9 . hydra--digit-argument)
                       (kp-8 . hydra--digit-argument)
@@ -221,7 +220,6 @@ The body can be accessed via `hydra-error/body'."
                       (97 . hydra-toggle/abbrev-mode-and-exit)
                       (102 . hydra-toggle/auto-fill-mode-and-exit)
                       (116 . hydra-toggle/toggle-truncate-lines-and-exit)
-                      (7 . hydra-keyboard-quit)
                       (kp-subtract . hydra--negative-argument)
                       (kp-9 . hydra--digit-argument)
                       (kp-8 . hydra--digit-argument)
@@ -368,7 +366,6 @@ The body can be accessed via `hydra-toggle/body'."
        (quote (keymap (113 . hydra-vi/nil)
                       (107 . hydra-vi/previous-line)
                       (106 . hydra-vi/next-line)
-                      (7 . hydra-vi/hydra-keyboard-quit-and-exit)
                       (kp-subtract . hydra--negative-argument)
                       (kp-9 . hydra--digit-argument)
                       (kp-8 . hydra--digit-argument)
@@ -392,27 +389,9 @@ The body can be accessed via `hydra-toggle/body'."
                       (48 . hydra--digit-argument)
                       (45 . hydra--negative-argument)
                       (21 . hydra--universal-argument))))
-      (defun hydra-vi/hydra-keyboard-quit-and-exit nil
-        "Create a hydra with no body and the heads:
-
-\"\":    `hydra-keyboard-quit',
-\"j\":    `next-line',
-\"k\":    `previous-line',
-\"q\":    `nil'
-
-The body can be accessed via `hydra-vi/body'.
-
-Call the head: `hydra-keyboard-quit'."
-        (interactive)
-        (hydra-default-pre)
-        (set-cursor-color "#e52b50")
-        (hydra-keyboard-quit)
-        (call-interactively
-         (function hydra-keyboard-quit)))
       (defun hydra-vi/next-line nil
         "Create a hydra with no body and the heads:
 
-\"\":    `hydra-keyboard-quit',
 \"j\":    `next-line',
 \"k\":    `previous-line',
 \"q\":    `nil'
@@ -440,7 +419,6 @@ Call the head: `next-line'."
       (defun hydra-vi/previous-line nil
         "Create a hydra with no body and the heads:
 
-\"\":    `hydra-keyboard-quit',
 \"j\":    `next-line',
 \"k\":    `previous-line',
 \"q\":    `nil'
@@ -468,7 +446,6 @@ Call the head: `previous-line'."
       (defun hydra-vi/nil nil
         "Create a hydra with no body and the heads:
 
-\"\":    `hydra-keyboard-quit',
 \"j\":    `next-line',
 \"k\":    `previous-line',
 \"q\":    `nil'
@@ -498,7 +475,6 @@ Call the head: `nil'."
       (defun hydra-vi/body nil
         "Create a hydra with no body and the heads:
 
-\"\":    `hydra-keyboard-quit',
 \"j\":    `next-line',
 \"k\":    `previous-line',
 \"q\":    `nil'
@@ -532,7 +508,6 @@ The body can be accessed via `hydra-vi/body'."
        (defvar hydra-zoom/keymap nil
          "Keymap for hydra-zoom.")
        (quote (keymap (114 . hydra-zoom/lambda-r)
-                      (7 . hydra-keyboard-quit)
                       (kp-subtract . hydra--negative-argument)
                       (kp-9 . hydra--digit-argument)
                       (kp-8 . hydra--digit-argument)
@@ -650,7 +625,6 @@ The body can be accessed via `hydra-zoom/body'."
        (defvar hydra-zoom/keymap nil
          "Keymap for hydra-zoom.")
        (quote (keymap (114 . hydra-zoom/lambda-r)
-                      (7 . hydra-keyboard-quit)
                       (kp-subtract . hydra--negative-argument)
                       (kp-9 . hydra--digit-argument)
                       (kp-8 . hydra--digit-argument)
@@ -1122,8 +1096,11 @@ _w_ Worf:                      % -8`hydra-tng/worf^^    
_h_ Set phasers to
                                 (kbd "C-c aabbaaqaabbaa")))
                    "jjkkjjaabbaa|"))
   (should (string= (hydra-with "|"
-                               (execute-kbd-macro
-                                (kbd "C-c aabb C-g aaqaabbaa")))
+                               (condition-case nil
+                                   (execute-kbd-macro
+                                    (kbd "C-c aabb C-g"))
+                                 (quit nil))
+                               (execute-kbd-macro "aaqaabbaa"))
                    "jjkkaaqaabbaa|")))
 
 (provide 'hydra-test)
diff --git a/hydra.el b/hydra.el
index 502b6a8..c9ef2da 100644
--- a/hydra.el
+++ b/hydra.el
@@ -107,7 +107,8 @@ warn: keep KEYMAP and issue a warning instead of running 
the command."
 
 (defun hydra--clearfun ()
   "Disable the current Hydra unless `this-command' is a head."
-  (if (eq this-command 'handle-switch-frame)
+  (if (memq this-command '(handle-switch-frame
+                           keyboard-quit))
       (hydra-disable)
     (unless (eq this-command
                 (lookup-key hydra-curr-map (this-command-keys-vector)))
@@ -163,11 +164,6 @@ warn: keep KEYMAP and issue a warning instead of running 
the command."
   :type 'boolean
   :group 'hydra)
 
-(defcustom hydra-keyboard-quit ""
-  "This binding will quit an amaranth Hydra.
-It's the only other way to quit it besides though a blue head.
-It's possible to set this to nil.")
-
 (defcustom hydra-lv t
   "When non-nil, `lv-message' (not `message') will be used to display hints."
   :type 'boolean)
@@ -814,11 +810,6 @@ result of `defhydra'."
          (body-post (plist-get body-plist :post))
          (body-color (hydra--body-color body)))
     (hydra--make-funcall body-post)
-    (when hydra-keyboard-quit
-      (if body-post
-          (setq heads (cons (list hydra-keyboard-quit #'hydra-keyboard-quit 
nil :exit t)
-                            heads))
-        (define-key keymap hydra-keyboard-quit #'hydra-keyboard-quit)))
     (dolist (h heads)
       (let ((len (length h)))
         (cond ((< len 2)
@@ -885,7 +876,6 @@ result of `defhydra'."
                   (lambda (head)
                     (let ((name (hydra--head-property head :cmd-name)))
                       (when (and (cadr head)
-                                 (not (eq (cadr head) 'hydra-keyboard-quit))
                                  (or body-key body-map))
                         (let ((bind (hydra--head-property head :bind body-map))
                               (final-key



reply via email to

[Prev in Thread] Current Thread [Next in Thread]