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

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

[nongnu] elpa/free-keys d681a3fba0 12/19: Fix the "overflow" bug on the


From: ELPA Syncer
Subject: [nongnu] elpa/free-keys d681a3fba0 12/19: Fix the "overflow" bug on the last/first row if the displayed list was not rectangular
Date: Sat, 29 Jan 2022 08:02:53 -0500 (EST)

branch: elpa/free-keys
commit d681a3fba0856dd78cf5d9f959692c72b44eb2b5
Author: Matus Goljer <dota.keys@gmail.com>
Commit: Matus Goljer <dota.keys@gmail.com>

    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")



reply via email to

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