[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 02f2907 33/36: hydra.el (hydra--sort-heads): change orderi
From: |
Oleh Krehel |
Subject: |
[elpa] master 02f2907 33/36: hydra.el (hydra--sort-heads): change ordering method of columns |
Date: |
Sat, 22 Jul 2017 11:22:26 -0400 (EDT) |
branch: master
commit 02f29073e0074ffc124c3545f87f21f73f3c057e
Author: David AMAR <address@hidden>
Commit: David AMAR <address@hidden>
hydra.el (hydra--sort-heads): change ordering method of columns
The order was based upon the alphabetical order of the column name.
It is now done upon the order in which column name first appear in defhydra.
---
hydra-test.el | 50 +++++++++++++++++++++++++++++++++++++++++++++++++-
hydra.el | 13 +++++++++----
2 files changed, 58 insertions(+), 5 deletions(-)
diff --git a/hydra-test.el b/hydra-test.el
index 94a19a4..ffbfa24 100644
--- a/hydra-test.el
+++ b/hydra-test.el
@@ -1442,7 +1442,7 @@ t: info-to"
;; column compatibility with ruby style and no colum specified
;; column declared several time
;; nil column
-(ert-deftest hydra-column-1 ()
+(ert-deftest hydra-column-basic ()
(should (equal (eval
(cadr
(nth 2
@@ -1507,6 +1507,54 @@ o: ok | s: string
270 272 (face hydra-face-pink)
296 298 (face hydra-face-pink)))))
+;; check column order is the same as they appear in defhydra
+(ert-deftest hydra-column-order ()
+ (should (equal (eval
+ (cadr
+ (nth 2
+ (nth 3
+ (macroexpand
+ '(defhydra hydra-window-order
+ (:color red :hint nil :timeout 4)
+ ("z" ace-window "ace" :color blue :column
"Switch")
+ ("h" windmove-left "← window")
+ ("j" windmove-down "↓ window")
+ ("l" windmove-right "→ window")
+ ("s" split-window-below "split window" :color
blue :column "Split Management")
+ ("v" split-window-right "split window
vertically" :color blue)
+ ("d" delete-window "delete current window")
+ ("f" follow-mode "toogle follow mode")
+ ("u" winner-undo "undo window conf" :column
"Undo/Redo")
+ ("r" winner-redo "redo window conf")
+ ("b" balance-windows "balance window height"
:column "1-Sizing")
+ ("m" maximize-window "maximize current
window")
+ ("k" windmove-up "↑ window" :column "Switch")
+ ("M" minimize-window "maximize current
window" :column "1-Sizing")
+ ("q" nil "quit menu" :color blue :column
nil)))))))
+ #("hydra:
+Switch | Split Management | Undo/Redo | 1-Sizing
+----------- | -------------------------- | ------------------- |
--------------------------
+z: ace | s: split window | u: undo window conf | b: balance
window height
+h: ← window | v: split window vertically | r: redo window conf | m: maximize
current window
+j: ↓ window | d: delete current window | | M: maximize
current window
+l: → window | f: toogle follow mode | |
+k: ↑ window | | |
+[q]: quit menu."
+ 173 174 (face hydra-face-blue)
+ 187 188 (face hydra-face-blue)
+ 216 217 (face hydra-face-red)
+ 238 239 (face hydra-face-red)
+ 263 264 (face hydra-face-red)
+ 277 278 (face hydra-face-blue)
+ 306 307 (face hydra-face-red)
+ 328 329 (face hydra-face-red)
+ 355 356 (face hydra-face-red)
+ 369 370 (face hydra-face-red)
+ 420 421 (face hydra-face-red)
+ 447 448 (face hydra-face-red)
+ 461 462 (face hydra-face-red)
+ 512 513 (face hydra-face-red)
+ 578 579 (face hydra-face-blue)))))
(provide 'hydra-test)
diff --git a/hydra.el b/hydra.el
index 79ee6f1..1e28239 100644
--- a/hydra.el
+++ b/hydra.el
@@ -1002,12 +1002,17 @@ was defined."
heads)))
(defun hydra--sort-heads (normalized-heads)
- "Return a list of heads with non-nil doc sorted by ascending column property
-each head of NORMALIZED-HEADS must have a column property"
+ "Return a list of heads with non-nil doc grouped by column property.
+Each head of NORMALIZED-HEADS must have a column property."
(let* ((heads-wo-nil-doc (cl-remove-if-not (lambda (head) (nth 2 head))
normalized-heads))
+ (columns-list (delete-dups (mapcar (lambda (head)
(hydra--head-property head :column))
+ normalized-heads)))
+ (get-col-index-fun (lambda (head) (cl-position (hydra--head-property
head :column)
+ columns-list
+ :test 'equal)))
(heads-sorted (cl-sort heads-wo-nil-doc (lambda (it other)
- (string<
(hydra--head-property it :column)
-
(hydra--head-property other :column))))))
+ (< (funcall
get-col-index-fun it)
+ (funcall
get-col-index-fun other))))))
;; this operation partition the sorted head list into lists of heads with
same column property
(cl-loop for head in heads-sorted
for column-name = (hydra--head-property head :column)
- [elpa] master 32b8352 36/36: Merge commit '943636fe4a35298d9d234222bc4520dec9ef2305' from hydra, (continued)
- [elpa] master 32b8352 36/36: Merge commit '943636fe4a35298d9d234222bc4520dec9ef2305' from hydra, Oleh Krehel, 2017/07/22
- [elpa] master 91f8e7c 22/36: hydra.el: Bump version, Oleh Krehel, 2017/07/22
- [elpa] master a85a617 03/36: Allow to use e.g. "↑" in place of "<up>" in the docstring, Oleh Krehel, 2017/07/22
- [elpa] master 9c2589f 19/36: Update the package description, Oleh Krehel, 2017/07/22
- [elpa] master 63de503 21/36: hydra.el (hydra-key-regex): Add "$", Oleh Krehel, 2017/07/22
- [elpa] master 81d88e4 15/36: hydra.el (hydra-show-hint): Extract from defhydra, Oleh Krehel, 2017/07/22
- [elpa] master 1d378c6 16/36: Allow to set hydra verbosity, Oleh Krehel, 2017/07/22
- [elpa] master 2ebf862 25/36: Move Amaranth warning message to a defvar, Oleh Krehel, 2017/07/22
- [elpa] master a07b92a 26/36: lv.el (lv-window): Rename to " *LV*", Oleh Krehel, 2017/07/22
- [elpa] master 36fb5e0 32/36: hydra.el (defhydra): Use copy-tree on heads, Oleh Krehel, 2017/07/22
- [elpa] master 02f2907 33/36: hydra.el (hydra--sort-heads): change ordering method of columns,
Oleh Krehel <=
- [elpa] master 2751f00 31/36: Remove trailing whitespace from :column docstring, Oleh Krehel, 2017/07/22
- [elpa] master 38ce88a 34/36: hydra.el : fix some docstring warning, Oleh Krehel, 2017/07/22