]> git.eshelyaron.com Git - emacs.git/commitdiff
Small diary-lib.el font-locking fix.
authorGlenn Morris <rgm@gnu.org>
Wed, 4 May 2011 02:06:28 +0000 (19:06 -0700)
committerGlenn Morris <rgm@gnu.org>
Wed, 4 May 2011 02:06:28 +0000 (19:06 -0700)
* 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.

lisp/ChangeLog
lisp/calendar/diary-lib.el

index 277d7c12cf7450b8fb424194696a81ee52b83319..3d7b2c338322a16cc2aad4d3b6bf9fdf9088b4d2 100644 (file)
@@ -1,5 +1,12 @@
 2011-05-04  Glenn Morris  <rgm@gnu.org>
 
+       * 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.
+
        * calendar/diary-lib.el (diary-fancy-date-pattern): Do not use
        non-numbers for `year' etc pseudo-variables.  (Bug#8583)
 
index ee9ad0e45670146733d61911698e96906e66e368..43c0682277cd2605616e1b0ca6076301ba0c0ced 100644 (file)
@@ -2364,8 +2364,9 @@ return a font-lock pattern matching array of MONTHS and marking SYMBOL."
 
 ;;; Fancy Diary Mode.
 
-;; FIXME does not update upon changes to the name-arrays.
-(defvar diary-fancy-date-pattern
+(defun diary-fancy-date-pattern ()
+  "Return a regexp matching the first line of a fancy diary date header.
+This depends on the calendar date style."
   (concat
    (let ((dayname (diary-name-pattern calendar-day-name-array nil t))
          (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."
                                (mapconcat 'eval calendar-date-display-form "")
                                nil t))
    ;; Optional ": holiday name" after the date.
-   "\\(: .*\\)?")
-  "Regular expression matching the first line of a fancy diary date header.")
+   "\\(: .*\\)?"))
+
+(defun diary-fancy-date-matcher (limit)
+  "Search for a fancy diary data header, up to LIMIT."
+  ;; Any number of " other holiday name" lines, followed by "==" line.
+  (when (re-search-forward
+         (format "%s\\(\n +.*\\)*\n=+$" (diary-fancy-date-pattern)) limit t)
+    (put-text-property (match-beginning 0) (match-end 0) 'font-lock-multiline t)
+    t))
 
 (define-obsolete-variable-alias 'fancy-diary-font-lock-keywords
   'diary-fancy-font-lock-keywords "23.1")
 
 (defvar diary-fancy-font-lock-keywords
-  (list
-   (list
-    ;; Any number of " other holiday name" lines, followed by "==" line.
-    (concat diary-fancy-date-pattern "\\(\n +.*\\)*\n=+$")
-    '(0 (progn (put-text-property (match-beginning 0) (match-end 0)
-                                  'font-lock-multiline t)
-               diary-face)))
-   '("^.*\\([aA]nniversary\\|[bB]irthday\\).*$" . 'diary-anniversary)
-   '("^.*Yahrzeit.*$" . font-lock-reference-face)
-   '("^\\(Erev \\)?Rosh Hodesh.*" . font-lock-function-name-face)
-   '("^Day.*omer.*$" . font-lock-builtin-face)
-   '("^Parashat.*$" . font-lock-comment-face)
-   `(,(format "\\(^\\|\\s-\\)%s\\(-%s\\)?" diary-time-regexp
+  `((diary-fancy-date-matcher . diary-face)
+    ("^.*\\([aA]nniversary\\|[bB]irthday\\).*$" . 'diary-anniversary)
+    ("^.*Yahrzeit.*$" . font-lock-reference-face)
+    ("^\\(Erev \\)?Rosh Hodesh.*" . font-lock-function-name-face)
+    ("^Day.*omer.*$" . font-lock-builtin-face)
+    ("^Parashat.*$" . font-lock-comment-face)
+    (,(format "\\(^\\|\\s-\\)%s\\(-%s\\)?" diary-time-regexp
               diary-time-regexp) . 'diary-time))
   "Keywords to highlight in fancy diary display.")
 
@@ -2416,7 +2418,7 @@ Fontify the region between BEG and END, quietly unless VERBOSE is non-nil."
   (while (and (looking-at " +[^ ]")
               (zerop (forward-line -1))))
   ;; This check not essential.
-  (if (looking-at diary-fancy-date-pattern)
+  (if (looking-at (diary-fancy-date-pattern))
       (setq beg (line-beginning-position)))
   (goto-char end)
   (forward-line 0)