help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Gnus: mark-expirable vs. delete


From: Johan Bockgård
Subject: Re: Gnus: mark-expirable vs. delete
Date: Mon, 04 Aug 2003 17:09:12 +0200
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.2 (usg-unix-v)

"Joe Casadonte" <address@hidden> writes:

> On Mon, 16 Jun 2003, Johan Bockgård wrote:
>
>> Yes, I have thought about this too. It might be nice to have. I
>> think Pine does this--you mark messages for deletion and it deletes
>> them when you exit.
>
> That's exactly what I want!

Only slightly tested:


(defcustom gnus-expungable-mark ?D
  "*Mark used for articles that will be expunged on group exit."
  :group 'gnus-summary-marks
  :type 'character)

(defvar gnus-interactive-expunge 'maybe
  "*If t, require your confirmation before expunging articles. If nil don't ask.
Any other value means to do what `gnus-summary-delete-article' would do
\(ask if `gnus-novice-user' is non-nil).")

(defun gnus-summary-mark-as-expungable (n)
  "Mark next N articles as expungable.
If N is negative, mark backward instead."
  (interactive "p")
  (gnus-summary-mark-forward n gnus-expungable-mark))

(add-hook 'gnus-summary-prepare-exit-hook 
'gnus-summary-expunge-expungable-articles)

;; mostly copied from spam-mark-spam-as-expired-and-move-routine in spam.el
(defun gnus-summary-expunge-expungable-articles ()
  (unless gnus-group-is-exiting-without-update-p
    (gnus-summary-kill-process-mark)
    (let ((articles gnus-newsgroup-articles)
          article
          todelete)
      (dolist (article articles)
        (when (eq (gnus-summary-article-mark article)
                  gnus-expungable-mark)
          (push article todelete)))

      ;; now do the actual deletion
      (condition-case data
          (when todelete
            (dolist (article todelete)
              (gnus-summary-set-process-mark article))
            ;; should we ask before expunging?
            (let ((gnus-novice-user (cond ((null gnus-interactive-expunge) nil)
                                          ((eq gnus-interactive-expunge t) t)
                                          (t gnus-novice-user))))
              (gnus-summary-delete-article))
            ;; why does gnus-summary-work-articles push the marks on the stack?
            (gnus-summary-yank-process-mark)
            (gnus-message 6 "Expunging articles"))
        ;; is (cadr data) always a string?
        (error (gnus-message 3 "%s" (cadr data))))
      (gnus-summary-yank-process-mark))))

;;(define-key gnus-summary-mode-map "\C-cd" 'gnus-summary-mark-as-expungable)


-- 
Join us on #emacs @ irc.freenode.net.
http://www.emacswiki.org/cgi-bin/wiki.pl/EmacsChannel


reply via email to

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