Algorithms for moving the cursor to a date on a 12 month rotating calendar in Emacs

蹲街弑〆低调 提交于 2019-12-01 17:26:22

I must be missing something because it looks like the formulas are as simple as (pseudocode):

first  = 9 * ( rows - 1 ) 
second = 6 + 25 * ( cols - 1 )

based on your edit, you can calculate the rows and cols to move with:

if target > display
   difference = target - display
else 
   difference = 12 + target - display
 rows = difference / 3 
 cols = difference % 3
 rowmove = 9 * rows 
 colmove = 6 + 25 * cols

And then use the formula above.

My attempt at elisp:

(let difference (if (>= target-month display-month) 
                      (- target-month display-month) 
                    (- (+ target-month 12) display-month)))
(let rows (/ difference 3))
(let cols (% difference 3))
(let rowmove (* 9 rows))   
(let colmove (+ 6 (* 25 cols)))
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!