Emacs calendar: show more than 3 months?

前端 未结 4 961
青春惊慌失措
青春惊慌失措 2021-02-14 09:46

In Emacs, when you display the calendar with M-x calendar, you get a three-month display – last month, this month, and next month – in a new window that\'s just 8 l

4条回答
  •  情歌与酒
    2021-02-14 10:47

    It's not easy to do this, the code to generate calendar is:

    (defun calendar-generate (month year)
      "Generate a three-month Gregorian calendar centered around MONTH, YEAR."
      ;; A negative YEAR is interpreted as BC; -1 being 1 BC, and so on.
      ;; Note that while calendars for years BC could be displayed as it
      ;; stands, almost all other calendar functions (eg holidays) would
      ;; at best have unpredictable results for such dates.
      (if (< (+ month (* 12 (1- year))) 2)
          (error "Months before January, 1 AD cannot be displayed"))
      (setq displayed-month month
            displayed-year year)
      (erase-buffer)
      (calendar-increment-month month year -1)
      (dotimes (i 3)
        (calendar-generate-month month year
                                 (+ calendar-left-margin
                                    (* calendar-month-width i)))
        (calendar-increment-month month year 1)))
    

    Here, (dotimes (i 3) ...) generate 3 months in a row.

    So if you want to generate more than 3 months in more than 1 row, you must override calendar-generate function by yourself, same as @Luke said.

提交回复
热议问题