unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* newbie questions
@ 2012-02-03 11:59 Tamas Papp
  2012-02-05 11:02 ` albin stjerna
  2012-02-06  6:51 ` Tomi Ollila
  0 siblings, 2 replies; 4+ messages in thread
From: Tamas Papp @ 2012-02-03 11:59 UTC (permalink / raw)
  To: notmuch

Hi,

I just started using notmuch.  It is fascinating, but I still need to
figure out a few things:

1. How can I restrict searches (eg of my inbox) to the last few
messages (eg 50-100) or some date (eg last 2 weeks)?  I am using the
Emacs interface.

2. Could someone point me to some guides on workflow with notmuch in
Emacs?  So far I have been using mutt, and I guess I need to rethink a
few things.

3. If I have multiple accounts, how can I change my e-mail address
(From:) when I am writing messages (within emacs, using the m key).

Thanks,

Tamas

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: newbie questions
  2012-02-03 11:59 newbie questions Tamas Papp
@ 2012-02-05 11:02 ` albin stjerna
  2012-02-06  6:51 ` Tomi Ollila
  1 sibling, 0 replies; 4+ messages in thread
From: albin stjerna @ 2012-02-05 11:02 UTC (permalink / raw)
  To: Tamas Papp, notmuch

On Fri, 3 Feb 2012 12:59:34 +0100, Tamas Papp <tkpapp@gmail.com> wrote:
> Hi,

Hi Tamas, and (I suppose) welcome to the Notmuch mailing list!

> I just started using notmuch. It is fascinating, but I still need to
> figure out a few things:
> 
> 1. How can I restrict searches (eg of my inbox) to the last few
> messages (eg 50-100) or some date (eg last 2 weeks)? I am using the
> Emacs interface.

Well, the query syntax is <start unix timestamp>..<end unix timestamp>. I
know there's been talk on the list about some way to use it more easily
in the queries, and it wouldn't be hard to write a function that
generated a query using a more human-friendly notation of time. So far I
don't know about anyone actually having written such a function though,
but I wouldn't be surprised if someone has.

> 2. Could someone point me to some guides on workflow with notmuch in
> Emacs? So far I have been using mutt, and I guess I need to rethink a
> few things.

Possibly. I've only used mutt briefly and a very long time ago, so I
don't really remember, but as you've probably already seen notmuch
relies very heavily on tags, as opposed to just about any other email
client out there (except Gmail, which I've found to be very similar). So
»inbox«, »archived«, »read« and so on isn't really »boxes« the way one
is used to, rather than separate labels you can set (and unset) on each
thread.

My workflow is something like this: first I fetch mail from IMAP using
offlineimap, then I run a script that tags incoming mail as personal,
list, notmuch, rss and so on (notmuch is also my RSS reader). I've set
the saved searches in Emacs to show fairly standard »tag:<tag title> AND
tag:inbox« searches for most of my tags. Then each morning, I begin by
processing »personal« from the top to the bottom, because the »personal«
tag is the one most likely to contain important and/or time-critical
mail (in effect it is the catch-all tag for all mail that isn't directed
to a mailing list or otherwise filtered out as probably uninteresting).

If you're interested, I can send you my mail tagging script.

When I'm done with each mail I archive it (using the standard keybinding
»a«). Most mails are handled more or less immediately, but some (in
particular posts from RSS) take longer time to read. Those I tag with
»read/review« using a custom keybinding »T«. I can then process those
when I have the time.

> 3. If I have multiple accounts, how can I change my e-mail address
> (From:) when I am writing messages (within emacs, using the m key).

I'm mostly changing this by just typing my other email address (and
tab-completing it of course). I actually haven't thought about there
being any other way, but now that you mention it there probably is. :)

Hope this helps! Albin

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: newbie questions
  2012-02-03 11:59 newbie questions Tamas Papp
  2012-02-05 11:02 ` albin stjerna
@ 2012-02-06  6:51 ` Tomi Ollila
  2012-02-06 18:29   ` Jesse Rosenthal
  1 sibling, 1 reply; 4+ messages in thread
From: Tomi Ollila @ 2012-02-06  6:51 UTC (permalink / raw)
  To: Tamas Papp, notmuch

On Fri, 3 Feb 2012 12:59:34 +0100, Tamas Papp <tkpapp@gmail.com> wrote:
> Hi,
> 
> I just started using notmuch.  It is fascinating, but I still need to
> figure out a few things:
> 
> 1. How can I restrict searches (eg of my inbox) to the last few
> messages (eg 50-100) or some date (eg last 2 weeks)?  I am using the
> Emacs interface.

Currently, if you have GNU date you can run from command line:

date +%s.. --date '2 weeks ago'

Then paste the string 1327300096.. to the search field.

> 2. Could someone point me to some guides on workflow with notmuch in
> Emacs?  So far I have been using mutt, and I guess I need to rethink a
> few things.

guides??? what guides??? ;) http://notmuchmail.org/ has some (old)
practices available...

> 3. If I have multiple accounts, how can I change my e-mail address
> (From:) when I am writing messages (within emacs, using the m key).

This is something I've long been planning to look out but so far
my needs have been so small that the effort threshold has not been 
passed...

> Thanks,
> 
> Tamas

Tomi

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: newbie questions
  2012-02-06  6:51 ` Tomi Ollila
@ 2012-02-06 18:29   ` Jesse Rosenthal
  0 siblings, 0 replies; 4+ messages in thread
From: Jesse Rosenthal @ 2012-02-06 18:29 UTC (permalink / raw)
  To: Tomi Ollila, Tamas Papp, notmuch

On Mon, 06 Feb 2012 08:51:15 +0200, Tomi Ollila <tomi.ollila@iki.fi> wrote:
> On Fri, 3 Feb 2012 12:59:34 +0100, Tamas Papp <tkpapp@gmail.com> wrote:
> > 
> > 1. How can I restrict searches (eg of my inbox) to the last few
> > messages (eg 50-100) or some date (eg last 2 weeks)?  I am using the
> > Emacs interface.
> 
> Currently, if you have GNU date you can run from command line:
> 
> date +%s.. --date '2 weeks ago'
> 
> Then paste the string 1327300096.. to the search field.

FWIW, I actually have a hacky date parser baked into my
remote-usage-and-other-stuff script (a more idiosyncratc python
version of the bash script on the wiki). I found that I needed
date-searching pretty frequently, since language and senders seem to be
repeated pretty often in my world. It just parses a "date:" term, passes
it to GNU date, and proceeds with a term in notmuch language. It also
does some day-rounding, since by "date:'2 days ago'..yesterday", I mean
"beginning of day before yesterday to end of yesterday," not "48 hours
ago until 24 hours ago."

I'm not swearing by its efficiency, or even its correctness, but it has
made my life easier. The basics are as follows:

    DATE_PATTERN = re.compile(r'^date:([^.]+)(\.\.)?([^.]+)?')
    
    def replace_date_args(st):
        out = subprocess.check_output([GNU_DATE, "+%s", "-d", st])
        return out.strip()
    
    def round_day_down(timestamp):
        tup = datetime.fromtimestamp(int(timestamp)).date().timetuple()
        return time.mktime(tup)
    
    def round_day_up(timestamp):
        date = datetime.fromtimestamp(int(timestamp)).date()
        date += timedelta(days=1)
        tup = date.timetuple()
        return time.mktime(tup)
    
    def parse_date_args(st):
        re_match = DATE_PATTERN.match(st)
        if re_match:
            grps = re_match.groups()
            start_term = grps[0]
            if not (grps[1] or grps[2]):
                stop_term = start_term
            elif not grps[2]:
                stop_term = "now"
            else:
                stop_term = grps[2]
    
            try:
                start = round_day_down(replace_date_args(start_term))
                stop = round_day_up(replace_date_args(stop_term))
                return "%d..%d" % (start, stop)
            except OSError:
                return st
        else:
            return st

And then in the main routine, I have a parse-and-replace step:

    args = sys.argv[1:]
    try:
        if args[-1] == ")'":
            args = args[:-2] + shlex.split(sys.argv[-2]) + [")'"]
        else:
            args = args[:-1] + shlex.split(sys.argv[-1])
    except IndexError, ValueError:
        pass

    args = [parse_date_args(a) for a in args] 

I'm only giving the relevant parts here, of course.

Best,
Jesse
    

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-02-06 18:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-03 11:59 newbie questions Tamas Papp
2012-02-05 11:02 ` albin stjerna
2012-02-06  6:51 ` Tomi Ollila
2012-02-06 18:29   ` Jesse Rosenthal

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).