unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>
To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org
Subject: Re: [PATCH] emacs: support "notmuch new" as a notmuch-poll-script
Date: Mon, 12 Dec 2011 02:39:47 +0400	[thread overview]
Message-ID: <87liqig2bw.fsf@gmail.com> (raw)
In-Reply-To: <878vmi4upz.fsf@nikula.org>

On Mon, 12 Dec 2011 00:19:36 +0200, Jani Nikula <jani@nikula.org> wrote:
> 
> Hi Dmitry -
> 
> On Mon, 12 Dec 2011 02:00:45 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:
> > On Sun, 11 Dec 2011 23:48:20 +0200, Jani Nikula <jani@nikula.org> wrote:
> > > Let notmuch-poll-script be a function as well as a string. Make default
> > > value nil instead of an empty string, but allow "" for backwards
> > > compatibility. Add a notmuch poll function to call "notmuch new" using the
> > > configured notmuch-command.
> > > 
> > > This allows taking better advantage of the "notmuch new" hooks from emacs
> > > without intermediate scripts.
> > > 
> > 
> > I was just thinking about working on this myself :)
> 
> :)
> 
> > I think a better solution would be to allow running a command with
> > arguments.  Creating a elisp function just to run a command with some
> > parameters feels wrong.  This way we would have to add another function
> > each time we want to add another argument.
> 
> One thing to take into account is running "notmuch new" using
> notmuch-command, and make that happen with one click in custom.
> 

Indeed.  One click in custom should be easy, but using notmuch-command
may not be so.  So now I like your solution :) Though others may think
of something better.

The only comment I have:

+		 (function :tag "Custom function"
+			   :value notmuch-poll-script-notmuch-new)

Should we set :value to notmuch-poll-script-notmuch-new here?  There is
another option for "notmuch new", so perhaps there should be no value
for custom function as for custom script?

Regards,
  Dmitry

> > Function support for notmuch-poll-script seems like a useful feature on
> > it's own.
> 
> I just did this quickly to scratch my own itches, so to speak. My elisp
> is not that great, so I really wouldn't mind if you wanted to continue
> from here and make it your own. It'll be a while before I have the time
> to (figure out how to) do this properly anyway. But up to you, really.
> 
> BR,
> Jani.
> 
> 
> > 
> > Regards,
> >   Dmitry
> > 
> > > Signed-off-by: Jani Nikula <jani@nikula.org>
> > > ---
> > >  emacs/notmuch.el |   44 ++++++++++++++++++++++++++++++++------------
> > >  1 files changed, 32 insertions(+), 12 deletions(-)
> > > 
> > > diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> > > index 8936149..6c7e800 100644
> > > --- a/emacs/notmuch.el
> > > +++ b/emacs/notmuch.el
> > > @@ -965,28 +965,48 @@ same relative position within the new buffer."
> > >      (notmuch-search query oldest-first target-thread target-line continuation)
> > >      (goto-char (point-min))))
> > >  
> > > -(defcustom notmuch-poll-script ""
> > > -  "An external script to incorporate new mail into the notmuch database.
> > > +(defcustom notmuch-poll-script nil
> > > +  "A script or a function to incorporate new mail into the notmuch database.
> > >  
> > > -If this variable is non empty, then it should name a script to be
> > > -invoked by `notmuch-search-poll-and-refresh-view' and
> > > -`notmuch-hello-poll-and-update' (each have a default keybinding
> > > -of 'G'). The script could do any of the following depending on
> > > +This variable can be set to a function or the name of an external
> > > +script to be invoked by `notmuch-search-poll-and-refresh-view'
> > > +and `notmuch-hello-poll-and-update' (each have a default
> > > +keybinding of 'G'). Set to nil to do nothing.
> > > +
> > > +The function or script could do any of the following depending on
> > >  the user's needs:
> > >  
> > >  1. Invoke a program to transfer mail to the local mail store
> > >  2. Invoke \"notmuch new\" to incorporate the new mail
> > > -3. Invoke one or more \"notmuch tag\" commands to classify the mail"
> > > -  :type 'string
> > > +3. Invoke one or more \"notmuch tag\" commands to classify the mail
> > > +
> > > +You can also choose to use \"notmuch new\" through the provided
> > > +`notmuch-poll-script-notmuch-new' function, and have the
> > > +\"notmuch new\" hooks perform the actions above."
> > > +  :type '(choice (const :tag "Not set" nil)
> > > +		 (const :tag "Notmuch new" notmuch-poll-script-notmuch-new)
> > > +		 (function :tag "Custom function"
> > > +			   :value notmuch-poll-script-notmuch-new)
> > > +		 (string :tag "Custom script"))
> > >    :group 'notmuch)
> > >  
> > > +(defun notmuch-poll-script-notmuch-new ()
> > > +  "Run \"notmuch new\"."
> > > +  (call-process notmuch-command nil nil nil "new"))
> > > +
> > >  (defun notmuch-poll ()
> > > -  "Run external script to import mail.
> > > +  "Run external script or call a function to import mail.
> > >  
> > > -Invokes `notmuch-poll-script' if it is not set to an empty string."
> > > +Invokes `notmuch-poll-script', which can be a function or the
> > > +name of an external script. Does nothing if `notmuch-poll-script'
> > > +is nil or an empty string."
> > >    (interactive)
> > > -  (if (not (string= notmuch-poll-script ""))
> > > -      (call-process notmuch-poll-script nil nil)))
> > > +  (cond
> > > +   ((stringp notmuch-poll-script)
> > > +    (if (not (string= notmuch-poll-script "")) ;; for backwards compatibility
> > > +	(call-process notmuch-poll-script nil nil)))
> > > +   ((functionp notmuch-poll-script)
> > > +    (funcall notmuch-poll-script))))
> > >  
> > >  (defun notmuch-search-poll-and-refresh-view ()
> > >    "Invoke `notmuch-poll' to import mail, then refresh the current view."
> > > -- 
> > > 1.7.5.4
> > > 
> > > _______________________________________________
> > > notmuch mailing list
> > > notmuch@notmuchmail.org
> > > http://notmuchmail.org/mailman/listinfo/notmuch

  reply	other threads:[~2011-12-11 22:40 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-11 21:48 [PATCH] emacs: support "notmuch new" as a notmuch-poll-script Jani Nikula
2011-12-11 22:00 ` Dmitry Kurochkin
2011-12-11 22:19   ` Jani Nikula
2011-12-11 22:39     ` Dmitry Kurochkin [this message]
2011-12-11 22:58   ` Austin Clements
2011-12-11 23:10     ` Jani Nikula
2011-12-12  0:31       ` Austin Clements
2011-12-12  0:39         ` Dmitry Kurochkin
2011-12-12 10:15         ` Tomi Ollila
2011-12-12 10:21           ` Dmitry Kurochkin
2011-12-12 11:38             ` Tomi Ollila
2011-12-12 15:42             ` Austin Clements
2011-12-12 19:57 ` [PATCH v2] " Jani Nikula
2011-12-12 20:12   ` Dmitry Kurochkin
2011-12-12 20:24   ` Austin Clements
2011-12-12 20:50 ` [PATCH v3] " Jani Nikula
2011-12-12 20:53   ` Dmitry Kurochkin
2011-12-12 21:13     ` Jani Nikula
2011-12-12 21:24       ` Austin Clements
2011-12-12 21:34         ` Dmitry Kurochkin
2011-12-12 21:01   ` Austin Clements
2011-12-15  4:24   ` David Bremner
2012-01-12 17:31   ` Pieter Praet
2012-01-12 17:33     ` [PATCH] emacs: globally replace non-branching "(if (not ..." with "(unless ..." Pieter Praet
2012-01-12 17:40       ` Dmitry Kurochkin
2012-01-12 22:10       ` Xavier Maillard
2012-01-13  8:23       ` David Edmondson
2012-01-13 12:42         ` Xavier Maillard
2012-01-13 12:37           ` Tomi Ollila
2012-01-13 13:01           ` David Edmondson
2012-01-14  9:14         ` Pieter Praet
2012-01-14  9:17           ` [PATCH] emacs: globally replace non-branching "(if COND (progn ..." with "(when ..." Pieter Praet
2012-01-28 12:41             ` David Bremner
2012-01-28 12:55               ` Jani Nikula
2012-01-28 17:14                 ` David Bremner
2012-01-30  9:23                   ` David Edmondson
2012-02-01 13:46                     ` Pieter Praet
2012-02-01 14:21                       ` Dmitry Kurochkin
2012-01-30  7:03               ` Pieter Praet
2012-01-30  7:59                 ` Tomi Ollila
2012-02-01 13:46                   ` Pieter Praet
2012-01-31  3:34             ` David Bremner
2012-02-01 13:47               ` Pieter Praet
2012-02-01 13:50                 ` [PATCH v2] " Pieter Praet
2012-02-01 14:05                   ` David Edmondson
2012-02-02  1:31                   ` David Bremner
2012-01-14  9:52           ` [PATCH] emacs: globally replace non-branching "(if (not ..." with "(unless ..." Pieter Praet
2012-01-13 16:06       ` David Edmondson
2012-01-14  9:18         ` Pieter Praet
2012-01-15 11:55           ` David Edmondson
2012-01-16 10:56             ` [PATCH v2] " Pieter Praet
2012-01-16 11:06               ` David Edmondson
2012-01-16 12:39               ` Tomi Ollila
2012-01-21 12:21               ` David Bremner

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=87liqig2bw.fsf@gmail.com \
    --to=dmitry.kurochkin@gmail.com \
    --cc=jani@nikula.org \
    --cc=notmuch@notmuchmail.org \
    /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).