unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Tomas Nordin <tomasn@posteo.net>
To: Sam Halliday <sam.halliday@gmail.com>, notmuch@notmuchmail.org
Subject: Re: IMAP with server deletion
Date: Fri, 05 Jul 2019 23:57:58 +0200	[thread overview]
Message-ID: <87bly8gn4p.fsf@fliptop.i-did-not-set--mail-host-address--so-tickle-me> (raw)
In-Reply-To: <87pnmolip6.fsf@gmail.com>

Sam Halliday <sam.halliday@gmail.com> writes:

> Hello all,

Hello Sam

> I'm using emacs + notmuch + offlineimap + msmtp to manage my Gmail.

I have that setup apart from Gmail, (I use Posteo).

>
> My gmail account is starting to get so big that an offline sync is
>time
> consuming.
>
> I'd like to delete messages on the server, but keep them locally. Is
> that possible with IMAP?

Yes. I keep a lot of mailing list mails locally but delete them from the
server. I have this to tag list mails

(define-key notmuch-show-mode-map "a"
  (lambda ()
    "Tag all messages in current buffer with `rfile'."
    (interactive)
    (notmuch-show-tag-all (list "+rfile" "-inbox"))
    (message "rfiled the thread")))

so they all get tagged "rfile", just a tag I made up at some point. Then
I have this to move those messages to a directory not synced by
offlineimap:

(defun tn-refile-rfiles ()
  "Move all messages thus tagged to archive folder.

See variable `tn-refile-tags' for message tags that mean to move
the message to archived folder.

Discard all messages already in the archive folder."
  (interactive)
  (let (file-to-move count)
    (setq count 0)
    (message "Moving messages...")
    (dolist (file-to-move
	         (apply 'process-lines (append
                                    '("notmuch" "search" "--output=files")
				                    tn-refile-tags
				                    '("AND NOT folder:archive"))))
      (rename-file file-to-move
                   (concat tn-archive-folder
			               (file-name-nondirectory file-to-move)))
      (setq count (1+ count)))
    (if (> count 0)
	    (call-process "notmuch" nil "*tn-notmuch-new-out*" nil "new"))
    (message "Moved %d messages" count)))

The variable `tn-refile-tags' look like this

(defvar tn-refile-tags (list "tag:rfile" "tag:lst")
  "list of refile tag strings for use in a notmuch search")

Don't remember why I made this, really just using the rfile tag, but
anyway. Finally I have this binding:

(define-key notmuch-hello-mode-map (kbd "A") 'tn-refile-rfiles)

The effect is that offlineimap see those messages as deleted and sync
the deletion to the server. But for Notmuch the archive folder is a
valid folder and in my case it is "/home/tomas/Mail/archive/cur/".

Best regards
--
Tomas

      parent reply	other threads:[~2019-07-05 22:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-05 13:22 IMAP with server deletion Sam Halliday
2019-07-05 13:26 ` Dan Čermák
2019-07-05 13:30 ` Chris Coutinho
2019-07-05 21:57 ` Tomas Nordin [this message]

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

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bly8gn4p.fsf@fliptop.i-did-not-set--mail-host-address--so-tickle-me \
    --to=tomasn@posteo.net \
    --cc=notmuch@notmuchmail.org \
    --cc=sam.halliday@gmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

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 read-only IMAP folder(s) and NNTP newsgroup(s).