unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Fontification of calendar breaks localization
@ 2002-11-26 16:35 Romain FRANCOISE
  2002-11-26 17:33 ` Alan Shutko
  2002-11-26 22:46 ` Stefan Monnier
  0 siblings, 2 replies; 4+ messages in thread
From: Romain FRANCOISE @ 2002-11-26 16:35 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1385 bytes --]

Hi,

recently a patch by Alan Shutko which allows fontification of the
Calendar and Diary buffers was applied to the trunk.  It is a very nice
feature, however it breaks when you're using a "localized" Calendar;
that is if you have changed the month and day names to reflect your
language's.

For instance in my case (in French), I have:

(setq calendar-day-name-array
      ["Dimanche" "Lundi" "Mardi" "Mercredi" "Jeudi" "Vendredi" "Samedi"]
      calendar-month-name-array
      ["Janvier" "Février" "Mars" "Avril" "Mai" "Juin" "Juillet"
       "Août" "Septembre" "Octobre" "Novembre" "Décembre"])

so that the Diary and Calendar are displayed in French.

Alan's patch uses a regular expression to recognize month names and
fontify them, this regular expression does not match with accentuated
characters, so some month names get fontified and others don't.

I have written a quick fix that builds the regular expression using the
names defined in `calendar-month-name-array' so that it always
accurately matches month names.  It is in the attached patch (against
the current CVS).

What do you think?

        Romain.

-- 
Romain FRANCOISE <romain@orebokech.com> | You know that old saying,
it's a miracle -- http://orebokech.com/ | that you always hurt the ones
                                        | you love? Well it works both
                                        | ways.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: fontification fix --]
[-- Type: text/x-patch, Size: 958 bytes --]

Index: lisp/calendar/calendar.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/calendar/calendar.el,v
retrieving revision 1.142
diff -c -r1.142 calendar.el
*** lisp/calendar/calendar.el	16 Nov 2002 19:18:57 -0000	1.142
--- lisp/calendar/calendar.el	26 Nov 2002 15:44:13 -0000
***************
*** 2477,2483 ****
  
  (defvar calendar-font-lock-keywords
    (list
!    '("[A-Z][a-z]+ -?[0-9]+" . font-lock-function-name-face) ; month and year
     (cons
      (concat (substring (aref calendar-day-name-array 6) 0 2)
  	    "\\|"
--- 2477,2488 ----
  
  (defvar calendar-font-lock-keywords
    (list
!    (cons 
!     (mapconcat 'identity 
!                (mapcar '(lambda (x) (concat x " -?[0-9]+"))
!                        calendar-month-name-array)
!                "\\|")
!     'font-lock-function-name-face)
     (cons
      (concat (substring (aref calendar-day-name-array 6) 0 2)
  	    "\\|"

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Fontification of calendar breaks localization
  2002-11-26 16:35 Fontification of calendar breaks localization Romain FRANCOISE
@ 2002-11-26 17:33 ` Alan Shutko
  2002-11-26 22:46 ` Stefan Monnier
  1 sibling, 0 replies; 4+ messages in thread
From: Alan Shutko @ 2002-11-26 17:33 UTC (permalink / raw)


Romain FRANCOISE <romain@orebokech.com> writes:

> I have written a quick fix that builds the regular expression using the
> names defined in `calendar-month-name-array' so that it always
> accurately matches month names.

Very good idea.  I'm in favor of it.

-- 
Alan Shutko <ats@acm.org> - In a variety of flavors!
Head Crash: Falling asleep at the keyboard

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Fontification of calendar breaks localization
  2002-11-26 16:35 Fontification of calendar breaks localization Romain FRANCOISE
  2002-11-26 17:33 ` Alan Shutko
@ 2002-11-26 22:46 ` Stefan Monnier
  2002-11-26 23:14   ` Romain FRANCOISE
  1 sibling, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2002-11-26 22:46 UTC (permalink / raw)
  Cc: emacs-devel

> I have written a quick fix that builds the regular expression using the
> names defined in `calendar-month-name-array' so that it always
> accurately matches month names.  It is in the attached patch (against
> the current CVS).
> 
> What do you think?

Good idea.

> !     (mapconcat 'identity 
> !                (mapcar '(lambda (x) (concat x " -?[0-9]+"))
> !                        calendar-month-name-array)
> !                "\\|")

I'd use

   (concat (regexp-opt (mapcar 'identity calendar-month-name-array) t)
           " -?[0-9]+")

instead, tho: it makes a shorter regexp.


	Stefan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Fontification of calendar breaks localization
  2002-11-26 22:46 ` Stefan Monnier
@ 2002-11-26 23:14   ` Romain FRANCOISE
  0 siblings, 0 replies; 4+ messages in thread
From: Romain FRANCOISE @ 2002-11-26 23:14 UTC (permalink / raw)


Stefan Monnier writes:

> I'd use
>    (concat (regexp-opt (mapcar 'identity calendar-month-name-array) t)
>            " -?[0-9]+")
> instead, tho: it makes a shorter regexp.

Nice, I didn't think of optimization while I was looking into it, and
your code is way better.  Do you want me to send a new patch or can you
make the changes yourself?

Thanks,

        Romain.

-- 
Romain FRANCOISE <romain@orebokech.com> | I know, you love the song but
it's a miracle -- http://orebokech.com/ | not the singer.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-11-26 23:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-11-26 16:35 Fontification of calendar breaks localization Romain FRANCOISE
2002-11-26 17:33 ` Alan Shutko
2002-11-26 22:46 ` Stefan Monnier
2002-11-26 23:14   ` Romain FRANCOISE

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).