[PATCH] devel/emacs: add devel/try-emacs-mua.sh

2015-11-01 Thread Tomi Ollila
devel/try-emacs-mua.sh provides an easy way to try and experiment with
the notmuch emacs client provided in emacs subdirectory of notmuch
source tree.

User is required to choose whether to run emacs with -q, -Q or neither
-- and experienced ones may add other command line options, like
'-f notmuch'.

This script ensures that no .el files are newer than corresponding .elc
files so that user (/developer!) does not accidentally experiment with
outdated elisp files. The emacs variable to have the same effect,
`load-prefer-newer' is not available until emacs 24.4.

The *scratch* buffer is filled with some code user can execute before
running notmuch code.
---

Addressed David's comments in id:87d1xdtim1@maritornes.cs.unb.ca
with 2 updates:
 1) removed "address completion insinuate"
 2) added code to initialize package system when using -q or -Q

 devel/try-emacs-mua.sh | 92 ++
 1 file changed, 92 insertions(+)
 create mode 100755 devel/try-emacs-mua.sh

diff --git a/devel/try-emacs-mua.sh b/devel/try-emacs-mua.sh
new file mode 100755
index ..71be152c2346
--- /dev/null
+++ b/devel/try-emacs-mua.sh
@@ -0,0 +1,92 @@
+#!/bin/sh
+
+# This script provides an easy way to try and experiment with the
+# notmuch emacs client provided in notmuch/emacs directory.
+
+set -eu
+
+test $# -gt 0 || {
+   exec >&2
+   echo
+   echo "Usage: $0 '' | q | Q [other-emacs-args]"
+   echo
+   printf "  $0 %s\n" "'' starts emacs without either -q or -Q option" \
+   "q  starts emacs with -q" \
+   "Q  starts emacs with -Q"
+   echo
+   echo Note that if there are notmuch-emacs .elc files that are older than
+   echo their corresponding .el files those older .elcs will be removed.
+   echo
+   exit 1
+}
+
+case $1 in '') opt=
+   ;; q | -q) opt=-q
+   ;; Q | -Q) opt=-Q
+   ;; *) echo "option '$1' not '', 'q' nor 'Q'" >&2; exit 1
+esac
+shift
+
+case $0 in
+   *\"*)   echo "'$0' contain one or more '\"'s" >&2; exit 1 ;;
+   */*)d0=${0%/*} ;;
+   *)  d0=.
+esac
+
+pwd=$PWD
+cd "$d0/.."
+nmd=$PWD
+emd=$PWD/emacs
+
+test -f "$nmd"/emacs/notmuch-lib.el || {
+   echo "Cannot find notmuch-emacs source directory"
+   exit 1
+}
+
+if test -x "$nmd"/notmuch
+then
+   nmin='
+To use accompanied notmuch binary from the same source, evaluate
+(setq exec-path (cons \"'"$nmd"'\" exec-path))
+Note: Evaluating the above may be followed by unintended database
+upgrade and getting back to old version may require dump & restore.
+'
+else
+   nmin=
+fi
+
+if test "$opt" = '-q' || test "$opt" = '-Q'
+then
+   pkgin='
+If you want to use packages (like company from elpa) evaluate
+(progn (require '\''package) (package-initialize))
+'
+else
+   pkgin=
+fi
+
+# ensure we don't load .elc files that are older than corresponding .el file
+# the emacs variable `load-prefer-newer' is not available until emacs 24.4
+perl -e 'use strict; use warnings;
+while (<*.elc>) {
+   my $elc = $_; s/elc$/el/;
+   if (-M $_ < -M $elc) {
+   warn "$_ is newer than $elc. Removing $elc\n";
+   unlink $elc or die "Failed to remove '\''$elc'\'': $!\n";
+   }
+}'
+
+cd "$pwd"
+
+# note: whitespace in $EMACS splits to command and args
+exec ${EMACS:-emacs} $opt -L "$emd" -l "$emd"/notmuch.el "$@" --eval '
+(with-current-buffer "*scratch*"
+  (insert "
+Go to the end of the following lines and type C-x C-e to evaluate
+(or C-j which is shorter but inserts evaluation results into buffer)
+
+To \"disable\" mail sending, evaluate
+(setq message-send-mail-function (lambda () t))
+'"$nmin$pkgin"'
+To start notmuch (hello) screen, evaluate
+(notmuch-hello)") (set-buffer-modified-p nil))'
-- 
2.0.0

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


[PATCH] Add method to reparent of message to the database.

2015-11-01 Thread Steven Allen
Currently, a message is owned by its iterator (messages object) and,
ultimately, its query. This unfortunately makes encapsulating query
logic difficult because there is no way to return a message after
disposing of the query used to find the message (other than looking it
up again in the database by id).

This patch adds a function `notmuch_message_own` that reparents a
message onto the database making it the user's job to destroy it.
---
 lib/message.cc |  6 ++
 lib/notmuch.h  | 12 
 2 files changed, 18 insertions(+)

diff --git a/lib/message.cc b/lib/message.cc
index 26b5e76..014363f 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -1657,6 +1657,12 @@ notmuch_message_thaw (notmuch_message_t *message)
 }
 
 void
+notmuch_message_own (notmuch_message_t *message)
+{
+talloc_steal(message->notmuch, message);
+}
+
+void
 notmuch_message_destroy (notmuch_message_t *message)
 {
 talloc_free (message);
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 310a8b8..c80d7aa 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -1629,6 +1629,18 @@ notmuch_message_freeze (notmuch_message_t *message);
 notmuch_status_t
 notmuch_message_thaw (notmuch_message_t *message);
 
+
+/**
+ * Reparent a notmuch_message_t object onto the database.
+ *
+ * Calling this function allows a notmuch_message_t object to outlive its
+ * query. The message will automatically be reclaimed when the database is
+ * destroyed but if you want to free its memory before then, you should call
+ * notmuch_message_destroy.
+ */
+void
+notmuch_message_own (notmuch_message_t *message);
+
 /**
  * Destroy a notmuch_message_t object.
  *
-- 
2.6.2

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


[PATCH v3] devel/release-checks: added checking of copyright year in documentation

2015-11-01 Thread Tomi Ollila
Check that copyright year will be current year in generated documentation.

Checking is done my matching that copyright line contains current year
as a substring which is good enough "approximation" in this context.
---

v3 of id:1440616236-17866-1-git-send-email-tomi.oll...@iki.fi
changed $year to 2009-$year

v2 of id:1438511187-11321-1-git-send-email-tomi.oll...@iki.fi, perhaps
addressing comments in id:87r3niwan6@maritornes.cs.unb.ca

 devel/release-checks.sh | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/devel/release-checks.sh b/devel/release-checks.sh
index 8604a9f7d10b..5802942aa975 100755
--- a/devel/release-checks.sh
+++ b/devel/release-checks.sh
@@ -175,6 +175,21 @@ case $news_date in
append_emsg "Date '$news_date' in NEWS file is not in format 
(-mm-dd)"
 esac
 
+year=`exec date +%Y`
+echo -n "Checking that copyright in documentation contains 2009-$year... "
+# Read the value of variable `copyright' defined in 'doc/conf.py'.
+# As __file__ is not defined when python command is given from command line,
+# it is defined before contents of 'doc/conf.py' (which dereferences __file__)
+# is executed.
+copyrightline=`exec python -c "with open('doc/conf.py') as cf: __file__ = ''; 
exec(cf.read()); print(copyright)"`
+case $copyrightline in
+   *2009-$year*)
+   echo Yes. ;;
+   *)
+   echo No.
+   append_emsg "The copyright in doc/conf.py line '$copyrightline' 
does not contain '2009-$year'"
+esac
+
 if [ -n "$emsgs" ]
 then
echo
-- 
2.0.0

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