[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New articles since last viewing via gnus-group-line-format?

From: Dmitry Alexandrov
Subject: Re: New articles since last viewing via gnus-group-line-format?
Date: Thu, 30 Jun 2016 19:33:40 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

John Magolske <> writes:

> Think I found a solution to this...
> John Magolske <> writes:
>> I'd like to have a mark show up next to each group in the Gnus group
>> buffer to signify whether or not new articles have arrived since the
>> last viewing of that group (similar to Mutt's "N if folder has new
>> mail, blank otherwise"). I see there's %m in gnus-group-line-format:
>>     %m  Whether there is new(ish) mail in the group (char, "%")
>> which should place by default a %, or other character as defined by the
>> gnus-new-mail-mark variable. So I put a %m in my gnus-group-line-format:
>>     (setq gnus-group-line-format "%P%m %M%S%p%5,5y/%-5,5t 
>> :%*%B%-60,60ug%ud\n")
>> ..but I'm not seeing the % mark in the group buffer next to groups that
>> have new email.
> I put together the following elisp, which seems to be doing what I want.
> Upon exiting a group, the number of unread articles is recorded as a
> parameter. Then, the function gnus-user-format-function-N compares that
> against the current total number of unread articles. If the current
> number is greater, an N is displayed via gnus-group-line-format. I
> *think* this is working properly... any suggestions for improvements or
> alternate approaches are welcome. One thing that is required for this to
> work is for every group to be initially entered/exited at least once.
> ;; Used gnus-group-set-timestamp as an example when writing this:
> (defun gnus-group-record-unread-count ()
>   "record the number of unread messages in a group, can be used in hooks like 
> `gnus-select-group-hook'or `gnus-group-catchup-group-hook'."
>     (when gnus-newsgroup-name
>       (let ((lastcount (gnus-group-unread gnus-newsgroup-name)))
>         (gnus-group-set-parameter gnus-newsgroup-name 'prev-unread-count 
> lastcount))))
> ;; used gnus-group-timestamp as an example when writing this this:
> (defsubst gnus-group-recall-prev-unread-count (group)
>   "return the value of the number of unread messages in GROUP"
>   (gnus-group-get-parameter group 'prev-unread-count t))
> ;; record number of unread messages in a group when exiting that group
> (add-hook 'gnus-summary-exit-hook
>           (lambda ()
>           (gnus-group-record-unread-count)
>           (gnus-group-update-group-line)))
> ;; For use in gnus-group-line-format, displays "N" if there are more unread
> ;; messages in a group currently than the last time that group was entered
> (defun gnus-user-format-function-N (headers)
>   (let ((prev-count (gnus-group-recall-prev-unread-count gnus-tmp-group))
>         (cur-count (gnus-group-unread gnus-tmp-group)))
>     (if prev-count
>         (if cur-count
>             (if (< prev-count cur-count)
>                 (message "N")
>               (message " ")))
>       (message "~")))) ; a ~ here shows up groups that've never been 
> entered/exited
> ;; Then place a %uN in the gnus-group-line-format :
> (setq gnus-group-line-format "%P%uN %M%S%p%5,5y/%-5,5t :%*%B%-60,60ug%ud\n")
> <...>
> I find having a flag to notify the arrival of new articles since the
> last viewing of a group very useful. Displaying the number of unread
> articles by itself I don't find all that helpful, as I won't necessarily
> remember how many unread messages were present at the last viewing of a
> group. And I don't want to always mark all articles in a group as read,
> as I might read a few articles in a thread and decide to re-visit it
> later picking up where I left off, etc.

Many thanks, Iā€™ll take this as an example of writing user line formats.
But why built-in ā€˜%U Number of unseen articles (integer)ā€™ did not
satisfy your needs, I wonder.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]