GNU bug report logs - #18830
gnus-summary-line-format text face

Previous Next

Packages: emacs, gnus;

Reported by: Zhitao Gong <zzg0009 <at> auburn.edu>

Date: Sat, 25 Oct 2014 16:11:04 UTC

Severity: normal

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 18830 in the body.
You can then email your comments to 18830 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bugs <at> gnus.org:
bug#18830; Package gnus. (Sat, 25 Oct 2014 16:11:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Zhitao Gong <zzg0009 <at> auburn.edu>:
New bug report received and forwarded. Copy sent to bugs <at> gnus.org. (Sat, 25 Oct 2014 16:11:07 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Zhitao Gong <zzg0009 <at> auburn.edu>
To: The Gnus Bugfixing Girls + Boys <submit <at> debbugs.gnu.org>
Subject: gnus-summary-line-format text face
Date: Sat, 25 Oct 2014 08:44:05 -0500
I'm setting the date face according to how old the date is with the
following code:

--- code begins ---

(defun header-age-level (header)
  "Return the age of the header

The age are divided into three levels:
0: no more than one day old
1: no more than one week old
2: otherwise

Based on the age of the header, I set different foreground color
for the header string.
"
  (let* ((now (time-to-day-in-year (current-time)))
         (header-date-time
          (time-to-day-in-year (safe-date-to-time
                                (mail-header-date header))))
         (mail-age (- now header-date-time)))
    (cond
     ((< mail-age 1) 0)
     ((< mail-age 7) 1)
     (t 2))))

(defface my-date-one-day-old-face
  '((default (:foreground "#ADFF2F")))
  "...")
(defface my-date-one-week-old-face
  '((default (:foreground "#79B221")))
  "...")
(defface my-date-more-than-one-week-old-face
  '((default (:foreground "#456613")))
  "...")

(defun gnus-user-format-function-color-date (header)
  (let ((header-date-time-string
         (format-time-string
          "%Y-%m-%d %H:%M" (safe-date-to-time (mail-header-date header))))
        (age-level (header-age-level header)))
    (cond
      ((= 0 age-level)
       (propertize header-date-time-string
		   'face 'my-date-one-day-old-face
		   'gnus-face t
                   ))
      ((= 1 age-level)
       (propertize header-date-time-string
		   'face 'my-date-one-week-old-face
		   'gnus-face t))
      (t
       (propertize header-date-time-string
                   'face 'my-date-more-than-one-week-old-face
                   'gnus-face t)))))

(setq-default
 gnus-summary-line-format "%U%R%z %(%u&color-date;  %-30,30f  %B%s%)\n")
                                        ^---- this is my function

--- code ends ---

This works fine in Emacs24, however, when I upgrade to the new version,
emacs-25.x.x, I got the following error (please see the backtrace
information).

I've identified the source of this error

--- code begins ---

(defun gnus-put-text-property-excluding-characters-with-faces (beg end prop val)
  "The same as `put-text-property', except where `gnus-face' is set.
If so, and PROP is `face', set the second element of its value to VAL.
Otherwise, do nothing."
  (while (< beg end)
    ;; Property values are compared with `eq'.
    (let ((stop (next-single-property-change beg 'face nil end)))
      (if (get-text-property beg 'gnus-face)
	  (when (eq prop 'face)
	    (setcar (cdr (get-text-property beg 'face)) (or val  'default)))   ;; <- !!! THIS LINE !!!
	(inline
	  (gnus-put-text-property beg stop prop val)))
      (setq beg stop))))

--- code ends ---

The `(get-text-property beg 'face)` returns a face object, say,
`my-date-one-day-old-face`, which is NOT a list object, so `cdr` throws
the error "wrong-type-argument listp
my-date-more-than-one-week-old-face"

Hope this helps!

The backtrace:

Debugger entered--Lisp error: (wrong-type-argument listp my-date-more-than-one-week-old-face)
  gnus-put-text-property-excluding-characters-with-faces(1 55 face gnus-summary-normal-unread)
  gnus-summary-highlight-line()
  gnus-summary-insert-line([0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil] 0 nil t 90 t nil "" nil 1)
  gnus-update-summary-mark-positions()
  gnus-summary-mode("Tiger/INBOX")
  gnus-summary-setup-buffer("Tiger/INBOX")
  gnus-summary-read-group-1("Tiger/INBOX" t t nil nil nil)
  gnus-summary-read-group("Tiger/INBOX" t t nil nil nil nil)
  gnus-group-read-group(nil t)
  gnus-group-select-group(nil)
  funcall-interactively(gnus-group-select-group nil)
  call-interactively(gnus-group-select-group nil nil)
  command-execute(gnus-group-select-group)

Gnus v5.13
GNU Emacs 25.0.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.12.2)
 of 2014-10-24 on lgw01-26




Information forwarded to bugs <at> gnus.org:
bug#18830; Package gnus. (Sun, 26 Oct 2014 15:01:01 GMT) Full text and rfc822 format available.

Message #8 received at 18830 <at> debbugs.gnu.org (full text, mbox):

From: Wolfgang Jenkner <wjenkner <at> inode.at>
To: Zhitao Gong <zzg0009 <at> auburn.edu>
Cc: 18830 <at> debbugs.gnu.org
Subject: Re: bug#18830: gnus-summary-line-format text face
Date: Sun, 26 Oct 2014 16:00:13 +0100
On Sat, Oct 25 2014, Zhitao Gong wrote:

>       (t
>        (propertize header-date-time-string
>                    'face 'my-date-more-than-one-week-old-face
>                    'gnus-face t)))))
>
> (setq-default
>  gnus-summary-line-format "%U%R%z %(%u&color-date;  %-30,30f  %B%s%)\n")
>                                         ^---- this is my function

A similar case was reported in the thread starting with:

http://permalink.gmane.org/gmane.emacs.gnus.general/82816

Strictly speaking, gnus-face is an undocumented text property for
internal purposes; practically speaking, however, your use case requires
using it in some way.

The thread cited above indicates two possible solutions: 

1) Rewrite your code to mimic how gnus does things now (i.e., replace
   my-date-one-day-old-face as the value of the face text property by,
   e.g., (list 'my-date-one-day-old-face 'default), etc.)
   See also gnus-face-face-function.

or

2) There's a (small, but somewhat ugly) compatibility patch in the last
message in the thread, viz.,

http://permalink.gmane.org/gmane.emacs.gnus.general/82826




Information forwarded to bugs <at> gnus.org:
bug#18830; Package gnus. (Wed, 25 Jan 2017 20:54:02 GMT) Full text and rfc822 format available.

Message #11 received at 18830 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Wolfgang Jenkner <wjenkner <at> inode.at>
Cc: Zhitao Gong <zzg0009 <at> auburn.edu>, 18830 <at> debbugs.gnu.org
Subject: Re: bug#18830: gnus-summary-line-format text face
Date: Wed, 25 Jan 2017 21:44:07 +0100
Wolfgang Jenkner <wjenkner <at> inode.at> writes:

> The thread cited above indicates two possible solutions: 
>
> 1) Rewrite your code to mimic how gnus does things now (i.e., replace
>    my-date-one-day-old-face as the value of the face text property by,
>    e.g., (list 'my-date-one-day-old-face 'default), etc.)
>    See also gnus-face-face-function.

Yes, I think that's the proper solution, so this isn't really a bug, I
think.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug reassigned from package 'gnus' to 'emacs,gnus'. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 25 Jan 2017 20:54:03 GMT) Full text and rfc822 format available.

bug No longer marked as found in versions 5.13. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 25 Jan 2017 20:54:03 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 18830 <at> debbugs.gnu.org and Zhitao Gong <zzg0009 <at> auburn.edu> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 25 Jan 2017 20:54:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 23 Feb 2017 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 196 days ago.

Previous Next


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