aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2011-05-03 19:06:28 -0700
committerGlenn Morris2011-05-03 19:06:28 -0700
commitf330b642bb28e3b9ee5e14ac55c8103e6dcde412 (patch)
tree6dcdd63309a92207c5d473d3e7b50b2a368f430d
parent31dfb76ced3936a6a9f5417ce048414d8039e8f7 (diff)
downloademacs-f330b642bb28e3b9ee5e14ac55c8103e6dcde412.tar.gz
emacs-f330b642bb28e3b9ee5e14ac55c8103e6dcde412.zip
Small diary-lib.el font-locking fix.
* lisp/calendar/diary-lib.el (diary-fancy-date-pattern): Turn it into a function, so it follows changes in calendar-date-style. (diary-fancy-date-matcher): New function. (diary-fancy-font-lock-keywords): Use diary-fancy-date-matcher. (diary-fancy-font-lock-fontify-region-function): Use diary-fancy-date-pattern as a function.
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/calendar/diary-lib.el38
2 files changed, 27 insertions, 18 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 277d7c12cf7..3d7b2c33832 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,12 @@
12011-05-04 Glenn Morris <rgm@gnu.org> 12011-05-04 Glenn Morris <rgm@gnu.org>
2 2
3 * calendar/diary-lib.el (diary-fancy-date-pattern): Turn it into a
4 function, so it follows changes in calendar-date-style.
5 (diary-fancy-date-matcher): New function.
6 (diary-fancy-font-lock-keywords): Use diary-fancy-date-matcher.
7 (diary-fancy-font-lock-fontify-region-function):
8 Use diary-fancy-date-pattern as a function.
9
3 * calendar/diary-lib.el (diary-fancy-date-pattern): Do not use 10 * calendar/diary-lib.el (diary-fancy-date-pattern): Do not use
4 non-numbers for `year' etc pseudo-variables. (Bug#8583) 11 non-numbers for `year' etc pseudo-variables. (Bug#8583)
5 12
diff --git a/lisp/calendar/diary-lib.el b/lisp/calendar/diary-lib.el
index ee9ad0e4567..43c0682277c 100644
--- a/lisp/calendar/diary-lib.el
+++ b/lisp/calendar/diary-lib.el
@@ -2364,8 +2364,9 @@ return a font-lock pattern matching array of MONTHS and marking SYMBOL."
2364 2364
2365;;; Fancy Diary Mode. 2365;;; Fancy Diary Mode.
2366 2366
2367;; FIXME does not update upon changes to the name-arrays. 2367(defun diary-fancy-date-pattern ()
2368(defvar diary-fancy-date-pattern 2368 "Return a regexp matching the first line of a fancy diary date header.
2369This depends on the calendar date style."
2369 (concat 2370 (concat
2370 (let ((dayname (diary-name-pattern calendar-day-name-array nil t)) 2371 (let ((dayname (diary-name-pattern calendar-day-name-array nil t))
2371 (monthname (diary-name-pattern calendar-month-name-array nil t)) 2372 (monthname (diary-name-pattern calendar-month-name-array nil t))
@@ -2381,26 +2382,27 @@ return a font-lock pattern matching array of MONTHS and marking SYMBOL."
2381 (mapconcat 'eval calendar-date-display-form "") 2382 (mapconcat 'eval calendar-date-display-form "")
2382 nil t)) 2383 nil t))
2383 ;; Optional ": holiday name" after the date. 2384 ;; Optional ": holiday name" after the date.
2384 "\\(: .*\\)?") 2385 "\\(: .*\\)?"))
2385 "Regular expression matching the first line of a fancy diary date header.") 2386
2387(defun diary-fancy-date-matcher (limit)
2388 "Search for a fancy diary data header, up to LIMIT."
2389 ;; Any number of " other holiday name" lines, followed by "==" line.
2390 (when (re-search-forward
2391 (format "%s\\(\n +.*\\)*\n=+$" (diary-fancy-date-pattern)) limit t)
2392 (put-text-property (match-beginning 0) (match-end 0) 'font-lock-multiline t)
2393 t))
2386 2394
2387(define-obsolete-variable-alias 'fancy-diary-font-lock-keywords 2395(define-obsolete-variable-alias 'fancy-diary-font-lock-keywords
2388 'diary-fancy-font-lock-keywords "23.1") 2396 'diary-fancy-font-lock-keywords "23.1")
2389 2397
2390(defvar diary-fancy-font-lock-keywords 2398(defvar diary-fancy-font-lock-keywords
2391 (list 2399 `((diary-fancy-date-matcher . diary-face)
2392 (list 2400 ("^.*\\([aA]nniversary\\|[bB]irthday\\).*$" . 'diary-anniversary)
2393 ;; Any number of " other holiday name" lines, followed by "==" line. 2401 ("^.*Yahrzeit.*$" . font-lock-reference-face)
2394 (concat diary-fancy-date-pattern "\\(\n +.*\\)*\n=+$") 2402 ("^\\(Erev \\)?Rosh Hodesh.*" . font-lock-function-name-face)
2395 '(0 (progn (put-text-property (match-beginning 0) (match-end 0) 2403 ("^Day.*omer.*$" . font-lock-builtin-face)
2396 'font-lock-multiline t) 2404 ("^Parashat.*$" . font-lock-comment-face)
2397 diary-face))) 2405 (,(format "\\(^\\|\\s-\\)%s\\(-%s\\)?" diary-time-regexp
2398 '("^.*\\([aA]nniversary\\|[bB]irthday\\).*$" . 'diary-anniversary)
2399 '("^.*Yahrzeit.*$" . font-lock-reference-face)
2400 '("^\\(Erev \\)?Rosh Hodesh.*" . font-lock-function-name-face)
2401 '("^Day.*omer.*$" . font-lock-builtin-face)
2402 '("^Parashat.*$" . font-lock-comment-face)
2403 `(,(format "\\(^\\|\\s-\\)%s\\(-%s\\)?" diary-time-regexp
2404 diary-time-regexp) . 'diary-time)) 2406 diary-time-regexp) . 'diary-time))
2405 "Keywords to highlight in fancy diary display.") 2407 "Keywords to highlight in fancy diary display.")
2406 2408
@@ -2416,7 +2418,7 @@ Fontify the region between BEG and END, quietly unless VERBOSE is non-nil."
2416 (while (and (looking-at " +[^ ]") 2418 (while (and (looking-at " +[^ ]")
2417 (zerop (forward-line -1)))) 2419 (zerop (forward-line -1))))
2418 ;; This check not essential. 2420 ;; This check not essential.
2419 (if (looking-at diary-fancy-date-pattern) 2421 (if (looking-at (diary-fancy-date-pattern))
2420 (setq beg (line-beginning-position))) 2422 (setq beg (line-beginning-position)))
2421 (goto-char end) 2423 (goto-char end)
2422 (forward-line 0) 2424 (forward-line 0)