[PATCH] cli: abstract common config get/set code

2014-01-17 Thread Jani Nikula
Pretty straightforward abstraction similar to get/set list.

---

v2 of id:1376839205-5115-1-git-send-email-jani at nikula.org adding a few
comments about config value caching per David's request. Dropped the
2nd patch as too tricky.
---
 notmuch-config.c | 86 +++-
 1 file changed, 35 insertions(+), 51 deletions(-)

diff --git a/notmuch-config.c b/notmuch-config.c
index 6845e3c..4aad9eb 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -496,6 +496,32 @@ notmuch_config_is_new (notmuch_config_t *config)
 return config->is_new;
 }

+static const char *
+_config_get (notmuch_config_t *config, char **field,
+const char *group, const char *key)
+{
+/* read from config file and cache value, if not cached already */
+if (*field == NULL) {
+   char *value;
+   value = g_key_file_get_string (config->key_file, group, key, NULL);
+   if (value) {
+   *field = talloc_strdup (config, value);
+   free (value);
+   }
+}
+return *field;
+}
+
+static void
+_config_set (notmuch_config_t *config, char **field,
+const char *group, const char *key, const char *value)
+{
+g_key_file_set_string (config->key_file, group, key, value);
+
+/* drop the cached value */
+talloc_free (*field);
+*field = NULL;
+}

 static const char **
 _config_get_list (notmuch_config_t *config,
@@ -504,6 +530,7 @@ _config_get_list (notmuch_config_t *config,
 {
 assert(outlist);

+/* read from config file and cache value, if not cached already */
 if (*outlist == NULL) {

char **inlist = g_key_file_get_string_list (config->key_file,
@@ -535,6 +562,8 @@ _config_set_list (notmuch_config_t *config,
  size_t length, const char ***config_var )
 {
 g_key_file_set_string_list (config->key_file, group, name, list, length);
+
+/* drop the cached value */
 talloc_free (*config_var);
 *config_var = NULL;
 }
@@ -542,85 +571,40 @@ _config_set_list (notmuch_config_t *config,
 const char *
 notmuch_config_get_database_path (notmuch_config_t *config)
 {
-char *path;
-
-if (config->database_path == NULL) {
-   path = g_key_file_get_string (config->key_file,
- "database", "path", NULL);
-   if (path) {
-   config->database_path = talloc_strdup (config, path);
-   free (path);
-   }
-}
-
-return config->database_path;
+return _config_get (config, &config->database_path, "database", "path");
 }

 void
 notmuch_config_set_database_path (notmuch_config_t *config,
  const char *database_path)
 {
-g_key_file_set_string (config->key_file,
-  "database", "path", database_path);
-
-talloc_free (config->database_path);
-config->database_path = NULL;
+_config_set (config, &config->database_path, "database", "path", 
database_path);
 }

 const char *
 notmuch_config_get_user_name (notmuch_config_t *config)
 {
-char *name;
-
-if (config->user_name == NULL) {
-   name = g_key_file_get_string (config->key_file,
- "user", "name", NULL);
-   if (name) {
-   config->user_name = talloc_strdup (config, name);
-   free (name);
-   }
-}
-
-return config->user_name;
+return _config_get (config, &config->user_name, "user", "name");
 }

 void
 notmuch_config_set_user_name (notmuch_config_t *config,
  const char *user_name)
 {
-g_key_file_set_string (config->key_file,
-  "user", "name", user_name);
-
-talloc_free (config->user_name);
-config->user_name = NULL;
+_config_set (config, &config->user_name, "user", "name", user_name);
 }

 const char *
 notmuch_config_get_user_primary_email (notmuch_config_t *config)
 {
-char *email;
-
-if (config->user_primary_email == NULL) {
-   email = g_key_file_get_string (config->key_file,
-  "user", "primary_email", NULL);
-   if (email) {
-   config->user_primary_email = talloc_strdup (config, email);
-   free (email);
-   }
-}
-
-return config->user_primary_email;
+return _config_get (config, &config->user_primary_email, "user", 
"primary_email");
 }

 void
 notmuch_config_set_user_primary_email (notmuch_config_t *config,
   const char *primary_email)
 {
-g_key_file_set_string (config->key_file,
-  "user", "primary_email", primary_email);
-
-talloc_free (config->user_primary_email);
-config->user_primary_email = NULL;
+_config_set (config, &config->user_primary_email, "user", "primary_email", 
primary_email);
 }

 const char **
-- 
1.8.5.2



[PATCH] lib: fix clang compiler warning

2014-01-17 Thread Jani Nikula
With some combination of clang and talloc, not using the return value
of talloc_steal() produces a warning. Ignore it, as talloc_steal() has
no failure modes per documentation.
---
 lib/thread.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/thread.cc b/lib/thread.cc
index 4dcf705..8f53e12 100644
--- a/lib/thread.cc
+++ b/lib/thread.cc
@@ -524,7 +524,7 @@ _notmuch_thread_create (void *ctx,
 _resolve_thread_relationships (thread);

 /* Commit to returning thread. */
-talloc_steal (ctx, thread);
+(void) talloc_steal (ctx, thread);

   DONE:
 talloc_free (local);
-- 
1.8.5.2



[Patch v3 1/3] info: start info documentation.

2014-01-17 Thread Jani Nikula
On Wed, 15 Jan 2014, David Bremner  wrote:
> From: David Bremner 
>
> Initially, just a skeleton of documentation for the emacs
> interface. There are a few dangling references to other info pages;
> these are to be generated from the man pages in a following commit.

Is it possible to add a link to the info page from notmuch-hello?

Jani.



>
> As far as actual documentation, so far this contains only a brief
> intro to notmuch-hello.
> ---
>  INSTALL |  12 +-
>  Makefile|  10 +-
>  configure   |  32 +
>  info/Makefile   |   7 ++
>  info/Makefile.local |  33 +
>  info/notmuch-emacs.texi | 324 
> 
>  6 files changed, 412 insertions(+), 6 deletions(-)
>  create mode 100644 info/Makefile
>  create mode 100644 info/Makefile.local
>  create mode 100644 info/notmuch-emacs.texi
>
> diff --git a/INSTALL b/INSTALL
> index fce9352..451bf05 100644
> --- a/INSTALL
> +++ b/INSTALL
> @@ -60,16 +60,24 @@ Talloc which are each described below:
>  
>   Talloc is available from http://talloc.samba.org/
>  
> + texinfo
> + ---
> +
> + To build the info documentation, you need makeinfo and
> + pod2texi. To install the info documentation, you need
> + install-info; these are all part of the texinfo distribution
> + as of version 5.0.
> +
>  On a modern, package-based operating system you can install all of the
>  dependencies with a simple simple command line. For example:
>  
>For Debian and similar:
>  
> -sudo apt-get install libxapian-dev libgmime-2.6-dev libtalloc-dev
> +sudo apt-get install libxapian-dev libgmime-2.6-dev libtalloc-dev 
> makeinfo texinfo
>  
>For Fedora and similar:
>  
> - sudo yum install xapian-core-devel gmime-devel libtalloc-devel
> + sudo yum install xapian-core-devel gmime-devel libtalloc-devel texinfo
>  
>  On other systems, a similar command can be used, but the details of
>  the package names may be different.
> diff --git a/Makefile b/Makefile
> index 0428160..250fbaa 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -2,10 +2,12 @@
>  # given explicitly on the command line) so mention it first.
>  all:
>  
> -# List all subdirectories here. Each contains its own Makefile.local.
> -# Use of '=', without '+=', seems to be required for out-of-tree
> -# builds to work.
> -subdirs = compat completion emacs lib man parse-time-string performance-test 
> util test
> +# List all subdirectories here. Each contains its own Makefile.local
> +subdirs := compat completion emacs lib man parse-time-string
> +subdirs += performance-test util info
> +# it seems to be important to keep test last.
> +subdirs += test
> +
>  
>  # We make all targets depend on the Makefiles themselves.
>  global_deps = Makefile Makefile.config Makefile.local \
> diff --git a/configure b/configure
> index 13b6062..e75c1d4 100755
> --- a/configure
> +++ b/configure
> @@ -376,6 +376,10 @@ if [ -z "${EMACSETCDIR}" ]; then
>  fi
>  fi
>  
> +if [ -z "${INFODIR}" ]; then
> +INFODIR='$(prefix)/share/info'
> +fi
> +
>  printf "Checking if emacs is available... "
>  if emacs --quick --batch > /dev/null 2>&1; then
>  printf "Yes.\n"
> @@ -385,6 +389,24 @@ else
>  have_emacs=0
>  fi
>  
> +printf "Checking for makeinfo... "
> +if makeinfo --version > /dev/null 2>&1; then
> +printf "Yes.\n"
> +have_makeinfo=1
> +else
> +printf "No (so will not info docs)\n"
> +have_makeinfo=0
> +fi
> +
> +printf "Checking for install-info... "
> +if install-info --version > /dev/null 2>&1; then
> +printf "Yes.\n"
> +have_installinfo=1
> +else
> +printf "No (so will not install info docs)\n"
> +have_installinfo=0
> +fi
> +
>  libdir_in_ldconfig=0
>  
>  printf "Checking which platform we are on... "
> @@ -740,6 +762,16 @@ emacsetcdir=${EMACSETCDIR}
>  # Whether there's an emacs binary available for byte-compiling
>  HAVE_EMACS = ${have_emacs}
>  
> +# Whether there's a makeinfo binary available to build info docs
> +HAVE_MAKEINFO = ${have_makeinfo}
> +
> +# Whether there's an install-info binary available
> +HAVE_INSTALLINFO = ${have_installinfo}
> +
> +# where to install info files
> +
> +INFODIR = ${INFODIR}
> +
>  # The directory to which desktop files should be installed
>  desktop_dir = \$(prefix)/share/applications
>  
> diff --git a/info/Makefile b/info/Makefile
> new file mode 100644
> index 000..de492a7
> --- /dev/null
> +++ b/info/Makefile
> @@ -0,0 +1,7 @@
> +# See Makefile.local for the list of files to be compiled in this
> +# directory.
> +all:
> + $(MAKE) -C .. all
> +
> +.DEFAULT:
> + $(MAKE) -C .. $@
> diff --git a/info/Makefile.local b/info/Makefile.local
> new file mode 100644
> index 000..55e9740
> --- /dev/null
> +++ b/info/Makefile.local
> @@ -0,0 +1,33 @@
> +# -*- makefile -*-
> +
> +dir := info
> +
> +texi_sources :=  $(dir)/notmuch-emacs.texi
> +emacs_info := $(texi_sources:.texi=.info)
> +
> +info := 

[Patch v3 2/3] man: partial conversion to pod.

2014-01-17 Thread Jani Nikula
On Wed, 15 Jan 2014, David Bremner  wrote:
> From: David Bremner 
>
> This allows generation of man page and info document from the same source.
> It is also a bit more friendly to edit for most people.

Before plunging into reviewing this, I'd like to have some more views on
the choice of the format. Also on the mailing list and not just IRC.

In short, I'm really tempted by using markdown as the format, not least
because it's what we use for the web pages. The big (also literally)
downside is pandoc (http://johnmacfarlane.net/pandoc/), the tool for
converting markdown to man. I don't mind its dependencies, others may
disagree. Are there any sensible alternatives to pandoc?

That said, I do like pod better than *roff, and if people oppose to
requiring pandoc for building and installing the man pages, I'm okay
with that too.


BR,
Jani.


>
> The conversion was done with the following perl script (some small
> hand-editing of the .pod may be needed afterwards).
>
> open(POD,"groff -e -mandoc -Tascii -rHY=0 | rman -f POD|") || die;
> LINE:
> while(){
>   my $blank=0;
>   while (m/^\s*$/) {
> $_=;
> $blank++;
>   }
>   print "\n" if ($blank);
>
>   while(s/^(=head1 .*)B[<]/\1/){};
>   while(s/^(=head1 .*)[>]/\1/){};
>
>   s/  */ /g;
>   print;
> }
> ---
>  INSTALL |   6 +
>  configure   |  12 ++
>  info/Makefile.local |  28 -
>  man/Makefile.local  |  19 ++-
>  man/man1/notmuch-search.1   | 199 -
>  man/man1/notmuch.1  | 190 
>  man/man7/notmuch-search-terms.7 | 269 
> 
>  pod/notmuch-search-terms.pod| 235 +++
>  pod/notmuch-search.pod  | 194 +
>  pod/notmuch.pod | 155 +++
>  10 files changed, 645 insertions(+), 662 deletions(-)
>  delete mode 100644 man/man1/notmuch-search.1
>  delete mode 100644 man/man1/notmuch.1
>  delete mode 100644 man/man7/notmuch-search-terms.7
>  create mode 100644 pod/notmuch-search-terms.pod
>  create mode 100644 pod/notmuch-search.pod
>  create mode 100644 pod/notmuch.pod
>
> diff --git a/INSTALL b/INSTALL
> index 451bf05..697b7b2 100644
> --- a/INSTALL
> +++ b/INSTALL
> @@ -60,6 +60,12 @@ Talloc which are each described below:
>  
>   Talloc is available from http://talloc.samba.org/
>  
> + pod2man
> + ---
> +
> + Some of the documentation is built with pod2man. This is part
> + of the standard Perl distribution since Perl 5.6.0
> +
>   texinfo
>   ---
>  
> diff --git a/configure b/configure
> index e75c1d4..6dadbaa 100755
> --- a/configure
> +++ b/configure
> @@ -389,6 +389,15 @@ else
>  have_emacs=0
>  fi
>  
> +printf "Checking for pod2man... "
> +if pod2man --help > /dev/null 2>&1; then
> +printf "Yes.\n"
> +have_pod2man=1
> +else
> +printf "No (man page install may fail)\n"
> +have_pod2man=0
> +fi
> +
>  printf "Checking for makeinfo... "
>  if makeinfo --version > /dev/null 2>&1; then
>  printf "Yes.\n"
> @@ -768,6 +777,9 @@ HAVE_MAKEINFO = ${have_makeinfo}
>  # Whether there's an install-info binary available
>  HAVE_INSTALLINFO = ${have_installinfo}
>  
> +# Is pod2man in the path?
> +HAVE_POD2MAN = ${have_pod2man}
> +
>  # where to install info files
>  
>  INFODIR = ${INFODIR}
> diff --git a/info/Makefile.local b/info/Makefile.local
> index 55e9740..26466ae 100644
> --- a/info/Makefile.local
> +++ b/info/Makefile.local
> @@ -2,10 +2,14 @@
>  
>  dir := info
>  
> +man_texi :=  $(dir)/notmuch.texi $(dir)/notmuch-search.texi 
> $(dir)/notmuch-search-terms.texi
> +man_info := $(man_texi:.texi=.info)
> +man_entry := $(man_texi:.texi=.entry)
> +
>  texi_sources :=  $(dir)/notmuch-emacs.texi
>  emacs_info := $(texi_sources:.texi=.info)
>  
> -info := $(emacs_info)
> +info := $(emacs_info) $(man_info)
>  
>  ifeq ($(HAVE_MAKEINFO),1)
>  all: $(info)
> @@ -15,11 +19,26 @@ ifeq ($(HAVE_INSTALLINFO),1)
>  install: install-info
>  endif
>  
> -%.info: %.texi
> +%.entry: ../pod/%.pod
> + printf "@dircategory Notmuch\n at direntry\n" > $@
> + printf "* %s: (%s). " $(*F) $(*F) >> $@
> + podselect -section Name $< | \
> +   perl -n -e  's/notmuch.* - (.*)/\u\L$$1/ && print' >> $@
> + printf "@end direntry\n" >> $@
> +
> +%.info: %.texi %.entry
>   makeinfo --no-split -o $@ $<
>  
>  $(dir)/notmuch-emacs.info: $(dir)/notmuch-emacs.texi $(dir)/version.texi
>  
> +
> +%.raw-texi: ../pod/%.pod
> + pod2texi  --output $@ $<
> +
> +%.texi: %.raw-texi
> + # a nasty hack, but the nicer ways seem to have bugs.
> + sed 's/@node Top/@include $(*F).entry\n at node Top/'< $<  > $@
> +
>  .PHONY: $(dir)/version.texi
>  $(dir)/version.texi: version
>   printf "@set VERSION ${VERSION}\n" > $@
> @@ -29,5 +48,8 @@ install-info: ${info}
>   mkdir -p "$(DESTDIR)$(INFODIR)"
>   install -m0644 $(info) "$

[Patch v3 1/3] info: start info documentation.

2014-01-17 Thread Jani Nikula
On Wed, 15 Jan 2014, David Bremner  wrote:
> From: David Bremner 
>
> Initially, just a skeleton of documentation for the emacs
> interface. There are a few dangling references to other info pages;
> these are to be generated from the man pages in a following commit.
>
> As far as actual documentation, so far this contains only a brief
> intro to notmuch-hello.
> ---
>  INSTALL |  12 +-
>  Makefile|  10 +-
>  configure   |  32 +
>  info/Makefile   |   7 ++
>  info/Makefile.local |  33 +
>  info/notmuch-emacs.texi | 324 
> 
>  6 files changed, 412 insertions(+), 6 deletions(-)
>  create mode 100644 info/Makefile
>  create mode 100644 info/Makefile.local
>  create mode 100644 info/notmuch-emacs.texi
>
> diff --git a/INSTALL b/INSTALL
> index fce9352..451bf05 100644
> --- a/INSTALL
> +++ b/INSTALL
> @@ -60,16 +60,24 @@ Talloc which are each described below:
>  
>   Talloc is available from http://talloc.samba.org/
>  
> + texinfo
> + ---
> +
> + To build the info documentation, you need makeinfo and
> + pod2texi. To install the info documentation, you need
> + install-info; these are all part of the texinfo distribution
> + as of version 5.0.
> +
>  On a modern, package-based operating system you can install all of the
>  dependencies with a simple simple command line. For example:
>  
>For Debian and similar:
>  
> -sudo apt-get install libxapian-dev libgmime-2.6-dev libtalloc-dev
> +sudo apt-get install libxapian-dev libgmime-2.6-dev libtalloc-dev 
> makeinfo texinfo
>  
>For Fedora and similar:
>  
> - sudo yum install xapian-core-devel gmime-devel libtalloc-devel
> + sudo yum install xapian-core-devel gmime-devel libtalloc-devel texinfo
>  
>  On other systems, a similar command can be used, but the details of
>  the package names may be different.
> diff --git a/Makefile b/Makefile
> index 0428160..250fbaa 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -2,10 +2,12 @@
>  # given explicitly on the command line) so mention it first.
>  all:
>  
> -# List all subdirectories here. Each contains its own Makefile.local.
> -# Use of '=', without '+=', seems to be required for out-of-tree
> -# builds to work.
> -subdirs = compat completion emacs lib man parse-time-string performance-test 
> util test

Please read the comment you're removing again! ;)

> +# List all subdirectories here. Each contains its own Makefile.local
> +subdirs := compat completion emacs lib man parse-time-string
> +subdirs += performance-test util info
> +# it seems to be important to keep test last.
> +subdirs += test
> +
>  
>  # We make all targets depend on the Makefiles themselves.
>  global_deps = Makefile Makefile.config Makefile.local \
> diff --git a/configure b/configure
> index 13b6062..e75c1d4 100755
> --- a/configure
> +++ b/configure
> @@ -376,6 +376,10 @@ if [ -z "${EMACSETCDIR}" ]; then
>  fi
>  fi
>  
> +if [ -z "${INFODIR}" ]; then
> +INFODIR='$(prefix)/share/info'
> +fi
> +
>  printf "Checking if emacs is available... "
>  if emacs --quick --batch > /dev/null 2>&1; then
>  printf "Yes.\n"
> @@ -385,6 +389,24 @@ else
>  have_emacs=0
>  fi
>  
> +printf "Checking for makeinfo... "
> +if makeinfo --version > /dev/null 2>&1; then
> +printf "Yes.\n"
> +have_makeinfo=1
> +else
> +printf "No (so will not info docs)\n"

Parse error?

> +have_makeinfo=0
> +fi
> +
> +printf "Checking for install-info... "
> +if install-info --version > /dev/null 2>&1; then
> +printf "Yes.\n"
> +have_installinfo=1
> +else
> +printf "No (so will not install info docs)\n"
> +have_installinfo=0
> +fi
> +
>  libdir_in_ldconfig=0
>  
>  printf "Checking which platform we are on... "
> @@ -740,6 +762,16 @@ emacsetcdir=${EMACSETCDIR}
>  # Whether there's an emacs binary available for byte-compiling
>  HAVE_EMACS = ${have_emacs}
>  
> +# Whether there's a makeinfo binary available to build info docs
> +HAVE_MAKEINFO = ${have_makeinfo}
> +
> +# Whether there's an install-info binary available
> +HAVE_INSTALLINFO = ${have_installinfo}
> +
> +# where to install info files
> +

Extra empty line.

> +INFODIR = ${INFODIR}
> +
>  # The directory to which desktop files should be installed
>  desktop_dir = \$(prefix)/share/applications
>  
> diff --git a/info/Makefile b/info/Makefile
> new file mode 100644
> index 000..de492a7
> --- /dev/null
> +++ b/info/Makefile
> @@ -0,0 +1,7 @@
> +# See Makefile.local for the list of files to be compiled in this
> +# directory.
> +all:
> + $(MAKE) -C .. all
> +
> +.DEFAULT:
> + $(MAKE) -C .. $@
> diff --git a/info/Makefile.local b/info/Makefile.local
> new file mode 100644
> index 000..55e9740
> --- /dev/null
> +++ b/info/Makefile.local
> @@ -0,0 +1,33 @@
> +# -*- makefile -*-
> +
> +dir := info
> +
> +texi_sources :=  $(dir)/notmuch-emacs.texi
> +emacs_info := $(texi_sources:.texi=.info)
> +
>

[Patch v3 2/3] man: partial conversion to pod.

2014-01-17 Thread David Bremner
Jani Nikula  writes:

> On Wed, 15 Jan 2014, David Bremner  wrote:
>> From: David Bremner 

> In short, I'm really tempted by using markdown as the format, not least
> because it's what we use for the web pages. The big (also literally)
> downside is pandoc (http://johnmacfarlane.net/pandoc/), the tool for
> converting markdown to man. I don't mind its dependencies, others may
> disagree. Are there any sensible alternatives to pandoc?

To complicate things, if we did decide on something heavyweight I think
I'd propose we think about rst instead of markdown. I don't rst as well
as markdown, but markdown does feel a little too adhoc to me from time
to time (e.g. a verbatim block forcing the end of a list and so on).
As far as I can tell, there are many incompatible versions of markdown
as soon as you start to want e.g. tables.

In any case, rst -> man is supported by python-docutils. sphinx supports
both man page generation and texinfo output.  So that would be relatively
lighter weight alternative (??) to pandoc.

A more radical proposal would be to skip generating info and assuming
everybody can browse html in emacs. That assumption is supposed to
become less ludicrous in emacs24.4 with the inclusion of "eww".

d


[Patch v3 1/3] info: start info documentation.

2014-01-17 Thread David Bremner
Jani Nikula  writes:

> On Wed, 15 Jan 2014, David Bremner  wrote:
>> From: David Bremner 
>>
>> Initially, just a skeleton of documentation for the emacs
>> interface. There are a few dangling references to other info pages;
>> these are to be generated from the man pages in a following commit.
>
> Is it possible to add a link to the info page from notmuch-hello?
>
> Jani.

Yep, just need to add a button that calls 

  (info "notmuch-emacs")

We could/should also add custom keybindings to other modes to invoke the
same help. For example in notmuch-search-mode we can have a binding to call

 (info "(notmuch-emacs)notmuch-search")

Let the bikeshedding over keybindings begin ;). Potentially we could
steal '?' if we made sure the key binding info was prominent.

d


Re: [Patch v3 2/3] man: partial conversion to pod.

2014-01-17 Thread Gregor Zattler
Hi David, notmuch developers,
* David Bremner  [17. Jan. 2014]:
> A more radical proposal would be to skip generating info and assuming
> everybody can browse html in emacs. That assumption is supposed to
> become less ludicrous in emacs24.4 with the inclusion of "eww".

While html-rendering is somewhat more dynamic (I wished I knew how
to build emacs info documentation with less width) and at least
in graphical environments even provides pictures, it's easier to
navigate info documentation (going "up", notion of TOC,).

I prefer info docs and do read info manuals more closely than any
documentation in any other format.

Ciao; Gregor
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [Patch v3 2/3] man: partial conversion to pod.

2014-01-17 Thread David Bremner
Jani Nikula  writes:

> On Wed, 15 Jan 2014, David Bremner  wrote:
>> From: David Bremner 

> In short, I'm really tempted by using markdown as the format, not least
> because it's what we use for the web pages. The big (also literally)
> downside is pandoc (http://johnmacfarlane.net/pandoc/), the tool for
> converting markdown to man. I don't mind its dependencies, others may
> disagree. Are there any sensible alternatives to pandoc?

To complicate things, if we did decide on something heavyweight I think
I'd propose we think about rst instead of markdown. I don't rst as well
as markdown, but markdown does feel a little too adhoc to me from time
to time (e.g. a verbatim block forcing the end of a list and so on).
As far as I can tell, there are many incompatible versions of markdown
as soon as you start to want e.g. tables.

In any case, rst -> man is supported by python-docutils. sphinx supports
both man page generation and texinfo output.  So that would be relatively
lighter weight alternative (??) to pandoc.

A more radical proposal would be to skip generating info and assuming
everybody can browse html in emacs. That assumption is supposed to
become less ludicrous in emacs24.4 with the inclusion of "eww".

d
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [Patch v3 1/3] info: start info documentation.

2014-01-17 Thread David Bremner
Jani Nikula  writes:

> On Wed, 15 Jan 2014, David Bremner  wrote:
>> From: David Bremner 
>>
>> Initially, just a skeleton of documentation for the emacs
>> interface. There are a few dangling references to other info pages;
>> these are to be generated from the man pages in a following commit.
>
> Is it possible to add a link to the info page from notmuch-hello?
>
> Jani.

Yep, just need to add a button that calls 
 
  (info "notmuch-emacs")

We could/should also add custom keybindings to other modes to invoke the
same help. For example in notmuch-search-mode we can have a binding to call

 (info "(notmuch-emacs)notmuch-search")

Let the bikeshedding over keybindings begin ;). Potentially we could
steal '?' if we made sure the key binding info was prominent.

d
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] cli: abstract common config get/set code

2014-01-17 Thread Jani Nikula
Pretty straightforward abstraction similar to get/set list.

---

v2 of id:1376839205-5115-1-git-send-email-j...@nikula.org adding a few
comments about config value caching per David's request. Dropped the
2nd patch as too tricky.
---
 notmuch-config.c | 86 +++-
 1 file changed, 35 insertions(+), 51 deletions(-)

diff --git a/notmuch-config.c b/notmuch-config.c
index 6845e3c..4aad9eb 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -496,6 +496,32 @@ notmuch_config_is_new (notmuch_config_t *config)
 return config->is_new;
 }
 
+static const char *
+_config_get (notmuch_config_t *config, char **field,
+const char *group, const char *key)
+{
+/* read from config file and cache value, if not cached already */
+if (*field == NULL) {
+   char *value;
+   value = g_key_file_get_string (config->key_file, group, key, NULL);
+   if (value) {
+   *field = talloc_strdup (config, value);
+   free (value);
+   }
+}
+return *field;
+}
+
+static void
+_config_set (notmuch_config_t *config, char **field,
+const char *group, const char *key, const char *value)
+{
+g_key_file_set_string (config->key_file, group, key, value);
+
+/* drop the cached value */
+talloc_free (*field);
+*field = NULL;
+}
 
 static const char **
 _config_get_list (notmuch_config_t *config,
@@ -504,6 +530,7 @@ _config_get_list (notmuch_config_t *config,
 {
 assert(outlist);
 
+/* read from config file and cache value, if not cached already */
 if (*outlist == NULL) {
 
char **inlist = g_key_file_get_string_list (config->key_file,
@@ -535,6 +562,8 @@ _config_set_list (notmuch_config_t *config,
  size_t length, const char ***config_var )
 {
 g_key_file_set_string_list (config->key_file, group, name, list, length);
+
+/* drop the cached value */
 talloc_free (*config_var);
 *config_var = NULL;
 }
@@ -542,85 +571,40 @@ _config_set_list (notmuch_config_t *config,
 const char *
 notmuch_config_get_database_path (notmuch_config_t *config)
 {
-char *path;
-
-if (config->database_path == NULL) {
-   path = g_key_file_get_string (config->key_file,
- "database", "path", NULL);
-   if (path) {
-   config->database_path = talloc_strdup (config, path);
-   free (path);
-   }
-}
-
-return config->database_path;
+return _config_get (config, &config->database_path, "database", "path");
 }
 
 void
 notmuch_config_set_database_path (notmuch_config_t *config,
  const char *database_path)
 {
-g_key_file_set_string (config->key_file,
-  "database", "path", database_path);
-
-talloc_free (config->database_path);
-config->database_path = NULL;
+_config_set (config, &config->database_path, "database", "path", 
database_path);
 }
 
 const char *
 notmuch_config_get_user_name (notmuch_config_t *config)
 {
-char *name;
-
-if (config->user_name == NULL) {
-   name = g_key_file_get_string (config->key_file,
- "user", "name", NULL);
-   if (name) {
-   config->user_name = talloc_strdup (config, name);
-   free (name);
-   }
-}
-
-return config->user_name;
+return _config_get (config, &config->user_name, "user", "name");
 }
 
 void
 notmuch_config_set_user_name (notmuch_config_t *config,
  const char *user_name)
 {
-g_key_file_set_string (config->key_file,
-  "user", "name", user_name);
-
-talloc_free (config->user_name);
-config->user_name = NULL;
+_config_set (config, &config->user_name, "user", "name", user_name);
 }
 
 const char *
 notmuch_config_get_user_primary_email (notmuch_config_t *config)
 {
-char *email;
-
-if (config->user_primary_email == NULL) {
-   email = g_key_file_get_string (config->key_file,
-  "user", "primary_email", NULL);
-   if (email) {
-   config->user_primary_email = talloc_strdup (config, email);
-   free (email);
-   }
-}
-
-return config->user_primary_email;
+return _config_get (config, &config->user_primary_email, "user", 
"primary_email");
 }
 
 void
 notmuch_config_set_user_primary_email (notmuch_config_t *config,
   const char *primary_email)
 {
-g_key_file_set_string (config->key_file,
-  "user", "primary_email", primary_email);
-
-talloc_free (config->user_primary_email);
-config->user_primary_email = NULL;
+_config_set (config, &config->user_primary_email, "user", "primary_email", 
primary_email);
 }
 
 const char **
-- 
1.8.5.2

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] lib: fix clang compiler warning

2014-01-17 Thread Jani Nikula
With some combination of clang and talloc, not using the return value
of talloc_steal() produces a warning. Ignore it, as talloc_steal() has
no failure modes per documentation.
---
 lib/thread.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/thread.cc b/lib/thread.cc
index 4dcf705..8f53e12 100644
--- a/lib/thread.cc
+++ b/lib/thread.cc
@@ -524,7 +524,7 @@ _notmuch_thread_create (void *ctx,
 _resolve_thread_relationships (thread);
 
 /* Commit to returning thread. */
-talloc_steal (ctx, thread);
+(void) talloc_steal (ctx, thread);
 
   DONE:
 talloc_free (local);
-- 
1.8.5.2

___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [Patch v3 1/3] info: start info documentation.

2014-01-17 Thread Jani Nikula
On Wed, 15 Jan 2014, David Bremner  wrote:
> From: David Bremner 
>
> Initially, just a skeleton of documentation for the emacs
> interface. There are a few dangling references to other info pages;
> these are to be generated from the man pages in a following commit.

Is it possible to add a link to the info page from notmuch-hello?

Jani.



>
> As far as actual documentation, so far this contains only a brief
> intro to notmuch-hello.
> ---
>  INSTALL |  12 +-
>  Makefile|  10 +-
>  configure   |  32 +
>  info/Makefile   |   7 ++
>  info/Makefile.local |  33 +
>  info/notmuch-emacs.texi | 324 
> 
>  6 files changed, 412 insertions(+), 6 deletions(-)
>  create mode 100644 info/Makefile
>  create mode 100644 info/Makefile.local
>  create mode 100644 info/notmuch-emacs.texi
>
> diff --git a/INSTALL b/INSTALL
> index fce9352..451bf05 100644
> --- a/INSTALL
> +++ b/INSTALL
> @@ -60,16 +60,24 @@ Talloc which are each described below:
>  
>   Talloc is available from http://talloc.samba.org/
>  
> + texinfo
> + ---
> +
> + To build the info documentation, you need makeinfo and
> + pod2texi. To install the info documentation, you need
> + install-info; these are all part of the texinfo distribution
> + as of version 5.0.
> +
>  On a modern, package-based operating system you can install all of the
>  dependencies with a simple simple command line. For example:
>  
>For Debian and similar:
>  
> -sudo apt-get install libxapian-dev libgmime-2.6-dev libtalloc-dev
> +sudo apt-get install libxapian-dev libgmime-2.6-dev libtalloc-dev 
> makeinfo texinfo
>  
>For Fedora and similar:
>  
> - sudo yum install xapian-core-devel gmime-devel libtalloc-devel
> + sudo yum install xapian-core-devel gmime-devel libtalloc-devel texinfo
>  
>  On other systems, a similar command can be used, but the details of
>  the package names may be different.
> diff --git a/Makefile b/Makefile
> index 0428160..250fbaa 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -2,10 +2,12 @@
>  # given explicitly on the command line) so mention it first.
>  all:
>  
> -# List all subdirectories here. Each contains its own Makefile.local.
> -# Use of '=', without '+=', seems to be required for out-of-tree
> -# builds to work.
> -subdirs = compat completion emacs lib man parse-time-string performance-test 
> util test
> +# List all subdirectories here. Each contains its own Makefile.local
> +subdirs := compat completion emacs lib man parse-time-string
> +subdirs += performance-test util info
> +# it seems to be important to keep test last.
> +subdirs += test
> +
>  
>  # We make all targets depend on the Makefiles themselves.
>  global_deps = Makefile Makefile.config Makefile.local \
> diff --git a/configure b/configure
> index 13b6062..e75c1d4 100755
> --- a/configure
> +++ b/configure
> @@ -376,6 +376,10 @@ if [ -z "${EMACSETCDIR}" ]; then
>  fi
>  fi
>  
> +if [ -z "${INFODIR}" ]; then
> +INFODIR='$(prefix)/share/info'
> +fi
> +
>  printf "Checking if emacs is available... "
>  if emacs --quick --batch > /dev/null 2>&1; then
>  printf "Yes.\n"
> @@ -385,6 +389,24 @@ else
>  have_emacs=0
>  fi
>  
> +printf "Checking for makeinfo... "
> +if makeinfo --version > /dev/null 2>&1; then
> +printf "Yes.\n"
> +have_makeinfo=1
> +else
> +printf "No (so will not info docs)\n"
> +have_makeinfo=0
> +fi
> +
> +printf "Checking for install-info... "
> +if install-info --version > /dev/null 2>&1; then
> +printf "Yes.\n"
> +have_installinfo=1
> +else
> +printf "No (so will not install info docs)\n"
> +have_installinfo=0
> +fi
> +
>  libdir_in_ldconfig=0
>  
>  printf "Checking which platform we are on... "
> @@ -740,6 +762,16 @@ emacsetcdir=${EMACSETCDIR}
>  # Whether there's an emacs binary available for byte-compiling
>  HAVE_EMACS = ${have_emacs}
>  
> +# Whether there's a makeinfo binary available to build info docs
> +HAVE_MAKEINFO = ${have_makeinfo}
> +
> +# Whether there's an install-info binary available
> +HAVE_INSTALLINFO = ${have_installinfo}
> +
> +# where to install info files
> +
> +INFODIR = ${INFODIR}
> +
>  # The directory to which desktop files should be installed
>  desktop_dir = \$(prefix)/share/applications
>  
> diff --git a/info/Makefile b/info/Makefile
> new file mode 100644
> index 000..de492a7
> --- /dev/null
> +++ b/info/Makefile
> @@ -0,0 +1,7 @@
> +# See Makefile.local for the list of files to be compiled in this
> +# directory.
> +all:
> + $(MAKE) -C .. all
> +
> +.DEFAULT:
> + $(MAKE) -C .. $@
> diff --git a/info/Makefile.local b/info/Makefile.local
> new file mode 100644
> index 000..55e9740
> --- /dev/null
> +++ b/info/Makefile.local
> @@ -0,0 +1,33 @@
> +# -*- makefile -*-
> +
> +dir := info
> +
> +texi_sources :=  $(dir)/notmuch-emacs.texi
> +emacs_info := $(texi_sources:.texi=.info)
> +
> +info := 

Re: [Patch v3 1/3] info: start info documentation.

2014-01-17 Thread Jani Nikula
On Wed, 15 Jan 2014, David Bremner  wrote:
> From: David Bremner 
>
> Initially, just a skeleton of documentation for the emacs
> interface. There are a few dangling references to other info pages;
> these are to be generated from the man pages in a following commit.
>
> As far as actual documentation, so far this contains only a brief
> intro to notmuch-hello.
> ---
>  INSTALL |  12 +-
>  Makefile|  10 +-
>  configure   |  32 +
>  info/Makefile   |   7 ++
>  info/Makefile.local |  33 +
>  info/notmuch-emacs.texi | 324 
> 
>  6 files changed, 412 insertions(+), 6 deletions(-)
>  create mode 100644 info/Makefile
>  create mode 100644 info/Makefile.local
>  create mode 100644 info/notmuch-emacs.texi
>
> diff --git a/INSTALL b/INSTALL
> index fce9352..451bf05 100644
> --- a/INSTALL
> +++ b/INSTALL
> @@ -60,16 +60,24 @@ Talloc which are each described below:
>  
>   Talloc is available from http://talloc.samba.org/
>  
> + texinfo
> + ---
> +
> + To build the info documentation, you need makeinfo and
> + pod2texi. To install the info documentation, you need
> + install-info; these are all part of the texinfo distribution
> + as of version 5.0.
> +
>  On a modern, package-based operating system you can install all of the
>  dependencies with a simple simple command line. For example:
>  
>For Debian and similar:
>  
> -sudo apt-get install libxapian-dev libgmime-2.6-dev libtalloc-dev
> +sudo apt-get install libxapian-dev libgmime-2.6-dev libtalloc-dev 
> makeinfo texinfo
>  
>For Fedora and similar:
>  
> - sudo yum install xapian-core-devel gmime-devel libtalloc-devel
> + sudo yum install xapian-core-devel gmime-devel libtalloc-devel texinfo
>  
>  On other systems, a similar command can be used, but the details of
>  the package names may be different.
> diff --git a/Makefile b/Makefile
> index 0428160..250fbaa 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -2,10 +2,12 @@
>  # given explicitly on the command line) so mention it first.
>  all:
>  
> -# List all subdirectories here. Each contains its own Makefile.local.
> -# Use of '=', without '+=', seems to be required for out-of-tree
> -# builds to work.
> -subdirs = compat completion emacs lib man parse-time-string performance-test 
> util test

Please read the comment you're removing again! ;)

> +# List all subdirectories here. Each contains its own Makefile.local
> +subdirs := compat completion emacs lib man parse-time-string
> +subdirs += performance-test util info
> +# it seems to be important to keep test last.
> +subdirs += test
> +
>  
>  # We make all targets depend on the Makefiles themselves.
>  global_deps = Makefile Makefile.config Makefile.local \
> diff --git a/configure b/configure
> index 13b6062..e75c1d4 100755
> --- a/configure
> +++ b/configure
> @@ -376,6 +376,10 @@ if [ -z "${EMACSETCDIR}" ]; then
>  fi
>  fi
>  
> +if [ -z "${INFODIR}" ]; then
> +INFODIR='$(prefix)/share/info'
> +fi
> +
>  printf "Checking if emacs is available... "
>  if emacs --quick --batch > /dev/null 2>&1; then
>  printf "Yes.\n"
> @@ -385,6 +389,24 @@ else
>  have_emacs=0
>  fi
>  
> +printf "Checking for makeinfo... "
> +if makeinfo --version > /dev/null 2>&1; then
> +printf "Yes.\n"
> +have_makeinfo=1
> +else
> +printf "No (so will not info docs)\n"

Parse error?

> +have_makeinfo=0
> +fi
> +
> +printf "Checking for install-info... "
> +if install-info --version > /dev/null 2>&1; then
> +printf "Yes.\n"
> +have_installinfo=1
> +else
> +printf "No (so will not install info docs)\n"
> +have_installinfo=0
> +fi
> +
>  libdir_in_ldconfig=0
>  
>  printf "Checking which platform we are on... "
> @@ -740,6 +762,16 @@ emacsetcdir=${EMACSETCDIR}
>  # Whether there's an emacs binary available for byte-compiling
>  HAVE_EMACS = ${have_emacs}
>  
> +# Whether there's a makeinfo binary available to build info docs
> +HAVE_MAKEINFO = ${have_makeinfo}
> +
> +# Whether there's an install-info binary available
> +HAVE_INSTALLINFO = ${have_installinfo}
> +
> +# where to install info files
> +

Extra empty line.

> +INFODIR = ${INFODIR}
> +
>  # The directory to which desktop files should be installed
>  desktop_dir = \$(prefix)/share/applications
>  
> diff --git a/info/Makefile b/info/Makefile
> new file mode 100644
> index 000..de492a7
> --- /dev/null
> +++ b/info/Makefile
> @@ -0,0 +1,7 @@
> +# See Makefile.local for the list of files to be compiled in this
> +# directory.
> +all:
> + $(MAKE) -C .. all
> +
> +.DEFAULT:
> + $(MAKE) -C .. $@
> diff --git a/info/Makefile.local b/info/Makefile.local
> new file mode 100644
> index 000..55e9740
> --- /dev/null
> +++ b/info/Makefile.local
> @@ -0,0 +1,33 @@
> +# -*- makefile -*-
> +
> +dir := info
> +
> +texi_sources :=  $(dir)/notmuch-emacs.texi
> +emacs_info := $(texi_sources:.texi=.info)
> +
>