From: John Magolske <trimtab@b79.net>
To: info-gnus-english@gnu.org
Subject: Re: New articles since last viewing via gnus-group-line-format?
Date: Tue, 07 Jun 2016 21:48:38 -0700 [thread overview]
Message-ID: <878tyg1e1l.fsf@b79.net> (raw)
In-Reply-To: <87d1oasj1h.fsf@b79.net>
Think I found a solution to this...
John Magolske <listmail@b79.net> 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")
The following functions will download email / news and update the
group-line-format in the group buffer. In conjunction with the above
elisp, this places an N in front of groups that have new articles. I'm
using fdm to download email into ~/Mail and the nnfolder backend to
access this with Gnus. For news I use slrnpull to pull articles into
~/News and read from that local spool using the nnspool backend.
;; Update groups under the topic named "Email". A modification of
;; gnus-topic-get-new-news-this-topic, I found this necessary
;; as gnus-group-get-new-news by itself doesn't "Get" newly arrived
;; articles for my nnfolder email
(defun gnus-group-get-email ()
(interactive)
"Check for new news in the \"Email\" topic."
(let* ((topic "Email")
(data (cadr (gnus-topic-find-topology topic))))
(save-excursion
(gnus-topic-mark-topic topic nil)
(gnus-group-get-new-news-this-group))
(gnus-topic-remove-topic (eq 'visible (cadr data)))))
;; get email
(defun gnus-download-email ()
(interactive)
(shell-command "fdm -f ~/path-to-fdm.conf -m -a account_1 -a account_2 fetch")
(gnus-group-get-email))
(define-key gnus-group-mode-map (kbd "Ge") 'gnus-download-email)
;; get news
(defun gnus-download-news ()
(interactive)
(shell-command "~/bin/slrnp") ; slrnp is a script that runs slrnpull against several accounts
(gnus-group-get-new-news))
(define-key gnus-group-mode-map (kbd "Gn") 'gnus-download-news)
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.
--
John Magolske
http://b79.net/contact
next parent reply other threads:[~2016-06-08 4:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <87d1oasj1h.fsf@b79.net>
2016-06-08 4:48 ` John Magolske [this message]
2016-06-30 16:33 ` Dmitry Alexandrov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878tyg1e1l.fsf@b79.net \
--to=trimtab@b79.net \
--cc=info-gnus-english@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).