From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.user/18263 Path: news.gmane.org!not-for-mail From: John Magolske Newsgroups: gmane.emacs.gnus.user Subject: Re: New articles since last viewing via gnus-group-line-format? Date: Tue, 07 Jun 2016 21:48:38 -0700 Organization: Aioe.org NNTP Server Message-ID: <878tyg1e1l.fsf@b79.net> References: <87d1oasj1h.fsf@b79.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1465361415 16212 80.91.229.3 (8 Jun 2016 04:50:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 8 Jun 2016 04:50:15 +0000 (UTC) To: info-gnus-english@gnu.org Original-X-From: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org@gnu.org Wed Jun 08 06:50:10 2016 Return-path: Envelope-to: gegu-info-gnus-english@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bAVRR-0000Tq-8T for gegu-info-gnus-english@m.gmane.org; Wed, 08 Jun 2016 06:50:09 +0200 Original-Received: from localhost ([::1]:54453 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAVRQ-0002Wh-8N for gegu-info-gnus-english@m.gmane.org; Wed, 08 Jun 2016 00:50:08 -0400 Original-Path: usenet.stanford.edu!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.gnus Original-Lines: 109 Original-NNTP-Posting-Host: 9hNmCZDdyG1+1jiGEyk58A.user.gioia.aioe.org Original-X-Complaints-To: abuse@aioe.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) Cancel-Lock: sha1:vL5dL+GOK/DoO3nQvem8COGWQWo= X-Notice: Filtered by postfilter v. 0.8.2 Original-Xref: usenet.stanford.edu gnu.emacs.gnus:89390 X-BeenThere: info-gnus-english@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Announcements and discussions for GNUS, the GNU Emacs Usenet newsreader \(in English\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: info-gnus-english-bounces+gegu-info-gnus-english=m.gmane.org@gnu.org Original-Sender: "info-gnus-english" Xref: news.gmane.org gmane.emacs.gnus.user:18263 Archived-At: 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") 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