Subject: bug#18200: Mostly broken gnus-group-mark-article-read

From: Carlos Pita <[email-masked]>
Date: Tue, 05 Aug 2014 15:41:20 -0300

In order to get a "conversation view" a la gmail I've configured gnus as
follows:

(setq gnus-gcc-mark-as-read t)
(setq gnus-message-archive-group
      (lambda (g)
    (unless (string-match ":" g)
      (concat "nnimap+gmail:" g))))

nnimap+gmail is my primary method so I check for lacking of ":" in the
group name (only groups for secondary methods contain a ":", at least in
my case). The generated gcc header is correct: say the group is
"facultad/micro2", the gcc will be
"nnimap+gmail:facultad/micro2". That's fine.

But then there are a lot of quirks I'm not sure what to do about. Say I
reply a message in "facultad/micro2" group. My reply is indeed archived
into "facultad/micro2" but in the summary buffer for this group:

1. At first the sent reply is not shown at all.
2. If I press /N, then the reply is shown but as unread.
3. If I press M-g, then the reply is shown read.

In the imap server the behavior is as expected: the reply appears inside
the "facultad/micro2" folder and it's marked read. The problem is
obviously with the refreshing of the gnus views/state itself.

Some tracing doesn't show anything manifestly wrong, but nevertheless I
don't know which function is in charge of refreshing the summary buffer
(if any) or, at least, to locally mark the article as read, so maybe I'm
not providing the best info below:

======================================================================
1 -> (gnus-group-mark-article-read "facultad/micro2" 306)
| 2 -> (gnus-request-set-mark "facultad/micro2" (((306) add (read))))
| 2 <- gnus-request-set-mark: nil
| 2 -> (gnus-mark-article-as-read 306 82)
| 2 <- gnus-mark-article-as-read: t
1 <- gnus-group-mark-article-read: nil
======================================================================
1 -> (gnus-group-mark-article-read "facultad/micro2" 307)
| 2 -> (gnus-request-set-mark "facultad/micro2" (((307) add (read))))
| 2 <- gnus-request-set-mark: nil
| 2 -> (gnus-mark-article-as-read 307 82)
| 2 <- gnus-mark-article-as-read: t
1 <- gnus-group-mark-article-read: nil

I'm more or less capable of elisp programming/debugging so don't
hesitate in asking whatever you need from me to fix this issue. I could
even figure out a solution with the appropriate guidance.

Best regards
--
Carlos

Some additional info:

-----------------------------------------------

(emacs-version)
"GNU Emacs 24.3.92.1 (i686-pc-linux-gnu, GTK+ Version 3.12.2)
 of 2014-07-22 on carlos"

(gnus-version)
"Gnus v5.13"

-----------------------------------------------

My .gnus.el:

;;; -*- lexical-binding: t; -*-

;;; me
;
(setq user-mail-address "[email-masked]"
      user-full-name "Carlos Pita")

;;; imap
;
(setq gnus-select-method
      '(nnimap "gmail"
               (nnimap-user "[email-masked]")
               (nnimap-address "imap.gmail.com")
               (nnimap-server-port 993)
               (nnimap-stream ssl)))

;;; nntp
;
(setq gnus-secondary-select-methods
      '((nntp "news.gnus.org")
	(nntp "news.gmane.org")))

;;; smtp
;
(setq message-send-mail-function 'smtpmail-send-it
      smtpmail-smtp-user "[email-masked]"
      smtpmail-smtp-server "smtp.gmail.com"
      smtpmail-smtp-service 465
      smtpmail-stream-type 'ssl)

;;; gmail tweaks
;
;; automatically expires to remove label (and archive)
(setq nnmail-expiry-wait 'immediate)
;; copy sent message to current group (to get conversations)
(setq gnus-gcc-mark-as-read t)
(setq gnus-message-archive-group
      (lambda (g)
	(unless (string-match ":" g)
	  (concat "nnimap+gmail:" g))))
;; move to gmail trash
(add-hook 'gnus-summary-mode-hook
	  (lambda ()
	    (define-key gnus-summary-mode-map "D"
	      (lambda ()
		(interactive)
		(gnus-summary-move-article nil "nnimap+gmail:[Gmail]/Trash")
		(forward-line 1)))))

;;; check new level1 mail
;
(defun my-level1-unread ()
  (let* ((groups (mapcar 'car gnus-newsrc-alist))
	 (unread (mapcar (lambda (g) (when (= (gnus-group-level g) 1)
				  (gnus-group-unread g)))
			 groups)))
	(apply '+ (delq nil unread))))
(defun my-level1-check ()
  (interactive)
  (let ((unread-pre (my-level1-unread))
	(unread-post (progn (gnus-get-unread-articles 1)
			    (my-level1-unread))))
    (unless (= unread-post unread-pre)
      (gnus-group-list-groups)
      (switch-to-buffer "*Group*"))))
(global-set-key [f5] 'my-level1-check)

;;; files & buffers
;
(setq gnus-save-newsrc-file nil
      gnus-read-newsrc-file nil
      gnus-use-dribble-file nil
      gnus-startup-file "~/.emacs.d/newsrc"
      gnus-save-killed-list nil
      message-kill-buffer-on-exit t)

;;; misc
;
(setq mm-discouraged-alternatives '("text/html" "text/richtext")
      gnus-group-line-format "%M%S%p%P%5y:%B%(%G%)\n"
      gnus-thread-hide-subtree t
      auth-source-save-behavior nil)
(require 'google-contacts-message)

-----------------------------------------------

Gnus v5.13
GNU Emacs 24.3.92.1 (i686-pc-linux-gnu, GTK+ Version 3.12.2)
 of 2014-07-22 on carlos
200 quimby.gnus.org InterNetNews NNRP server INN 2.5.3 ready (posting ok)
100 Legal commands
  ARTICLE [message-ID|number]
  AUTHINFO USER name|PASS password|SASL mechanism [initial-response]|GENERIC program [argument ...]
  BODY [message-ID|number]
  CAPABILITIES [keyword]
  DATE
  GROUP newsgroup
  HDR header [message-ID|range]
  HEAD [message-ID|number]
  HELP
  IHAVE message-ID
  LAST
  LIST [ACTIVE [wildmat]|ACTIVE.TIMES [wildmat]|COUNTS [wildmat]|DISTRIB.PATS|DISTRIBUTIONS|HEADERS [MSGID|RANGE]|MODERATORS|MOTD|NEWSGROUPS [wildmat]|OVERVIEW.FMT|SUBSCRIPTIONS [wildmat]]
  LISTGROUP [newsgroup [range]]
  MODE READER
  NEWGROUPS [yy]yymmdd hhmmss [GMT]
  NEWNEWS wildmat [yy]yymmdd hhmmss [GMT]
  NEXT
  OVER [range]
  POST
  QUIT
  STARTTLS
  STAT [message-ID|number]
  XGTITLE [wildmat]
  XHDR header [message-ID|range]
  XOVER [range]
  XPAT header message-ID|range pattern [pattern ...]
Report problems to <[email-masked]>.
.
580 Error initializing TLS