aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/calendar/lunar.el66
1 files changed, 36 insertions, 30 deletions
diff --git a/lisp/calendar/lunar.el b/lisp/calendar/lunar.el
index 26710d8c9cf..1e779452886 100644
--- a/lisp/calendar/lunar.el
+++ b/lisp/calendar/lunar.el
@@ -178,36 +178,42 @@ remainder mod 4 gives the phase: 0 new moon, 1 first quarter, 2 full moon,
178(defvar displayed-year) 178(defvar displayed-year)
179 179
180;;;###cal-autoload 180;;;###cal-autoload
181(defun calendar-lunar-phases () 181(defun calendar-lunar-phases (&optional event)
182 "Create a buffer with the lunar phases for the current calendar window." 182 "Create a buffer with the lunar phases for the current calendar window.
183 (interactive) 183If EVENT is non-nil, it's an event indicating the buffer position to
184 (message "Computing phases of the moon...") 184use instead of point."
185 (let ((m1 displayed-month) 185 (interactive (list last-nonmenu-event))
186 (y1 displayed-year) 186 ;; If called from a menu, with the calendar window not selected.
187 (m2 displayed-month) 187 (with-current-buffer
188 (y2 displayed-year)) 188 (if event (window-buffer (posn-window (event-start event)))
189 (calendar-increment-month m1 y1 -1) 189 (current-buffer))
190 (calendar-increment-month m2 y2 1) 190 (message "Computing phases of the moon...")
191 (calendar-in-read-only-buffer lunar-phases-buffer 191 (let ((m1 displayed-month)
192 (calendar-set-mode-line 192 (y1 displayed-year)
193 (if (= y1 y2) 193 (m2 displayed-month)
194 (format "Phases of the Moon from %s to %s, %d%%-" 194 (y2 displayed-year))
195 (calendar-month-name m1) (calendar-month-name m2) y2) 195 (calendar-increment-month m1 y1 -1)
196 (format "Phases of the Moon from %s, %d to %s, %d%%-" 196 (calendar-increment-month m2 y2 1)
197 (calendar-month-name m1) y1 (calendar-month-name m2) y2))) 197 (calendar-in-read-only-buffer lunar-phases-buffer
198 (insert 198 (calendar-set-mode-line
199 (mapconcat 199 (if (= y1 y2)
200 (lambda (x) 200 (format "Phases of the Moon from %s to %s, %d%%-"
201 (let ((date (car x)) 201 (calendar-month-name m1) (calendar-month-name m2) y2)
202 (time (cadr x)) 202 (format "Phases of the Moon from %s, %d to %s, %d%%-"
203 (phase (nth 2 x))) 203 (calendar-month-name m1) y1 (calendar-month-name m2) y2)))
204 (concat (calendar-date-string date) 204 (insert
205 ": " 205 (mapconcat
206 (lunar-phase-name phase) 206 (lambda (x)
207 " " 207 (let ((date (car x))
208 time))) 208 (time (cadr x))
209 (lunar-phase-list m1 y1) "\n"))) 209 (phase (nth 2 x)))
210 (message "Computing phases of the moon...done"))) 210 (concat (calendar-date-string date)
211 ": "
212 (lunar-phase-name phase)
213 " "
214 time)))
215 (lunar-phase-list m1 y1) "\n")))
216 (message "Computing phases of the moon...done"))))
211 217
212;;;###cal-autoload 218;;;###cal-autoload
213(define-obsolete-function-alias 'calendar-phases-of-moon 219(define-obsolete-function-alias 'calendar-phases-of-moon