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

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

[elpa] master cfac8bd 21/27: Prepare for the first version in GNU ELPA


From: Oleh Krehel
Subject: [elpa] master cfac8bd 21/27: Prepare for the first version in GNU ELPA
Date: Sat, 24 Jan 2015 20:36:36 +0000

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

    Prepare for the first version in GNU ELPA
    
    hydra.el (hydra-set-transient-map): new alias
    
    `set-transient-map' only works for Emacs>=24.4.
---
 README.md         |    6 ++--
 hydra-examples.el |   22 ++++++++--------
 hydra.el          |   69 +++++++++++++++++++++++++++-------------------------
 3 files changed, 50 insertions(+), 47 deletions(-)

diff --git a/README.md b/README.md
index 5a52369..f7ddd40 100644
--- a/README.md
+++ b/README.md
@@ -15,7 +15,7 @@ that disables itself auto-magically.
 Here's how I use the examples bundled with Hydra:
 
     (require 'hydra-examples)
-    (hydra-create "C-M-w" hydra-example-move-window-splitter)
+    (hydra-create "C-M-y" hydra-example-move-window-splitter)
     (hydra-create "M-g" hydra-example-goto-error)
 
 You can expand the examples in-place, it still looks elegant:
@@ -34,7 +34,7 @@ You can use the third optional argument of `hydra-create` for 
this (it defaults
 Here's an example:
 
 ```cl
-(hydra-create "z"
+(hydra-create "C-z"
   '(("l" forward-char)
     ("h" backward-char)
     ("j" next-line)
@@ -47,7 +47,7 @@ For this simple case, there's even a shortcut: if you give a 
keymap as the third
 the lambda will be generated for you:
 
 ```cl
-(hydra-create "z"
+(hydra-create "C-z"
   '(("l" forward-char)
     ("h" backward-char)
     ("j" next-line)
diff --git a/hydra-examples.el b/hydra-examples.el
index 98f3310..c07bd8e 100644
--- a/hydra-examples.el
+++ b/hydra-examples.el
@@ -1,22 +1,23 @@
-;;; hydra-examples.el --- some applications for hydra
+;;; hydra-examples.el --- Some applications for Hydra
 
-;; Copyright (C) 2015 Oleh Krehel
+;; Copyright (C) 2015  Free Software Foundation, Inc.
 
-;; This file is not part of GNU Emacs
+;; Author: Oleh Krehel
 
-;; This file is free software; you can redistribute it and/or modify
+;; 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, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
-;; This program is distributed in the hope that it will be useful,
+;; 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.
 
-;; For a full copy of the GNU General Public License
-;; see <http://www.gnu.org/licenses/>.
-
+;; 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:
 ;;
@@ -81,5 +82,4 @@ Works best if you have not more than 4 windows.")
 Useful for e.g. `occur', `rgrep' and the like.")
 
 (provide 'hydra-examples)
-
 ;;; hydra-examples.el ends here
diff --git a/hydra.el b/hydra.el
index 49e78e9..932cea2 100644
--- a/hydra.el
+++ b/hydra.el
@@ -1,27 +1,28 @@
-;;; hydra.el --- make bindings that stick around.
+;;; hydra.el --- Make bindings that stick around
 
-;; Copyright (C) 2015 Oleh Krehel
+;; Copyright (C) 2015  Free Software Foundation, Inc.
 
 ;; Author: Oleh Krehel <address@hidden>
+;; Maintainer: Oleh Krehel <address@hidden>
 ;; URL: https://github.com/abo-abo/hydra
-;; Version: 0.2.3
-;; Package-Requires: ((cl-lib "0.5"))
+;; Version: 0.3.0
 ;; Keywords: bindings
+;; Package-Requires: ((cl-lib "0.5"))
 
-;; This file is not part of GNU Emacs
+;; This file is part of GNU Emacs.
 
-;; This file is free software; you can redistribute it and/or modify
+;; 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, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
-;; This program is distributed in the hope that it will be useful,
+;; 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.
 
-;; For a full copy of the GNU General Public License
-;; see <http://www.gnu.org/licenses/>.
+;; 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:
 ;;
@@ -29,31 +30,31 @@
 ;; short bindings with a common prefix - a Hydra.
 ;;
 ;; Once you summon the Hydra (through the prefixed binding), all the
-;; heads can be called in succession with only a short extension.  The
-;; Hydra is vanquished once Hercules, any binding that isn't the
+;; heads can be called in succession with only a short extension.
+;; The Hydra is vanquished once Hercules, any binding that isn't the
 ;; Hydra's head, arrives.  Note that Hercules, besides vanquishing the
 ;; Hydra, will still serve his orignal purpose, calling his proper
 ;; command.  This makes the Hydra very seamless, it's like a minor
 ;; mode that disables itself automagically.
 ;;
-;; Here's how I use the examples bundled with Hydra:
+;; Here's how to use the examples bundled with Hydra:
 ;;
 ;;    (require 'hydra-examples)
-;;    (hydra-create "C-M-w" hydra-example-move-window-splitter)
+;;    (hydra-create "C-M-y" hydra-example-move-window-splitter)
 ;;    (hydra-create "M-g" hydra-example-goto-error)
 ;;
 ;; You can expand the examples in-place, it still looks elegant:
 ;;
 ;;     (hydra-create "<f2>"
-;;       '(("g" text-scale-increase)
-;;         ("l" text-scale-decrease)))
+;;       '(("g" text-scale-increase "zoom in")
+;;         ("l" text-scale-decrease "zoom out")))
+;;
+;; The third element of each list is the optional doc string that will
+;; be displayed in the echo area when `hydra-is-helpful' is t.
 
 ;;; Code:
 (require 'cl-lib)
 
-(eval-when-compile
-  (require 'cl))
-
 (defgroup hydra nil
   "Make bindings that stick around."
   :group 'bindings
@@ -64,8 +65,13 @@
   :type 'boolean
   :group 'hydra)
 
+(defalias 'hydra-set-transient-map
+  (if (fboundp 'set-transient-map)
+      'set-transient-map
+    'set-temporary-overlay-map))
+
 (defvar hydra-last nil
-  "The result of the last `set-transient-map' call.")
+  "The result of the last `hydra-set-transient-map' call.")
 
 ;;;###autoload
 (defmacro hydra-create (body heads &optional method)
@@ -91,17 +97,15 @@ When `(keymapp METHOD)`, it becomes:
                    (define-key keymap (kbd (car x))
                      (intern (format "hydra-%s-%S" body (cadr x)))))
                  heads))
-         (hint (concat "hydra: "
+         (hint (format "hydra: %s."
                        (mapconcat
                         (lambda (h)
-                          (if (caddr h)
-                              (format "[%s]: %s"
-                                      (propertize (car h)
-                                                  'face 
'font-lock-keyword-face)
-                                      (caddr h))
-                            (propertize (car h) 'face 
'font-lock-keyword-face)))
-                        heads ", ")
-                       "."))
+                          (format
+                           (if (cl-caddr h)
+                               (concat "[%s]: " (cl-caddr h))
+                             "%s")
+                           (propertize (car h) 'face 'font-lock-keyword-face)))
+                        heads ", ")))
          (doc (format
                "Create a hydra with a \"%s\" body and the heads:\n\n%s."
                body
@@ -133,19 +137,18 @@ When `(keymapp METHOD)`, it becomes:
                      `((call-interactively #',(cadr head))
                        (when hydra-is-helpful
                          (message ,hint))
-                       (setq hydra-last (set-transient-map ',keymap t))))))
+                       (setq hydra-last (hydra-set-transient-map ',keymap 
t))))))
           heads names)
        (defun ,(intern (format "hydra-%s-body" body)) ()
          ,doc
          (interactive)
          (when hydra-is-helpful
            (message ,hint))
-         (setq hydra-last (set-transient-map ',keymap t)))
+         (setq hydra-last (hydra-set-transient-map ',keymap t)))
        ,@(cl-mapcar
           (lambda (head name)
             `(,method ,(vconcat (kbd body) (kbd (car head))) #',name))
           heads names))))
 
 (provide 'hydra)
-
 ;;; hydra.el ends here



reply via email to

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