diff --git a/lisp/gnus/nnimap.el b/lisp/gnus/nnimap.el index 67c5db1e04..5f8e9d5ec0 100644 --- a/lisp/gnus/nnimap.el +++ b/lisp/gnus/nnimap.el @@ -1702,18 +1702,19 @@ nnimap-update-qresync-info (cdr (or (assoc (caddr type) flags) ; %Flagged (assoc (intern (cadr type) obarray) flags) (assoc (cadr type) flags))))) ; "\Flagged" - (setq marks (delq ticks marks)) - (pop ticks) - ;; Add the new marks we got. - (setq ticks (gnus-add-to-range ticks new-marks)) - ;; Remove the marks from messages that don't have them. - (setq ticks (gnus-remove-from-range - ticks - (gnus-compress-sequence - (gnus-sorted-complement existing new-marks)))) - (when ticks - (push (cons (car type) ticks) marks))) - (gnus-info-set-marks info marks t)) + (when new-marks + (setq marks (delq ticks marks)) + (pop ticks) + ;; Add the new marks we got. + (setq ticks (gnus-add-to-range ticks new-marks)) + ;; Remove the marks from messages that don't have them. + (setq ticks (gnus-remove-from-range + ticks + (gnus-compress-sequence + (gnus-sorted-complement existing new-marks)))) + (when ticks + (push (cons (car type) ticks) marks)) + (gnus-info-set-marks info marks t)))) ;; Add vanished to the list of unexisting articles. (when vanished (let* ((old-unexists (assq 'unexist marks))