1 ;; 11-cal-sy.el --- Calendar Settings -*- Emacs-Lisp -*-
3 ;; Copyright (C) 2007 - 2013 Steve Youngs
5 ;; Author: Steve Youngs <steve@sxemacs.org>
6 ;; Maintainer: Steve Youngs <steve@sxemacs.org>
7 ;; Created: <2007-12-02>
8 ;; Time-stamp: <Thursday Dec 31, 2015 01:18:15 steve>
9 ;; Download: <http://bastard.steveyoungs.com/~steve/SXEmacs/inits/>
10 ;; HTMLised: <http://bastard.steveyoungs.com/~steve/SXEmacs/htmlinits/11-cal-sy.html>
11 ;; Git Repo: git clone http://git.sxemacs.org/syinit
12 ;; Keywords: init, compile
14 ;; This file is part of SYinit
16 ;; Redistribution and use in source and binary forms, with or without
17 ;; modification, are permitted provided that the following conditions
20 ;; 1. Redistributions of source code must retain the above copyright
21 ;; notice, this list of conditions and the following disclaimer.
23 ;; 2. Redistributions in binary form must reproduce the above copyright
24 ;; notice, this list of conditions and the following disclaimer in the
25 ;; documentation and/or other materials provided with the distribution.
27 ;; 3. Neither the name of the author nor the names of any contributors
28 ;; may be used to endorse or promote products derived from this
29 ;; software without specific prior written permission.
31 ;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
32 ;; IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
33 ;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
34 ;; DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
35 ;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
36 ;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37 ;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
38 ;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
39 ;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
40 ;; OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
41 ;; IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 ;; My calendar/diary settings
50 ;; The HTML version of this file was created with Hrvoje Niksic's
51 ;; htmlize.el which is part of the XEmacs "text-modes" package.
59 ;:*=======================
64 calendar-latitude -27.3
65 calendar-longitude 153.0
66 calendar-location-name "Brisbane"
67 calendar-time-zone 600
68 calendar-standard-time-zone-name "EST"
70 ; calendar-date-display-form ; see: "Howm Integration" below
71 ; '((if dayname (concat dayname ", ")) day " " monthname " " year)
72 calendar-time-display-form
73 '(24-hours ":" minutes
74 (if time-zone " (") time-zone (if time-zone ")"))
75 calendar-week-start-day 1
76 diary-file (expand-file-name "diary" user-init-directory)
77 diary-mail-addr "steve"
79 european-calendar-style t
80 mark-diary-entries-in-calendar t
81 number-of-diary-entries 7
82 view-diary-entries-initially t)
84 ;:*=======================
86 ;; Turning this off for a while to see if I can get used to using Howm
88 ;;(autoload 'todo-mode "todo-mode"
89 ;; "Major mode for editing TODO lists." t)
90 ;;(autoload 'todo-show "todo-mode"
91 ;; "Show TODO items." t)
92 ;;(autoload 'todo-insert-item "todo-mode"
93 ;; "Add TODO item." t)
94 ;;(global-set-key "\C-ct" 'todo-show) ;; switch to TODO buffer
95 ;;(global-set-key "\C-cn" 'todo-insert-item) ;; insert new item
97 ;; todo-prefix "&%%(todo-cp)"
98 ;; todo-file-do (expand-file-name ".todo-do" (getenv "HOME"))
99 ;; todo-file-done (expand-file-name ".todo-done" (getenv "HOME"))
100 ;; todo-file-top (expand-file-name ".todo-top" (getenv "HOME"))
101 ;; todo-time-string-format "%3b, %d")
103 ;:*=======================
104 ;:* Fancy Diary with perdy colours!
105 (defun sy-hide-fancy-dashes ()
106 "Hides the long lines of dashes from todo-mode in fancy diary display."
108 (goto-char (point-min))
109 (while (re-search-forward "-----" nil t)
111 (make-extent (match-beginning 0) (1+ (match-end 0)))
114 (define-derived-mode fancy-diary-display-mode fundamental-mode "Diary"
115 "Minor mode for displaying Fancy Diary entries buffer."
116 (set (make-local-variable 'font-lock-defaults)
117 '(fancy-diary-font-lock-keywords t))
118 (sy-hide-fancy-dashes)
120 (define-key (current-local-map) "o" 'other-window)
121 (define-key (current-local-map) [space] 'scroll-up-command)
122 (define-key (current-local-map) [backspace] 'scroll-down-command))
124 (defadvice fancy-diary-display (after set-mode activate)
125 "Give the Fancy Diary Entries buffer a mode of its own.
127 It has the ever-so-original name of: `fancy-diary-display-mode', adds
128 a couple of motion keybindings, and lets you set up font lock keywords
129 for a fontified Diary buffer."
131 (set-buffer (get-buffer-create fancy-diary-buffer))
132 (fancy-diary-display-mode)))
134 (defun fancy-diary-font-lock-keywords ()
135 (let* ((today (regexp-opt (list (calendar-date-string (calendar-current-date)))))
136 (keywords `(("^---\\s-\\(.*$\\)" (1 font-lock-function-name-face))
137 ("^.*SY:" . font-lock-keyword-face)
138 ("\"\\(.*\\)\"" (1 font-lock-string-face))
139 ("`\\(.*?\\)'" (1 font-lock-reference-face))
140 ("[0-9]+:[0-9]+" . font-lock-warning-face)
141 (,today . font-lock-warning-face)
142 ("\\(^.*\\)\n=" (1 font-lock-comment-face)))))
145 (defvar fancy-diary-font-lock-keywords (fancy-diary-font-lock-keywords))
147 ;:*=======================
148 ;:* Display ISO week numbers
150 ;; I saw this code mentioned on c.e.x. I just snarfed what I needed
151 ;; and SXEmacserised it.
154 (defvar calendar-use-colours t
155 "Tries to fontify Calendar if non-nil.")
157 (defvar calendar-week-string "WK"
158 "String (up to three chars) used in calendar header to identify week numbers.")
160 (defun sy-generate-calendar-month (month year indent)
161 "Produce a calendar for ISO-week, month, year on the Gregorian calendar.
162 The calendar is inserted in the buffer starting at the line on which point
163 is currently located, but indented INDENT spaces. The indentation is done
164 from the first character on the line and does not disturb the first INDENT
165 characters on the line."
166 (let* ((blank-days ; At start of month
168 (- (calendar-day-of-week (list month 1 year))
169 calendar-week-start-day)
171 (last (calendar-last-day-of-month month year)))
172 (goto-char (point-min))
173 (calendar-insert-indented
174 (calendar-string-spread
175 (list (format "%s %d" (calendar-month-name month) year)) ? 20)
177 ;; Add colour to month name
178 (if calendar-use-colours
179 (set-extent-property (make-extent (point-min) (1- (point)))
180 'face 'calendar-header-face))
181 (calendar-insert-indented "" indent) ; Go to proper spot
184 (insert (substring (aref calendar-day-name-array
185 (mod (+ calendar-week-start-day i) 7)) 0 2))
186 ;; Add colour to week day names and sundays
187 (if calendar-use-colours
188 (set-extent-property (make-extent (- (point) 2) (point)) 'face
189 (if (= 0 (mod (+ calendar-week-start-day i) 7))
190 'calendar-sunday-face
191 'calendar-header-face)))
193 ;; Add week-string after week dates
194 (insert (concat calendar-week-string
195 (make-string (- 3 (length calendar-week-string)) ? )))
196 ;; Add colour to week-string
197 (if calendar-use-colours
198 (set-extent-property (make-extent (- (point) 3) (point))
199 'face 'calendar-week-face))
200 (calendar-insert-indented "" 0 t);; Force onto following line
201 (calendar-insert-indented "" indent);; Go to proper spot
202 ;; Add blank days before the first of the month
203 (calendar-for-loop i from 1 to blank-days do (insert " "))
204 ;; Put in the days of the month
207 (insert (format "%2d " i))
208 (if (not calendar-use-colours)
210 (put-text-property (- (point) 3) (1- (point)) 'mouse-face 'highlight)
211 ;; Add colour to sunday
212 (if (= 1 (mod (+ blank-days calendar-week-start-day i) 7))
213 (set-extent-property (make-extent (- (point) 3) (1- (point)))
214 'face 'calendar-sunday-face)))
215 (and (zerop (mod (+ i blank-days) 7))
216 ;; Add ISO-week # at the end each week entry
218 (format "%2d " (extract-calendar-month
219 (calendar-iso-from-absolute
220 (calendar-absolute-from-gregorian
221 (list month i year)))))))
222 ;; Add colour to week #
223 (if calendar-use-colours
224 (set-extent-property (make-extent (- (point) 3) (1- (point)))
225 'face 'calendar-week-face)
228 (calendar-insert-indented "" 0 t);; Force onto following line
229 (calendar-insert-indented "" indent)))));; Go to proper spot
231 (defalias 'generate-calendar-month #'sy-generate-calendar-month)
233 ;:*=======================
235 (add-hook 'diary-display-hook #'fancy-diary-display)
236 (add-hook 'diary-hook #'appt-make-list)
237 (add-hook 'list-diary-entries-hook
240 (include-other-diary-files)))
241 (add-hook 'mark-diary-entries-hook #'mark-included-diary-files)
242 (add-hook 'today-visible-calendar-hook #'calendar-mark-today)
243 (add-hook 'calendar-move-hook #'(lambda () (diary-view-entries 1)))
244 (add-hook 'calendar-mode-hook
246 (setq fancy-diary-font-lock-keywords
247 (fancy-diary-font-lock-keywords))))
249 ;:*=======================
252 (require 'balloon-help)
253 (balloon-help-mode 1)
255 balloon-help-background "BlanchedAlmond"
256 balloon-help-foreground "Black"
257 display-time-24hr-format t
258 display-time-day-and-date t
259 display-time-no-mail-balloon "What! No mail? That can't be right."
260 display-time-mail-balloon-show-gnus-group t
261 display-time-mail-balloon-max-displayed 20
262 display-time-mail-balloon-gnus-split-width 19
263 display-time-mail-balloon-enhance-gnus-group
265 display-time-mail-balloon-suppress-gnus-group
266 '("\\(SPAM.*\\|returned\\.mail\\)"))
270 appt-message-warning-time 30
271 appt-display-format 'echo
273 appt-display-mode-line t
274 appt-announce-method 'appt-persistent-message-announce)
276 ;:*=======================
278 (defvar displayed-month)
279 (defvar displayed-year)
282 ;; First up, a slightly re-written easter-holiday function
283 (defun sy-easter-holidays ()
284 "List of dates related to Easter, as visible in calendar window.
285 Ever-so-slightly modified to include the Easter Monday holiday."
286 (if (and (> displayed-month 5) (not all-christian-calendar-holidays))
287 nil;; Ash Wednesday, Good Friday, and Easter are not visible.
288 (let* ((century (1+ (/ displayed-year 100)))
289 (shifted-epact ;; Age of moon for April 5...
290 (% (+ 14 (* 11 (% displayed-year 19));; ...by Nicaean rule
291 (- ;; ...corrected for the Gregorian century rule
293 (/ ;; ...corrected for Metonic cycle inaccuracy.
294 (+ 5 (* 8 century)) 25)
295 (* 30 century));; Keeps value positive.
297 (adjusted-epact ;; Adjust for 29.5 day month.
298 (if (or (= shifted-epact 0)
299 (and (= shifted-epact 1) (< 10 (% displayed-year 19))))
302 (paschal-moon ;; Day after the full moon on or after March 21.
303 (- (calendar-absolute-from-gregorian (list 4 19 displayed-year))
305 (abs-easter (calendar-dayname-on-or-before 0 (+ paschal-moon 7)))
308 (list (calendar-gregorian-from-absolute abs-easter)