Gnus development mailing list
 help / color / mirror / Atom feed
* setting face in gnus-user-format-function-x
@ 2011-05-23 18:04 Peter Münster
  2011-05-24  6:18 ` Reiner Steib
  2011-05-30 18:10 ` Lars Magne Ingebrigtsen
  0 siblings, 2 replies; 26+ messages in thread
From: Peter Münster @ 2011-05-23 18:04 UTC (permalink / raw)
  To: ding

Hello,

I would like to set different faces for some marks in the summary lines.
But unfortunately, when changing the mark, the mark-letter is updated,
but the face is not. Only after reopening the group, the faces get
right.
Here my test setup:

--8<---------------cut here---------------start------------->8---
(defun gnus-user-format-function-x (header)
  (propertize (format "%c" gnus-tmp-unread) 'face
              (if (equal gnus-tmp-unread gnus-ancient-mark)
                  gnus-face-2 gnus-face-3) 'gnus-face t))

(setq gnus-summary-line-format "%ux...")
--8<---------------cut here---------------end--------------->8---

Could anybody help please?

TIA for any hints!

-- 
           Peter




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

* Re: setting face in gnus-user-format-function-x
  2011-05-23 18:04 setting face in gnus-user-format-function-x Peter Münster
@ 2011-05-24  6:18 ` Reiner Steib
  2011-05-25 13:38   ` Peter Münster
  2011-05-30 18:10 ` Lars Magne Ingebrigtsen
  1 sibling, 1 reply; 26+ messages in thread
From: Reiner Steib @ 2011-05-24  6:18 UTC (permalink / raw)
  To: ding

On Mon, May 23 2011, Peter Münster wrote:

> I would like to set different faces for some marks in the summary lines.
> But unfortunately, when changing the mark, the mark-letter is updated,
> but the face is not. Only after reopening the group, the faces get
> right.
> Here my test setup:
>
> (defun gnus-user-format-function-x (header)
>   (propertize (format "%c" gnus-tmp-unread) 'face
>               (if (equal gnus-tmp-unread gnus-ancient-mark)
>                   gnus-face-2 gnus-face-3) 'gnus-face t))
>
> (setq gnus-summary-line-format "%ux...")

Did you try (info "(gnus)Formatting Fonts")?

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/




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

* Re: setting face in gnus-user-format-function-x
  2011-05-24  6:18 ` Reiner Steib
@ 2011-05-25 13:38   ` Peter Münster
  2011-05-26  6:37     ` Reiner Steib
  0 siblings, 1 reply; 26+ messages in thread
From: Peter Münster @ 2011-05-25 13:38 UTC (permalink / raw)
  To: ding

On Tue, May 24 2011, Reiner Steib wrote:

>> Here my test setup:
>>
>> (defun gnus-user-format-function-x (header)
>>   (propertize (format "%c" gnus-tmp-unread) 'face
>>               (if (equal gnus-tmp-unread gnus-ancient-mark)
>>                   gnus-face-2 gnus-face-3) 'gnus-face t))
>>
>> (setq gnus-summary-line-format "%ux...")
>
> Did you try (info "(gnus)Formatting Fonts")?

Yes, but it does not help. This test fails (a literal "%{...%}" is printed):

--8<---------------cut here---------------start------------->8---
(defun gnus-user-format-function-x (header)
   (format "%%%d{%c%%}" (if (equal gnus-tmp-unread gnus-ancient-mark) 2 3)
           gnus-tmp-unread))
--8<---------------cut here---------------end--------------->8---

-- 
           Peter




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

* Re: setting face in gnus-user-format-function-x
  2011-05-25 13:38   ` Peter Münster
@ 2011-05-26  6:37     ` Reiner Steib
  2011-05-27  8:26       ` Peter Münster
  0 siblings, 1 reply; 26+ messages in thread
From: Reiner Steib @ 2011-05-26  6:37 UTC (permalink / raw)
  To: ding

On Wed, May 25 2011, Peter Münster wrote:

> On Tue, May 24 2011, Reiner Steib wrote:
>> Did you try (info "(gnus)Formatting Fonts")?
>
> Yes, but it does not help. This test fails (a literal "%{...%}" is printed):
>
> (defun gnus-user-format-function-x (header)
>    (format "%%%d{%c%%}" (if (equal gnus-tmp-unread gnus-ancient-mark) 2 3)
>            gnus-tmp-unread))

You should use e.g. `%3{' and `%3}' _directly_ in
`gnus-summary-line-format' after defining face `gnus-face-2' with
`defface'.   No need for a user-format-function.

[ Re-reading you goal... Hm, maybe this is not sufficient for you. ]

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/




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

* Re: setting face in gnus-user-format-function-x
  2011-05-26  6:37     ` Reiner Steib
@ 2011-05-27  8:26       ` Peter Münster
  2011-05-27  9:44         ` Michael Piotrowski
  0 siblings, 1 reply; 26+ messages in thread
From: Peter Münster @ 2011-05-27  8:26 UTC (permalink / raw)
  To: ding

On Thu, May 26 2011, Reiner Steib wrote:

>> (defun gnus-user-format-function-x (header)
>>    (format "%%%d{%c%%}" (if (equal gnus-tmp-unread gnus-ancient-mark) 2 3)
>>            gnus-tmp-unread))
>
> You should use e.g. `%3{' and `%3}' _directly_ in
> `gnus-summary-line-format' after defining face `gnus-face-2' with
> `defface'.   No need for a user-format-function.
>
> [ Re-reading you goal... Hm, maybe this is not sufficient for you. ]

Indeed. I need something like "if" or "cond". Different faces for
different marks.

-- 
           Peter




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

* Re: setting face in gnus-user-format-function-x
  2011-05-27  8:26       ` Peter Münster
@ 2011-05-27  9:44         ` Michael Piotrowski
  0 siblings, 0 replies; 26+ messages in thread
From: Michael Piotrowski @ 2011-05-27  9:44 UTC (permalink / raw)
  To: ding

On 2011-05-27, pmlists@free.fr (Peter Münster) wrote:

> On Thu, May 26 2011, Reiner Steib wrote:
>
>> You should use e.g. `%3{' and `%3}' _directly_ in
>> `gnus-summary-line-format' after defining face `gnus-face-2' with
>> `defface'.   No need for a user-format-function.
>> 
>> [ Re-reading you goal... Hm, maybe this is not sufficient for you. ]
>
> Indeed. I need something like "if" or "cond". Different faces for
> different marks.

I just ran into the same problem: I'm in the process of migrating my
Gnus setup from XEmacs to FSF Emacs (as it seems unlikely that the
XEmacs-related problems will be fixed) and I have a similar user format
function.  It works fine on XEmacs using extents, e.g.,

--8<---------------cut here---------------start------------->8---
    ...
    (cond
     ((= message-day today)
      (setq my-ext (make-extent 0 10 message-date))
      (set-extent-property my-ext 'duplicable t)
      (set-extent-face my-ext 'mxp-gnus-summary-today-face))
    ...
--8<---------------cut here---------------end--------------->8---

For FSF Emacs, I changed it to use text properties, but, as Peter noted,
it seems that the face property is overwritten (other properties are
preserved).

Greetings

-- 
Dr.-Ing. Michael Piotrowski, M.A.                   <mxp@dynalabs.de>
Public key at <http://www.dynalabs.de/mxp/pubkey.txt> (ID 0x1614A044)




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

* Re: setting face in gnus-user-format-function-x
  2011-05-23 18:04 setting face in gnus-user-format-function-x Peter Münster
  2011-05-24  6:18 ` Reiner Steib
@ 2011-05-30 18:10 ` Lars Magne Ingebrigtsen
  2011-05-31  7:06   ` Peter Münster
  2011-07-18 21:09   ` special face for marks (was: setting face in gnus-user-format-function-x) Peter Münster
  1 sibling, 2 replies; 26+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-05-30 18:10 UTC (permalink / raw)
  To: ding

pmlists@free.fr (Peter Münster) writes:

> I would like to set different faces for some marks in the summary lines.
> But unfortunately, when changing the mark, the mark-letter is updated,
> but the face is not. Only after reopening the group, the faces get
> right.

I think your best bet would be to put a function into
`gnus-summary-update-hook', possibly calling
`gnus-summary-update-article-line' to delete the line and reinsert it.

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




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

* Re: setting face in gnus-user-format-function-x
  2011-05-30 18:10 ` Lars Magne Ingebrigtsen
@ 2011-05-31  7:06   ` Peter Münster
  2011-06-07 16:24     ` Michael Piotrowski
  2011-07-18 21:09   ` special face for marks (was: setting face in gnus-user-format-function-x) Peter Münster
  1 sibling, 1 reply; 26+ messages in thread
From: Peter Münster @ 2011-05-31  7:06 UTC (permalink / raw)
  To: ding

On Mon, May 30 2011, Lars Magne Ingebrigtsen wrote:

> pmlists@free.fr (Peter Münster) writes:
>
>> I would like to set different faces for some marks in the summary lines.
>> But unfortunately, when changing the mark, the mark-letter is updated,
>> but the face is not. Only after reopening the group, the faces get
>> right.
>
> I think your best bet would be to put a function into
> `gnus-summary-update-hook', possibly calling
> `gnus-summary-update-article-line' to delete the line and reinsert it.

Oh, no chance for an easier solution...? :(
Ok, one day, I'll try it.

-- 
           Peter




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

* Re: setting face in gnus-user-format-function-x
  2011-05-31  7:06   ` Peter Münster
@ 2011-06-07 16:24     ` Michael Piotrowski
  2011-06-23  8:47       ` Peter Münster
  0 siblings, 1 reply; 26+ messages in thread
From: Michael Piotrowski @ 2011-06-07 16:24 UTC (permalink / raw)
  To: ding

On 2011-05-31, pmlists@free.fr (Peter Münster) wrote:

>>> I would like to set different faces for some marks in the summary lines.
>>> But unfortunately, when changing the mark, the mark-letter is updated,
>>> but the face is not. Only after reopening the group, the faces get
>>> right.
>> 
>> I think your best bet would be to put a function into
>> `gnus-summary-update-hook', possibly calling
>> `gnus-summary-update-article-line' to delete the line and reinsert it.
>
> Oh, no chance for an easier solution...? :(
> Ok, one day, I'll try it.

I just tried it.  Using `gnus-summary-update-hook' works.  For my
application--a different face for the date, depending on the age of the
message--I used the following two-step approach:

1. I have a user format function that adds a non-face property, roughly
   something like this:

    (cond
     ((= message-day today)
      (put-text-property 0 10 'mxp-date 'today message-date))
     ((= message-day (1- today))
      (put-text-property 0 10 'mxp-date 'yesterday message-date))
     (t
      (put-text-property 0 10 'mxp-date 'older message-date)))

2. I have a function that looks for this property (using
   `gnus-find-text-property-region') and sets the desired face.  This
   function is called by `gnus-summary-update-hook'.

Up to now, this approach seems to work nicely.  Maybe you can adapt it
to your needs.

Greetings

-- 
Dr.-Ing. Michael Piotrowski, M.A.                   <mxp@dynalabs.de>
Public key at <http://www.dynalabs.de/mxp/pubkey.txt> (ID 0x1614A044)




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

* Re: setting face in gnus-user-format-function-x
  2011-06-07 16:24     ` Michael Piotrowski
@ 2011-06-23  8:47       ` Peter Münster
  2011-06-26 10:06         ` Lars Magne Ingebrigtsen
  2011-07-11 16:57         ` setting face in gnus-user-format-function-x Michael Piotrowski
  0 siblings, 2 replies; 26+ messages in thread
From: Peter Münster @ 2011-06-23  8:47 UTC (permalink / raw)
  To: ding

On Tue, Jun 07 2011, Michael Piotrowski wrote:

> I just tried it.  Using `gnus-summary-update-hook' works.  For my
> application--a different face for the date, depending on the age of the
> message--I used the following two-step approach:
>
> 1. I have a user format function that adds a non-face property, roughly
>    something like this:
>
>     (cond
>      ((= message-day today)
>       (put-text-property 0 10 'mxp-date 'today message-date))
>      ((= message-day (1- today))
>       (put-text-property 0 10 'mxp-date 'yesterday message-date))
>      (t
>       (put-text-property 0 10 'mxp-date 'older message-date)))
>
> 2. I have a function that looks for this property (using
>    `gnus-find-text-property-region') and sets the desired face.  This
>    function is called by `gnus-summary-update-hook'.
>
> Up to now, this approach seems to work nicely.  Maybe you can adapt it
> to your needs.

Unfortunately no success... :(

This is, what I have now:

--8<---------------cut here---------------start------------->8---
(defun gnus-user-format-function-x (header)
  (let ((my-string (format "%c" gnus-tmp-unread)))
    (put-text-property 0 0 'my-test 'my-test my-string)
    my-string))

(defun my-summary-update ()
  (dolist (region (gnus-find-text-property-region (point-min)
                                                  (point-max)
                                                  'my-test))
    (destructuring-bind (start end function) region
      (put-text-property start end 'face gnus-face-2)
      (put-text-property start end 'gnus-face t))))

(add-hook 'gnus-summary-update-hook 'my-summary-update)
--8<---------------cut here---------------end--------------->8---

But the face is not set.

I've also tried Lars' suggestion to use
gnus-summary-update-article-line, but I don't know how to supply the
2 required arguments "article" and "header".

So, any help would be appreciated!
(sorry for my lack of elisp-experience)

Greetings,
-- 
           Peter




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

* Re: setting face in gnus-user-format-function-x
  2011-06-23  8:47       ` Peter Münster
@ 2011-06-26 10:06         ` Lars Magne Ingebrigtsen
  2011-06-27 12:46           ` Peter Münster
  2011-07-11 16:57         ` setting face in gnus-user-format-function-x Michael Piotrowski
  1 sibling, 1 reply; 26+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-06-26 10:06 UTC (permalink / raw)
  To: ding

pmlists@free.fr (Peter Münster) writes:

> I've also tried Lars' suggestion to use
> gnus-summary-update-article-line, but I don't know how to supply the
> 2 required arguments "article" and "header".

(gnus-summary-article-number) and (gnus-summary-article-header) would do
the trick, I think.

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




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

* Re: setting face in gnus-user-format-function-x
  2011-06-26 10:06         ` Lars Magne Ingebrigtsen
@ 2011-06-27 12:46           ` Peter Münster
  2011-06-30  2:23             ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 26+ messages in thread
From: Peter Münster @ 2011-06-27 12:46 UTC (permalink / raw)
  To: ding

On Sun, Jun 26 2011, Lars Magne Ingebrigtsen wrote:

> pmlists@free.fr (Peter Münster) writes:
>
>> I've also tried Lars' suggestion to use
>> gnus-summary-update-article-line, but I don't know how to supply the
>> 2 required arguments "article" and "header".
>
> (gnus-summary-article-number) and (gnus-summary-article-header) would do
> the trick, I think.

Thanks! But unfortunately, I still don't get updated read-marks. This is,
what I have now:

--8<---------------cut here---------------start------------->8---
(setq gnus-summary-update-hook '(my-summary-update))

(defun my-summary-update ()
  (setq gnus-summary-update-hook nil) ; there seems to be some recursion...
  (gnus-summary-update-article-line
   (gnus-summary-article-number)
   (gnus-summary-article-header (gnus-summary-article-number)))
  (setq gnus-summary-update-hook '(my-summary-update)))

(defun gnus-user-format-function-x (header)
  (propertize (format "%c" gnus-tmp-unread) 'face
              (if (equal gnus-tmp-unread gnus-ancient-mark)
                  gnus-face-2 gnus-face-3) 'gnus-face t))

(setq gnus-summary-line-format
      "%ux%R%3P %-10&user-date; %-17,17f(%4k)%* %B%s\n")
--8<---------------cut here---------------end--------------->8---

I would be glad about any further hints!

TIA,
-- 
           Peter




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

* Re: setting face in gnus-user-format-function-x
  2011-06-27 12:46           ` Peter Münster
@ 2011-06-30  2:23             ` Lars Magne Ingebrigtsen
  2011-06-30  5:14               ` Peter Münster
  0 siblings, 1 reply; 26+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-06-30  2:23 UTC (permalink / raw)
  To: ding

pmlists@free.fr (Peter Münster) writes:

> (defun my-summary-update ()
>   (setq gnus-summary-update-hook nil) ; there seems to be some recursion...
>   (gnus-summary-update-article-line
>    (gnus-summary-article-number)
>    (gnus-summary-article-header (gnus-summary-article-number)))
>   (setq gnus-summary-update-hook '(my-summary-update)))

Set the hook outside the function definition.

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




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

* Re: setting face in gnus-user-format-function-x
  2011-06-30  2:23             ` Lars Magne Ingebrigtsen
@ 2011-06-30  5:14               ` Peter Münster
  2011-06-30 22:03                 ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 26+ messages in thread
From: Peter Münster @ 2011-06-30  5:14 UTC (permalink / raw)
  To: ding

On Thu, Jun 30 2011, Lars Magne Ingebrigtsen wrote:

> pmlists@free.fr (Peter Münster) writes:
>
>> (defun my-summary-update ()
>>   (setq gnus-summary-update-hook nil) ; there seems to be some recursion...
>>   (gnus-summary-update-article-line
>>    (gnus-summary-article-number)
>>    (gnus-summary-article-header (gnus-summary-article-number)))
>>   (setq gnus-summary-update-hook '(my-summary-update)))
>
> Set the hook outside the function definition.

But that's what I've done (see previous message).

-- 
           Peter




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

* Re: setting face in gnus-user-format-function-x
  2011-06-30  5:14               ` Peter Münster
@ 2011-06-30 22:03                 ` Lars Magne Ingebrigtsen
  2011-07-13  9:15                   ` setting face in gnus-user-format-function-x (solved) Peter Münster
  0 siblings, 1 reply; 26+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-06-30 22:03 UTC (permalink / raw)
  To: ding

pmlists@free.fr (Peter Münster) writes:

>>> (defun my-summary-update ()
>>>   (setq gnus-summary-update-hook nil) ; there seems to be some recursion...
>>>   (gnus-summary-update-article-line
>>>    (gnus-summary-article-number)
>>>    (gnus-summary-article-header (gnus-summary-article-number)))
>>>   (setq gnus-summary-update-hook '(my-summary-update)))
>>
>> Set the hook outside the function definition.
>
> But that's what I've done (see previous message).

Oh, right.  The recursion thingie.

Uhm...  try edebugging through `gnus-summary-update-article-line' and
see what happens.  :-)

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




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

* Re: setting face in gnus-user-format-function-x
  2011-06-23  8:47       ` Peter Münster
  2011-06-26 10:06         ` Lars Magne Ingebrigtsen
@ 2011-07-11 16:57         ` Michael Piotrowski
  2011-07-13  7:36           ` Peter Münster
  1 sibling, 1 reply; 26+ messages in thread
From: Michael Piotrowski @ 2011-07-11 16:57 UTC (permalink / raw)
  To: ding

On 2011-06-23, pmlists@free.fr (Peter Münster) wrote:

> On Tue, Jun 07 2011, Michael Piotrowski wrote:
>
>> I just tried it.  Using `gnus-summary-update-hook' works.  For my
>> application--a different face for the date, depending on the age of the
>> message--I used the following two-step approach:
>> 
>> 1. I have a user format function that adds a non-face property, roughly
>>    something like this:
>> 
>>     (cond
>>      ((= message-day today)
>>       (put-text-property 0 10 'mxp-date 'today message-date))
>>      ((= message-day (1- today))
>>       (put-text-property 0 10 'mxp-date 'yesterday message-date))
>>      (t
>>       (put-text-property 0 10 'mxp-date 'older message-date)))
>> 
>> 2. I have a function that looks for this property (using
>>    `gnus-find-text-property-region') and sets the desired face.  This
>>    function is called by `gnus-summary-update-hook'.
>> 
>> Up to now, this approach seems to work nicely.  Maybe you can adapt it
>> to your needs.
>
> Unfortunately no success... :(
>
> This is, what I have now:
>
> (defun gnus-user-format-function-x (header)
>   (let ((my-string (format "%c" gnus-tmp-unread)))
>     (put-text-property 0 0 'my-test 'my-test my-string)
>     my-string))
>
> (defun my-summary-update ()
>   (dolist (region (gnus-find-text-property-region (point-min)
>                                                   (point-max)
>                                                   'my-test))
>     (destructuring-bind (start end function) region
>       (put-text-property start end 'face gnus-face-2)
>       (put-text-property start end 'gnus-face t))))
>
> (add-hook 'gnus-summary-update-hook 'my-summary-update)
>
> But the face is not set.

I found I needed to set `inhibit-read-only' to t; in any case, here are
my functions in full:

--8<---------------cut here---------------start------------->8---
(defun gnus-user-format-function-y (header)
  "Format the message date with different faces, depending on how old the
message is."
  (let* ((message-time (gnus-date-get-time (mail-header-date header)))
	 (message-date
	  (format-time-string "%Y-%m-%d" message-time))
	 (message-day
	  (string-to-number (format-time-string "%y%j" message-time)))
	 (today
	  (string-to-number (format-time-string "%y%j" (current-time)))))
    (cond
     ((= message-day today)
      (put-text-property 0 10 'mxp-date 'today message-date))
     ((= message-day (1- today))
      (put-text-property 0 10 'mxp-date 'yesterday message-date))
     (t
      (put-text-property 0 10 'mxp-date 'older message-date)))
    message-date))

(defun mxp-gnus-fontify-summary-line ()
  (save-excursion
    (let* ((inhibit-read-only t)
	   (date-region (gnus-find-text-property-region
			 (point-at-bol)
			 (point-at-eol) 'mxp-date))
	   (start (caar date-region))
	   (end   (cadar date-region)))
      (when (and start end (gnus-visual-p 'summary-highlight 'highlight))
	(cond
	 ((eq (caddar date-region) 'today)
	  (gnus-put-text-property start end 'face 'mxp-gnus-summary-today-face))
	 ((eq (caddar date-region) 'yesterday)
	  (gnus-put-text-property start end 'face
				  'mxp-gnus-summary-yesterday-face))
	 (t
	  (gnus-put-text-property start end 'face 'mxp-gnus-summary-older-face)))
	))))

(add-hook 'gnus-summary-update-hook 'mxp-gnus-fontify-summary-line)
--8<---------------cut here---------------end--------------->8---

Hope this helps

-- 
Dr.-Ing. Michael Piotrowski, M.A.                   <mxp@dynalabs.de>
Public key at <http://www.dynalabs.de/mxp/pubkey.txt> (ID 0x1614A044)




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

* Re: setting face in gnus-user-format-function-x
  2011-07-11 16:57         ` setting face in gnus-user-format-function-x Michael Piotrowski
@ 2011-07-13  7:36           ` Peter Münster
  0 siblings, 0 replies; 26+ messages in thread
From: Peter Münster @ 2011-07-13  7:36 UTC (permalink / raw)
  To: ding

On Mon, Jul 11 2011, Michael Piotrowski wrote:

> I found I needed to set `inhibit-read-only' to t; in any case, here are
> my functions in full:
>
> [...]
>
> Hope this helps

Yes and no: the face is set, but not updated. Could you please try this,
and tell me, if it works for you:

--8<---------------cut here---------------start------------->8---
(setq gnus-summary-line-format
      "%ux%R%3P %-10&user-date; %-17,17f(%4k)%* %B%s\n")

(defun gnus-user-format-function-x (header)
  (let* ((mark gnus-tmp-unread)
         (str (format "%c" mark)))
    (cond
     ((equal mark gnus-ancient-mark)
      (put-text-property 0 1 'my-prop 'read str))
     (t
      (put-text-property 0 1 'my-prop 'unread str)))
    str))

(defun my-gnus-fontify-summary-line ()
  (save-excursion
    (let* ((inhibit-read-only t)
           (my-region (gnus-find-text-property-region
                         (point-at-bol)
                         (point-at-eol) 'my-prop))
           (start (caar my-region))
           (end   (cadar my-region)))
      (cond
       ((eq (caddar my-region) 'unread)
        (gnus-put-text-property start end 'face gnus-face-2))
       (t
        (gnus-put-text-property start end 'face gnus-face-3))))))

(add-hook 'gnus-summary-update-hook 'my-gnus-fontify-summary-line)
--8<---------------cut here---------------end--------------->8---

Nevertheless, thanks for you efforts!

-- 
           Peter




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

* Re: setting face in gnus-user-format-function-x (solved)
  2011-06-30 22:03                 ` Lars Magne Ingebrigtsen
@ 2011-07-13  9:15                   ` Peter Münster
  2011-07-13 11:35                     ` Peter Münster
  2011-07-14  8:12                     ` Peter Münster
  0 siblings, 2 replies; 26+ messages in thread
From: Peter Münster @ 2011-07-13  9:15 UTC (permalink / raw)
  To: ding

On Fri, Jul 01 2011, Lars Magne Ingebrigtsen wrote:

> Uhm...  try edebugging through `gnus-summary-update-article-line' and
> see what happens.  :-)

Ok, it seems, that `gnus-summary-update-article-line' should only be
called, when the summary buffer has already been prepared. So I have to
avoid calling `my-summary-update' when creating a new summary buffer.

This works for me now:

--8<---------------cut here---------------start------------->8---
(defun my-summary-prepared ()
  (setq gnus-summary-update-hook '(my-summary-update)))

(defun my-summary-exit ()
  (setq gnus-summary-update-hook nil))

(defun my-summary-update ()
  (my-summary-exit)
  (gnus-summary-update-article-line
   (gnus-summary-article-number)
   (gnus-summary-article-header (gnus-summary-article-number)))
  (my-summary-prepared))

(defun gnus-user-format-function-x (header)
  (propertize (format "%c" gnus-tmp-unread) 'face
              (if (equal gnus-tmp-unread gnus-ancient-mark)
                  gnus-face-2 gnus-face-3) 'gnus-face t))

(setq gnus-summary-prepared-hook '(my-summary-prepared))
(setq gnus-summary-exit-hook '(my-summary-exit))

(setq gnus-summary-line-format
      "%ux%R%3P %-10&user-date; %-17,17f(%4k)%* %B%s\n")
--8<---------------cut here---------------end--------------->8---

What do you think? Any suggestions for doing this better?

Cheers,
-- 
           Peter




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

* Re: setting face in gnus-user-format-function-x (solved)
  2011-07-13  9:15                   ` setting face in gnus-user-format-function-x (solved) Peter Münster
@ 2011-07-13 11:35                     ` Peter Münster
  2011-07-14  8:12                     ` Peter Münster
  1 sibling, 0 replies; 26+ messages in thread
From: Peter Münster @ 2011-07-13 11:35 UTC (permalink / raw)
  To: ding

On Wed, Jul 13 2011, Peter Münster wrote:

> This works for me now:
>
> [..]
>
> (setq gnus-summary-line-format
>       "%ux%R%3P %-10&user-date; %-17,17f(%4k)%* %B%s\n")

The update-hook breaks the "%P"... :(
So I added this little patch:

--8<---------------cut here---------------start------------->8---
(defun gnus-pick-line-number ()
  "Return the current line number."
  (line-number-at-pos))
--8<---------------cut here---------------end--------------->8---

-- 
           Peter




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

* Re: setting face in gnus-user-format-function-x (solved)
  2011-07-13  9:15                   ` setting face in gnus-user-format-function-x (solved) Peter Münster
  2011-07-13 11:35                     ` Peter Münster
@ 2011-07-14  8:12                     ` Peter Münster
  2011-07-14 19:09                       ` Reiner Steib
  1 sibling, 1 reply; 26+ messages in thread
From: Peter Münster @ 2011-07-14  8:12 UTC (permalink / raw)
  To: ding

On Wed, Jul 13 2011, Peter Münster wrote:

> This works for me now:
>
> [...]
>
> (defun my-summary-update ()
>   (my-summary-exit)
>   (gnus-summary-update-article-line
>    (gnus-summary-article-number)
>    (gnus-summary-article-header (gnus-summary-article-number)))
    (previous-line)
>   (my-summary-prepared))

The side effect of gnus-summary-update-article-line is, that it jumps to
the next line. So I add a "(previous-line)" just after this.

-- 
           Peter




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

* Re: setting face in gnus-user-format-function-x (solved)
  2011-07-14  8:12                     ` Peter Münster
@ 2011-07-14 19:09                       ` Reiner Steib
  0 siblings, 0 replies; 26+ messages in thread
From: Reiner Steib @ 2011-07-14 19:09 UTC (permalink / raw)
  To: ding

On Thu, Jul 14 2011, Peter Münster wrote:

> The side effect of gnus-summary-update-article-line is, that it jumps to
> the next line. So I add a "(previous-line)" just after this.

Maybe better use `save-excursion' around it.

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/




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

* special face for marks (was: setting face in gnus-user-format-function-x)
  2011-05-30 18:10 ` Lars Magne Ingebrigtsen
  2011-05-31  7:06   ` Peter Münster
@ 2011-07-18 21:09   ` Peter Münster
  2011-07-19 10:09     ` special face for marks lee
  1 sibling, 1 reply; 26+ messages in thread
From: Peter Münster @ 2011-07-18 21:09 UTC (permalink / raw)
  To: ding

On Mon, May 30 2011, Lars Magne Ingebrigtsen wrote:

> pmlists@free.fr (Peter Münster) writes:
>
>> I would like to set different faces for some marks in the summary lines.
>> But unfortunately, when changing the mark, the mark-letter is updated,
>> but the face is not. Only after reopening the group, the faces get
>> right.
>
> I think your best bet would be to put a function into
> `gnus-summary-update-hook', possibly calling
> `gnus-summary-update-article-line' to delete the line and reinsert it.

Unfortunately, there were too many side effects, when calling
gnus-summary-update-article-line:
- %P (line number) broken
- %B (thread symbols) vanished
- strange behaviour when dummy-lines are present
- perhaps more...

But today I've found a solution, that works quite well. Perhaps you
could add something like that to Gnus.
My motivation: various faces for different states are nice, but when the
faces are set for the whole lines, it can disturb the eyes. Setting the
face just for the mark can look better. Pine/Alpine does it like that,
and I liked it.

So, here the solution, that works for me:

--8<---------------cut here---------------start------------->8---
(setq gnus-summary-highlight-mark
      '(gnus-ticked-mark        gnus-ticked-mark-face
        gnus-unseen-mark        gnus-new-mark-face
        gnus-unread-mark        gnus-new-mark-face
        gnus-read-mark          gnus-read-mark-face
        gnus-killed-mark        gnus-del-mark-face
        gnus-expirable-mark     gnus-del-mark-face
        gnus-replied-mark       gnus-replied-mark-face
        gnus-forwarded-mark     gnus-replied-mark-face
        gnus-recent-mark        gnus-new-mark-face
        gnus-ancient-mark       gnus-read-mark-face
        gnus-dormant-mark       gnus-ticked-mark-face))

(defun my-mark-face (chr)
  (let ((face 'gnus-unknown-mark-face)
        (list gnus-summary-highlight-mark))
    (while list
      (if (equal (symbol-value (car list)) chr)
          (setq face (cadr list)
                list nil)
        (setq list (cddr list))))
    face))

(defun my-summary-update ()
  (save-excursion
    (beginning-of-line) ; because here is the mark!
    (let* ((inhibit-read-only t)
           (pt (point))
           (chr (char-after pt)))
      (put-text-property pt (1+ pt)
                         'face (my-mark-face chr)))))

(add-hook 'gnus-summary-update-hook 'my-summary-update)
--8<---------------cut here---------------end--------------->8---

-- 
           Peter




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

* Re: special face for marks
  2011-07-18 21:09   ` special face for marks (was: setting face in gnus-user-format-function-x) Peter Münster
@ 2011-07-19 10:09     ` lee
  2011-07-19 10:58       ` Peter Münster
  0 siblings, 1 reply; 26+ messages in thread
From: lee @ 2011-07-19 10:09 UTC (permalink / raw)
  To: ding

pmlists@free.fr (Peter Münster) writes:

> (setq gnus-summary-highlight-mark
>       '(gnus-ticked-mark        gnus-ticked-mark-face
>         gnus-unseen-mark        gnus-new-mark-face
>         gnus-unread-mark        gnus-new-mark-face
>         gnus-read-mark          gnus-read-mark-face
>         gnus-killed-mark        gnus-del-mark-face
>         gnus-expirable-mark     gnus-del-mark-face
>         gnus-replied-mark       gnus-replied-mark-face
>         gnus-forwarded-mark     gnus-replied-mark-face
>         gnus-recent-mark        gnus-new-mark-face
>         gnus-ancient-mark       gnus-read-mark-face
>         gnus-dormant-mark       gnus-ticked-mark-face))

Do you have any idea how to get gnus to display these marks?  Accessing
them in a user-format-function doesn't seem to be possible.



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

* Re: special face for marks
  2011-07-19 10:09     ` special face for marks lee
@ 2011-07-19 10:58       ` Peter Münster
  2011-07-19 17:51         ` lee
  0 siblings, 1 reply; 26+ messages in thread
From: Peter Münster @ 2011-07-19 10:58 UTC (permalink / raw)
  To: ding

On Tue, Jul 19 2011, lee wrote:

> Do you have any idea how to get gnus to display these marks?

Yes. With "%U" in the `gnus-summary-line-format'.
My setting:

(setq gnus-summary-line-format
      "%U%R%3P %-10&user-date; %-17,17f(%4k)%* %B%s\n")


> Accessing them in a user-format-function doesn't seem to be possible.

It's possible with the variable `gnus-tmp-unread'

-- 
           Peter




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

* Re: special face for marks
  2011-07-19 10:58       ` Peter Münster
@ 2011-07-19 17:51         ` lee
  2011-09-29  9:41           ` Ted Zlatanov
  0 siblings, 1 reply; 26+ messages in thread
From: lee @ 2011-07-19 17:51 UTC (permalink / raw)
  To: ding

pmlists@free.fr (Peter Münster) writes:

> On Tue, Jul 19 2011, lee wrote:
>
>> Do you have any idea how to get gnus to display these marks?
>
> Yes. With "%U" in the `gnus-summary-line-format'.
> My setting:
>
> (setq gnus-summary-line-format
>       "%U%R%3P %-10&user-date; %-17,17f(%4k)%* %B%s\n")
>
>
>> Accessing them in a user-format-function doesn't seem to be possible.
>
> It's possible with the variable `gnus-tmp-unread'

Oh, I mean /all/ available marks.  Gnus seems to store them, and I would
like to be able to see all the marks of articles in the summary.  With
the available format specifiers, I cannot see what marks articles
actually have, with a few exceptions.  There are at least 10 different
marks for read articles, and gnus only displays either `O' or `E' with
the "%U" specifier.

I've tried to get the marks displayed with a
`gnus-user-format-function-*', and it worked only for one or two of the
marks.  When you try something like this with an "%uM" specifier in
`gnus-summary-line-format', it doesn't work:


(defun gnus-user-format-function-M (header)
  (let ( (str "|") )
    (if (equal gnus-tmp-unread gnus-unread-mark)
	(setq str (concat str "U") )  )
    (if (equal gnus-tmp-read gnus-read-mark)
	(setq str (concat str "R") )  )
    (if (equal gnus-tmp-del gnus-del-mark)
	(setq str (concat "d" str) )  )
    (if (equal gnus-tmp-read gnus-read-mark)
    	(setq str (concat "R" str) )  )
    (if (equal gnus-tmp-ancient gnus-ancient-mark)
    	(setq str (concat "O" str) )  )
    (if (equal gnus-tmp-killed gnus-killed-mark)
    	(setq str (concat "K" str) )  )
    (if (equal gnus-tmp-kill-file gnus-kill-file-mark)
    	(setq str (concat "X" str) )  )
    (if (equal gnus-tmp-low-score gnus-low-score-mark)
    	(setq str (concat "Y" str) )  )
    (if (equal gnus-tmp-catchup gnus-catchup-mark)
    	(setq str (concat "C" str) )  )
    (if (equal gnus-tmp-cancled gnus-cancled-mark)
    	(setq str (concat "G" str) )  )
    (if (equal gnus-tmp-sparse gnus-sparse-mark)
    	(setq str (concat "Q" str) )  )
    (if (equal gnus-tmp-duplicate gnus-duplicate-mark)
	(setq str (concat "M" str) )  )
    (if (equal gnus-tmp-expirable gnus-expirable-mark)
	(setq str (concat "E" str) )  )
    )
  )


Perhaps the variables for the marks aren't set when the function is
called?  They aren't given in the header, either.



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

* Re: special face for marks
  2011-07-19 17:51         ` lee
@ 2011-09-29  9:41           ` Ted Zlatanov
  0 siblings, 0 replies; 26+ messages in thread
From: Ted Zlatanov @ 2011-09-29  9:41 UTC (permalink / raw)
  To: ding

On Tue, 19 Jul 2011 19:51:51 +0200 lee <lee@yun.yagibdah.de> wrote: 

l> (defun gnus-user-format-function-M (header)
l>   (let ( (str "|") )
l>     (if (equal gnus-tmp-unread gnus-unread-mark)
l> 	(setq str (concat str "U") )  )
l>     (if (equal gnus-tmp-read gnus-read-mark)
l> 	(setq str (concat str "R") )  )
l>     (if (equal gnus-tmp-del gnus-del-mark)
l> 	(setq str (concat "d" str) )  )
l>     (if (equal gnus-tmp-read gnus-read-mark)
l>     	(setq str (concat "R" str) )  )
l>     (if (equal gnus-tmp-ancient gnus-ancient-mark)
l>     	(setq str (concat "O" str) )  )
l>     (if (equal gnus-tmp-killed gnus-killed-mark)
l>     	(setq str (concat "K" str) )  )
l>     (if (equal gnus-tmp-kill-file gnus-kill-file-mark)
l>     	(setq str (concat "X" str) )  )
l>     (if (equal gnus-tmp-low-score gnus-low-score-mark)
l>     	(setq str (concat "Y" str) )  )
l>     (if (equal gnus-tmp-catchup gnus-catchup-mark)
l>     	(setq str (concat "C" str) )  )
l>     (if (equal gnus-tmp-cancled gnus-cancled-mark)
l>     	(setq str (concat "G" str) )  )
l>     (if (equal gnus-tmp-sparse gnus-sparse-mark)
l>     	(setq str (concat "Q" str) )  )
l>     (if (equal gnus-tmp-duplicate gnus-duplicate-mark)
l> 	(setq str (concat "M" str) )  )
l>     (if (equal gnus-tmp-expirable gnus-expirable-mark)
l> 	(setq str (concat "E" str) )  )
l>     )
l>   )

Without commenting on the marks themselves, just a note on the Lisp: it
may be cleaner to write it like this:

#+begin_src lisp
(defun gnus-user-format-function-M (header)
  (concat "|"
          (mapconcat (lambda (mark-info)
                       (let* ((s (car mark-info))
                              (tmp (intern (format "gnus-tmp-%s" s)))
                              (mark (intern (format "gnus-%s-mark") s)))
                         (when (equal (symbol-value tmp)
                                      (symbol-value mark))
                           (cdr mark-info))))
                     '((unread . "U")
                       (read . "R")
                       ;; ... the rest
                       )
                     "")))

#+end_src

I'm sure there's better ways but at least the repetition should be avoided.

Ted




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

end of thread, other threads:[~2011-09-29  9:41 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-23 18:04 setting face in gnus-user-format-function-x Peter Münster
2011-05-24  6:18 ` Reiner Steib
2011-05-25 13:38   ` Peter Münster
2011-05-26  6:37     ` Reiner Steib
2011-05-27  8:26       ` Peter Münster
2011-05-27  9:44         ` Michael Piotrowski
2011-05-30 18:10 ` Lars Magne Ingebrigtsen
2011-05-31  7:06   ` Peter Münster
2011-06-07 16:24     ` Michael Piotrowski
2011-06-23  8:47       ` Peter Münster
2011-06-26 10:06         ` Lars Magne Ingebrigtsen
2011-06-27 12:46           ` Peter Münster
2011-06-30  2:23             ` Lars Magne Ingebrigtsen
2011-06-30  5:14               ` Peter Münster
2011-06-30 22:03                 ` Lars Magne Ingebrigtsen
2011-07-13  9:15                   ` setting face in gnus-user-format-function-x (solved) Peter Münster
2011-07-13 11:35                     ` Peter Münster
2011-07-14  8:12                     ` Peter Münster
2011-07-14 19:09                       ` Reiner Steib
2011-07-11 16:57         ` setting face in gnus-user-format-function-x Michael Piotrowski
2011-07-13  7:36           ` Peter Münster
2011-07-18 21:09   ` special face for marks (was: setting face in gnus-user-format-function-x) Peter Münster
2011-07-19 10:09     ` special face for marks lee
2011-07-19 10:58       ` Peter Münster
2011-07-19 17:51         ` lee
2011-09-29  9:41           ` Ted Zlatanov

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 NNTP newsgroup(s).