]> code.delx.au - gnu-emacs-elpa/commitdiff
Make digit and negative arguments work in 24.3
authorOleh Krehel <ohwoeowho@gmail.com>
Mon, 13 Apr 2015 10:26:02 +0000 (12:26 +0200)
committerOleh Krehel <ohwoeowho@gmail.com>
Mon, 13 Apr 2015 10:30:18 +0000 (12:30 +0200)
* hydra.el (hydra--digit-argument): Update.
(hydra--negative-argument): Update.

Just flatten these two functions to their 25.2 bodies, and don't call
the `set-transient-map' variants, since the map remains anyway because
of `hydra-base-map'.

hydra.el

index 0d219e3e2dfae3f47cc5dbb9fbb45bfbb9da2395..15ef3100773e82e9950757e5eae777dd539dadbe 100644 (file)
--- a/hydra.el
+++ b/hydra.el
@@ -253,17 +253,28 @@ Vanquishable only through a blue head.")
 (defun hydra--digit-argument (arg)
   "Forward to (`digit-argument' ARG)."
   (interactive "P")
-  (let ((universal-argument-map
-         (if (fboundp 'universal-argument--mode)
-             hydra-curr-map
-           universal-argument-map)))
-    (digit-argument arg)))
+  (let* ((char (if (integerp last-command-event)
+                   last-command-event
+                 (get last-command-event 'ascii-character)))
+         (digit (- (logand char ?\177) ?0)))
+    (setq prefix-arg (cond ((integerp arg)
+                            (+ (* arg 10)
+                               (if (< arg 0)
+                                   (- digit)
+                                 digit)))
+                           ((eq arg '-)
+                            (if (zerop digit)
+                                '-
+                              (- digit)))
+                           (t
+                            digit)))))
 
 (defun hydra--negative-argument (arg)
   "Forward to (`negative-argument' ARG)."
   (interactive "P")
-  (let ((universal-argument-map hydra-curr-map))
-    (negative-argument arg)))
+  (setq prefix-arg (cond ((integerp arg) (- arg))
+                         ((eq arg '-) nil)
+                         (t '-))))
 
 ;;* Repeat
 (defvar hydra-repeat--prefix-arg nil