GNU logs - #13072, boring messages


Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#13072: 24.3.50; Fancy Diary display fontification failures
Resent-From: Stephen Berman <stephen.berman@HIDDEN>
Original-Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Tue, 04 Dec 2012 00:05:02 +0000
Resent-Message-ID: <handler.13072.B.135457944523626 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 13072
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: 
To: 13072 <at> debbugs.gnu.org
X-Debbugs-Original-To: bug-gnu-emacs@HIDDEN
Received: via spool by submit <at> debbugs.gnu.org id=B.135457944523626
          (code B ref -1); Tue, 04 Dec 2012 00:05:02 +0000
Received: (at submit) by debbugs.gnu.org; 4 Dec 2012 00:04:05 +0000
Received: from localhost ([127.0.0.1]:52134 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1TffzY-000691-8T
	for submit <at> debbugs.gnu.org; Mon, 03 Dec 2012 19:04:04 -0500
Received: from eggs.gnu.org ([208.118.235.92]:39993)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <stephen.berman@HIDDEN>) id 1TffzS-00068Y-HB
	for submit <at> debbugs.gnu.org; Mon, 03 Dec 2012 19:04:00 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <stephen.berman@HIDDEN>) id 1Tffx3-00036u-M0
	for submit <at> debbugs.gnu.org; Mon, 03 Dec 2012 19:01:33 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,
	RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD autolearn=unavailable version=3.3.2
Received: from lists.gnu.org ([208.118.235.17]:44102)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <stephen.berman@HIDDEN>) id 1Tffx3-00036q-IT
	for submit <at> debbugs.gnu.org; Mon, 03 Dec 2012 19:01:29 -0500
Received: from eggs.gnu.org ([208.118.235.92]:43199)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <stephen.berman@HIDDEN>) id 1Tffwz-0005o6-UR
	for bug-gnu-emacs@HIDDEN; Mon, 03 Dec 2012 19:01:29 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <stephen.berman@HIDDEN>) id 1Tffwx-000362-0e
	for bug-gnu-emacs@HIDDEN; Mon, 03 Dec 2012 19:01:25 -0500
Received: from mailout-de.gmx.net ([213.165.64.23]:46137)
	by eggs.gnu.org with smtp (Exim 4.71)
	(envelope-from <stephen.berman@HIDDEN>) id 1Tffww-00035w-NT
	for bug-gnu-emacs@HIDDEN; Mon, 03 Dec 2012 19:01:22 -0500
Received: (qmail invoked by alias); 04 Dec 2012 00:01:20 -0000
Received: from i59F55AB4.versanet.de (EHLO rosalinde.fritz.box) [89.245.90.180]
	by mail.gmx.net (mp039) with SMTP; 04 Dec 2012 01:01:20 +0100
X-Authenticated: #20778731
X-Provags-ID: V01U2FsdGVkX1/n8RNSb0Hnpe2It6YaP/uDxv9bA2z9/JvOm8L+iY
	pYebKuD1bPfYAs
From: Stephen Berman <stephen.berman@HIDDEN>
Date: Tue, 04 Dec 2012 01:01:15 +0100
Message-ID: <87k3sybs8k.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Y-GMX-Trusted: 0
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 208.118.235.17
X-Spam-Score: -4.2 (----)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -6.9 (------)

In GNU Emacs 24.3.50.6 (x86_64-suse-linux-gnu, GTK+ Version 3.4.4)
 of 2012-12-03 on rosalinde
Bzr revision: 111073 dmantipov@HIDDEN
Windowing system distributor `The X.Org Foundation', version 11.0.11203000
System Description:	openSUSE 12.2 (x86_64)

Configured using:
 `configure '--without-toolkit-scroll-bars' 'CFLAGS=-g3 -O0''

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=local
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t


The doc string of calendar-date-display-form says:

    For example, a typical American form would be
    '(month "/" day "/" (substring year -2))
    whereas
    '((format "%9s, %9s %2s, %4s" dayname monthname day year))
    would give the usual American style in fixed-length fields.

But if you set calendar-date-display-form to either of these values
(either via setq in your user-init-file or via the Custom interface),
then in the Fancy Diary display the date header line is not fontified.
To reproduce:

0. Let the file ~/diary consist of entries dated today, like these:
+------------------
| Dec 3, 2012 test1
| 12/3/2012 test2
| 12/3/12 test3
+------------------

1. emacs -Q
2. M-x calendar
3. In the *Calendar* buffer type `d' to get the Fancy Diary display, and
note the fontified date header:
+------------------
| Monday, December 3, 2012
| ========================
| test2
| test3
| test1
+------------------

4. Kill the *Fancy Diary Entries* buffer.
5. Type `M-x customize-option RET calendar-date-display-form RET',
change the value from the default `((if dayname (concat dayname ", "))
monthname " " day ", " year)' to `(month "/" day "/" (substring year
-2))', then repeat steps 2 and 3.
=> The date header in the Fancy Diary display is not fontified.

Now repeat steps 4 and 5, this time changing the value to `((format
"%9s, %9s %2s, %4s" dayname monthname day year))', then repeat steps 2
and 3 again.
=> Again, the date header in the Fancy Diary display is not fontified.

If you restore the default value and repeat steps 2 and 3, now the date
header is fontified again.  (Note, too, the all the entries in the
~/diary have correctly fontified headers, regardless of the value of
calendar-date-display-form.)

I think these two cases (using `substring' and using `format' in the
value of calendar-date-display-form) fail to fontify for different
reasons:

- In the substring case, the problem is that in
  diary-fancy-date-pattern, the form `(substring year -2)' is evaluated
  with `year' let-bound to "3", which raises an args-out-of-range error,
  short-circuiting fontification.

- In contrast, the `format' form returns a string with the variables
  replaced by their let-bound values, which evaluates to itself and is
  passed to replace-regexp-in-string, so diary-fancy-date-pattern
  returns a valid regexp for the Fancy Diary header, so fontification
  should occur AFAICT, yet it doesn't.  However, this appears to depend
  on the pattern and values of the width specifiers in the format
  string, in a way I don't understand.  From testing lots of
  combinations, I found the following generalization appears to hold: if
  the second `%s' sequence (corresponding to `monthname') has a width
  specifier not greater than 8 (note that `monthname' evaluates to
  "December", a string of 9 characters; I haven't tested other month
  names yet) and the fourth `%s' sequence (corresponding to `year') has
  a width specifier not greater than 1, then in the Fancy Diary display,
  the date header is correctly fontified, regardless of the values (or
  presence) of the first and third width specifiers (corresponding to
  `dayname' and `day'); otherwise, fontification fails.  (I haven't yet
  tested different numbers of `%s' sequences.)

I have no idea what's going on with the `format' cases; but if an
explanation can be found for the behavior I described, which is
independent of how diary-fancy-date-pattern builds the regexp -- in
other words, if we assume that the regexp resulting from `format' in
general is valid for fontification, then the following patch, which
fixes the fontification failure in the `substring' case (and generalizes
it to all non-atomic sexps aside from `format' sexps) is one possible
half of the solution.


=== modified file 'lisp/calendar/diary-lib.el'
*** lisp/calendar/diary-lib.el	2012-11-27 15:40:49 +0000
--- lisp/calendar/diary-lib.el	2012-12-03 23:48:18 +0000
***************
*** 2461,2469 ****
       ;; string form"; eg the iso version calls string-to-number on some.
       ;; Therefore we cannot eg just let day = "[0-9]+".  (Bug#8583).
       ;; Assumes no integers in c-day/month-name-array.
!      (replace-regexp-in-string "[0-9]+" "[0-9]+"
!                                (mapconcat 'eval calendar-date-display-form "")
!                                nil t))
     ;; Optional ": holiday name" after the date.
     "\\(: .*\\)?"))
  
--- 2461,2478 ----
       ;; string form"; eg the iso version calls string-to-number on some.
       ;; Therefore we cannot eg just let day = "[0-9]+".  (Bug#8583).
       ;; Assumes no integers in c-day/month-name-array.
!      (replace-regexp-in-string
!       "[0-9]+" "[0-9]+"
!       (mapconcat (lambda (x) (if (or (atom x) (eq (car x) 'format))
! 				 (eval x)
! 			       (catch 'end
! 				 (while (consp x)
! 				   (let ((y (pop x)))
! 				     (when (or (eq y 'year) (eq y 'month)
! 					       (eq y 'day))
! 				       (throw 'end (eval y))))))))
! 		 calendar-date-display-form "")
!       nil t))
     ;; Optional ": holiday name" after the date.
     "\\(: .*\\)?"))
  





Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.428 (Entity 5.428)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Stephen Berman <stephen.berman@HIDDEN>
Subject: bug#13072: Acknowledgement (24.3.50; Fancy Diary display
 fontification failures)
Message-ID: <handler.13072.B.135457944523626.ack <at> debbugs.gnu.org>
References: <87k3sybs8k.fsf@HIDDEN>
X-Gnu-PR-Message: ack 13072
X-Gnu-PR-Package: emacs
Reply-To: 13072 <at> debbugs.gnu.org
Date: Tue, 04 Dec 2012 00:05:03 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
 bug-gnu-emacs@HIDDEN

If you wish to submit further information on this problem, please
send it to 13072 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
13072: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D13072
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems



Last modified: Fri, 31 Oct 2014 17:00:04 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.