* Diary font-lock problem
@ 2007-04-05 15:50 Stephen Berman
0 siblings, 0 replies; 4+ messages in thread
From: Stephen Berman @ 2007-04-05 15:50 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 486 bytes --]
I would like to have diary entries of the form
Thu, Apr 5, 2007 Today's entry
in which the string "Thu, Apr 5, 2007" has diary face. This
fontification is not provided by the default diary setup, but I had
hoped and expected to get it by customizing diary-date-forms
appropriately. However, after making what I think is the necessary
customization, I still don't get the fontification I want. I can
reproduce the problem with emacs -Q:
1. Let ~/.emacs consist only of this sexp:
[-- Attachment #2: ~/.emacs --]
[-- Type: text/plain, Size: 257 bytes --]
(custom-set-variables
'(diary-date-forms (quote ((month "/" day "[^/0-9]") (month "/" day "/" year "[^0-9]") (monthname " *" day "[^,0-9]") (monthname " *" day ", *" year "[^0-9]") (dayname "\\W") (dayname ", *" monthname " *" day ", *" year "[^0-9]")))))
[-- Attachment #3: Type: text/plain, Size: 209 bytes --]
2. emacs -Q
3. M-x calendar
4. In the calendar type `s' to show the whole diary, then in the diary
buffer type the above entry. Only "Thu," has diary face.
If I eval diary-font-lock-keywords I get this:
[-- Attachment #4: diary-font-lock-keywords --]
[-- Type: text/plain, Size: 1698 bytes --]
(("^&?\\(\\([0-9]+\\|\\*\\)/\\([0-9]+\\|\\*\\)[^/0-9]\\)" 1 diary-face) ("^&?\\(\\([0-9]+\\|\\*\\)/\\([0-9]+\\|\\*\\)/-?\\([0-9]+\\|\\*\\)[^0-9]\\)" 1 diary-face) ("^&?\\(\\(A\\(?:pr\\(?:\\.\\|il\\)?\\|ug\\(?:\\.\\|ust\\)?\\)\\|Dec\\(?:\\.\\|ember\\)?\\|Feb\\(?:\\.\\|ruary\\)?\\|J\\(?:an\\(?:\\.\\|uary\\)?\\|u\\(?:l[.y]\\|n[.e]\\|[ln]\\)\\)\\|Ma\\(?:r\\(?:\\.\\|ch\\)\\|y\\.\\|[ry]\\)\\|Nov\\(?:\\.\\|ember\\)?\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\\)\\|Nov\\(?:\\.\\|ember\\)?\\|Oct\\(?:\\.\\|ober\\)?\\|Sep\\(?:\\.\\|tember\\)?\\|\\*\\) *\\([0-9]+\\|\\*\\), *-?\\([0-9]+\\|\\*\\)[^0-9]\\)" 1 diary-face) ...)
[-- Attachment #5: Type: text/plain, Size: 172 bytes --]
The sexp immediately preceding `...' contains the result of the
customization I made above, and the regexp it contains is
string-match'd by the above diary entry string:
[-- Attachment #6: string-match --]
[-- Type: text/plain, Size: 613 bytes --]
(string-match "^&?\\(\\(Fri\\(?:\\.\\|day\\)?\\|Mon\\(?:\\.\\|day\\)?\\|S\\(?:at\\(?:\\.\\|urday\\)?\\|un\\(?:\\.\\|day\\)?\\)\\|T\\(?:hu\\(?:\\.\\|rsday\\)?\\|ue\\(?:\\.\\|sday\\)?\\)\\|Wed\\(?:\\.\\|nesday\\)?\\), *\\(A\\(?:pr\\(?:\\.\\|il\\)?\\|ug\\(?:\\.\\|ust\\)?\\)\\|Dec\\(?:\\.\\|ember\\)?\\|Feb\\(?:\\.\\|ruary\\)?\\|J\\(?:an\\(?:\\.\\|uary\\)?\\|u\\(?:l[.y]\\|n[.e]\\|[ln]\\)\\)\\|Ma\\(?:r\\(?:\\.\\|ch\\)\\|y\\.\\|[ry]\\)\\|Nov\\(?:\\.\\|ember\\)?\\|Oct\\(?:\\.\\|ober\\)?\\|Sep\\(?:\\.\\|tember\\)?\\|\\*\\) *\\([0-9]+\\|\\*\\), *-?\\([0-9]+\\|\\*\\)[^0-9]\\)" "Thu, Apr 5, 2007 Today's entry")
=> 0
[-- Attachment #7: Type: text/plain, Size: 237 bytes --]
Therefore, I assume my customization is what I want and I would expect
the entire date string to have diary face. Should I be doing
something else to get the fontification I want (and if so, what) or is
there a bug here?
Steve Berman
[-- Attachment #8: Type: text/plain, Size: 152 bytes --]
_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Diary font-lock problem
[not found] <mailman.1789.1175788495.7795.help-gnu-emacs@gnu.org>
@ 2007-04-06 3:28 ` Glenn Morris
2007-04-06 4:15 ` Glenn Morris
0 siblings, 1 reply; 4+ messages in thread
From: Glenn Morris @ 2007-04-06 3:28 UTC (permalink / raw)
To: help-gnu-emacs
Stephen Berman wrote:
> Thu, Apr 5, 2007 Today's entry
>
> in which the string "Thu, Apr 5, 2007" has diary face.
> 1. Let ~/.emacs consist only of this sexp:
You've written this:
(setq diary-date-forms
'((month "/" day "[^/0-9]")
(month "/" day "/" year "[^0-9]")
(monthname " *" day "[^,0-9]")
(monthname " *" day ", *" year "[^0-9]")
(dayname "\\W")
(dayname ", *" monthname " *" day ", *" year "[^0-9]")))
where the last line is the pattern you added.
The string "Thu, Apr 5, 2007" also matches the pattern in the previous
line, ie (dayname "\\W"). This pattern gets applied before yours does.
So move your pattern earlier in the diary-date-forms list (at the
start is probably best).
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Diary font-lock problem
2007-04-06 3:28 ` Diary font-lock problem Glenn Morris
@ 2007-04-06 4:15 ` Glenn Morris
2007-04-06 16:00 ` Stephen Berman
0 siblings, 1 reply; 4+ messages in thread
From: Glenn Morris @ 2007-04-06 4:15 UTC (permalink / raw)
To: help-gnu-emacs
Glenn Morris wrote:
> The string "Thu, Apr 5, 2007" also matches the pattern in the previous
> line, ie (dayname "\\W"). This pattern gets applied before yours does.
In other words, you've fallen afoul of the comment in the doc string
of diary-date-forms about making sure your patterns are mutually
exclusive.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Diary font-lock problem
2007-04-06 4:15 ` Glenn Morris
@ 2007-04-06 16:00 ` Stephen Berman
0 siblings, 0 replies; 4+ messages in thread
From: Stephen Berman @ 2007-04-06 16:00 UTC (permalink / raw)
To: help-gnu-emacs
On Thu, 05 Apr 2007 21:15:05 -0700 Glenn Morris <rgm+news@stanford.edu> wrote:
> Glenn Morris wrote:
>
>> The string "Thu, Apr 5, 2007" also matches the pattern in the previous
>> line, ie (dayname "\\W"). This pattern gets applied before yours does.
>
> In other words, you've fallen afoul of the comment in the doc string
> of diary-date-forms about making sure your patterns are mutually
> exclusive.
Thanks, and sorry for not being careful enough to recognize the error
in my customization as well as in reading the docstring.
Steve Berman
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-04-06 16:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.1789.1175788495.7795.help-gnu-emacs@gnu.org>
2007-04-06 3:28 ` Diary font-lock problem Glenn Morris
2007-04-06 4:15 ` Glenn Morris
2007-04-06 16:00 ` Stephen Berman
2007-04-05 15:50 Stephen Berman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).