comparison lisp/calendar/cal-menu.el @ 93328:15b0834c93df

(cal-menu-holidays-menu, cal-menu-list-holidays-year) (cal-menu-list-holidays-following-year, cal-menu-list-holidays-previous-year): Simplify now that 2nd arg of holiday-list is optional. (calendar-mouse-holidays): Remove un-needed local `l'.
author Glenn Morris <rgm@gnu.org>
date Fri, 28 Mar 2008 02:45:39 +0000
parents e800589311a9
children bbd30b42485a
comparison
equal deleted inserted replaced
93327:f6aa1bf031f5 93328:15b0834c93df
100 ;; The bug has since been fixed. 100 ;; The bug has since been fixed.
101 (dotimes (i 11) 101 (dotimes (i 11)
102 (push (vector (format "hol-year-%d" i) 102 (push (vector (format "hol-year-%d" i)
103 `(lambda () 103 `(lambda ()
104 (interactive) 104 (interactive)
105 (holiday-list (+ displayed-year ,(- i 5)) 105 (holiday-list (+ displayed-year ,(- i 5))))
106 (+ displayed-year ,(- i 5))))
107 :label `(format "For Year %d" 106 :label `(format "For Year %d"
108 (+ displayed-year ,(- i 5)))) 107 (+ displayed-year ,(- i 5))))
109 l)) 108 l))
110 (nreverse l)) 109 (nreverse l))
111 "--" 110 "--"
160 (error "Popup menus are not available on this system"))) 159 (error "Popup menus are not available on this system")))
161 160
162 (defun cal-menu-list-holidays-year () 161 (defun cal-menu-list-holidays-year ()
163 "Display a list of the holidays of the selected date's year." 162 "Display a list of the holidays of the selected date's year."
164 (interactive) 163 (interactive)
165 (let ((year (extract-calendar-year (calendar-cursor-to-date)))) 164 (holiday-list (extract-calendar-year (calendar-cursor-to-date))))
166 (holiday-list year year)))
167 165
168 (defun cal-menu-list-holidays-following-year () 166 (defun cal-menu-list-holidays-following-year ()
169 "Display a list of the holidays of the following year." 167 "Display a list of the holidays of the following year."
170 (interactive) 168 (interactive)
171 (let ((year (1+ (extract-calendar-year (calendar-cursor-to-date))))) 169 (holiday-list (1+ (extract-calendar-year (calendar-cursor-to-date)))))
172 (holiday-list year year)))
173 170
174 (defun cal-menu-list-holidays-previous-year () 171 (defun cal-menu-list-holidays-previous-year ()
175 "Display a list of the holidays of the previous year." 172 "Display a list of the holidays of the previous year."
176 (interactive) 173 (interactive)
177 (let ((year (1- (extract-calendar-year (calendar-cursor-to-date))))) 174 (holiday-list (1- (extract-calendar-year (calendar-cursor-to-date)))))
178 (holiday-list year year)))
179 175
180 (defun calendar-event-to-date (&optional error) 176 (defun calendar-event-to-date (&optional error)
181 "Date of last event. 177 "Date of last event.
182 If event is not on a specific date, signals an error if optional parameter 178 If event is not on a specific date, signals an error if optional parameter
183 ERROR is non-nil, otherwise just returns nil." 179 ERROR is non-nil, otherwise just returns nil."
204 (save-excursion 200 (save-excursion
205 (calendar-cursor-to-date (calendar-current-date)) 201 (calendar-cursor-to-date (calendar-current-date))
206 (calendar-cursor-holidays))) 202 (calendar-cursor-holidays)))
207 203
208 (autoload 'calendar-check-holidays "holidays") 204 (autoload 'calendar-check-holidays "holidays")
209 (autoload 'diary-list-entries "diary-lib")
210 205
211 (defun calendar-mouse-holidays (&optional event) 206 (defun calendar-mouse-holidays (&optional event)
212 "Pop up menu of holidays for mouse selected date. 207 "Pop up menu of holidays for mouse selected date.
213 EVENT is the event that invoked this command." 208 EVENT is the event that invoked this command."
214 (interactive "e") 209 (interactive "e")
215 (let* ((date (calendar-event-to-date)) 210 (let* ((date (calendar-event-to-date))
216 (l (mapcar 'list (calendar-check-holidays date)))
217 (title (format "Holidays for %s" (calendar-date-string date))) 211 (title (format "Holidays for %s" (calendar-date-string date)))
218 (selection 212 (selection
219 (cal-menu-x-popup-menu 213 (cal-menu-x-popup-menu
220 event 214 event
221 (list title 215 (list title
222 (append (list title) (or l '("None"))))))) 216 (append (list title)
217 (or (mapcar 'list (calendar-check-holidays date))
218 '("None")))))))
223 (and selection (call-interactively selection)))) 219 (and selection (call-interactively selection))))
224 220
221 (autoload 'diary-list-entries "diary-lib")
225 (defvar holidays-in-diary-buffer) ; only called from calendar.el 222 (defvar holidays-in-diary-buffer) ; only called from calendar.el
226 223
227 (defun calendar-mouse-view-diary-entries (&optional date diary event) 224 (defun calendar-mouse-view-diary-entries (&optional date diary event)
228 "Pop up menu of diary entries for mouse-selected date. 225 "Pop up menu of diary entries for mouse-selected date.
229 Use optional DATE and alternative file DIARY. EVENT is the event 226 Use optional DATE and alternative file DIARY. EVENT is the event