branch: elpa/free-keys
commit d681a3fba0856dd78cf5d9f959692c72b44eb2b5
Author: Matus Goljer <[email protected]>
Commit: Matus Goljer <[email protected]>
Fix the "overflow" bug on the last/first row if the displayed list was not
rectangular
---
free-keys.el | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/free-keys.el b/free-keys.el
index 7543bb2988..e3f142a7cb 100644
--- a/free-keys.el
+++ b/free-keys.el
@@ -67,12 +67,17 @@ The columns are ordered according to variable
`free-keys-keys',
advancing down-right. The margin between each column is 5 characters."
(setq columns (or columns 80))
(let* ((len (+ 5 (length (car key-list))))
+ (num-of-keys (length key-list))
(cols (/ columns len))
- (rows (/ (length key-list) cols))
+ (rows (1+ (/ num-of-keys cols)))
+ (rem (mod num-of-keys cols))
(cur-col 0)
(cur-row 0))
- (dotimes (i (length key-list))
- (insert (nth (+ (* cur-col rows) cur-row) key-list) " ")
+ (dotimes (i num-of-keys)
+ (insert (nth
+ (+ (* cur-col rows) cur-row (if (> cur-col rem) (- rem cur-col)
0))
+ key-list)
+ " ")
(cl-incf cur-col)
(when (= cur-col cols)
(insert "\n")