Re: [PATCH] emacs: Add customization group for replying

2012-09-04 Thread Tomi Ollila
On Tue, Sep 04 2012, Michal Sojka  wrote:

> On Tue, Sep 04 2012, Tomi Ollila wrote:
>> On Tue, Sep 04 2012, Michal Sojka  wrote:
>>
>>> On Thu, Jul 26 2012, Michal Sojka wrote:
 When one wants to customize the format of reply message, there nothing
 to tell the user how to do it.  Without knowing that construction of
 reply buffer is actually implemented in the message package, it seems
 that replying cannot be customized.

 Because I was getting annoyed by the empty line the between citation
 line and the quoted message, I figured out that changing this is fairly
 easy when one knows what to customize.

 This patch adds notmuch-reply customization group that that contains
 references to the relevant customization options. The new group is easy
 to find as it is shown as a result of running "M-x customize-group RET
 notmuch RET".
>>>
>>> Ping.
>>>
>>> Any objections against applying?
>>
>> Nobody dares to say anything due to infamiliriaty of this spesific case ;/.
>>
>> I could not find any reference this has been made before.
>
> It's at least documented at
> http://www.gnu.org/software/emacs/manual/html_node/elisp/Group-Definitions.html
>
>   The argument members is a list specifying an initial set of
>   customization items to be members of the group. However, most often
>   members is nil, and you specify the group's members by using the
>   :group keyword when defining those members.
>
>> I could not find any discussion about this issue.
>>
>> With little effort I could not extract the customization tree to
>> stdout I could have attempted to grep whether there is same variable
>> in many groups.
>
> I tried to grep emacs sources and found the following:
>
> (defgroup message '((user-mail-address custom-variable)
> (defgroup gnus-message '((message custom-group))
> (defgroup ps-print-printer '((lpr custom-group))
> (defgroup customize '((widgets custom-group))
> (defgroup font-lock '((jit-lock custom-group))
>
> At least the first line corresponds exactly to what is proposed in my
> patch.

Yes...


I was looking whether the same customization variable has been put
into multiple groups (now those are also in message-insertion group like
you have in your patch). (So far) I haven't seen that to be done
(not that it forbids doing so, just that there aren't issues about that).

>From consistency point of view all the customization variables in notmuch
groups start with "notmuch-" and these "message-" breaks this... An
alternative to the above could be the following:

 (defgroup notmuch-reply
   '((notmuch-message-replied-tags custom-variable)
 (message-insertion custom-group))
  "..."

I.e. first moving notmuch-message-replied-tags to this new group
and (only) referencing the message-insertion group from notmuch-reply
group (the message-citation-line-format & message-citation-line-function
are the first variables in message-insertion group, which is nice).


> Cheers,
> -Michal

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


[PATCH v2 0/5] emacs: notmuch-hello status message refresh hook, etc

2012-09-04 Thread Jani Nikula
On Tue, 04 Sep 2012, Michal Sojka  wrote:
> On Sun, Sep 02 2012, Jani Nikula wrote:
>> Hi all, v2 of [1] addressing review comments: added NEWS, improved
>> documentation, made the query customizable.
>>
>> [1]
>> id:"37899e28dbf67e4620a53279a869be3174c02d6f.1339775602.git.jani at 
>> nikula.org"
>
> Hello Jani,
>
> if I understand correctly, the goal of this patchset is to display the
> message with the difference in the number of messages before and after
> refresh of notmuch-hello.

Difference between two refreshes of notmuch-hello to be specific.

> I think the current implementation is unnecessarily complicated. It
> would be sufficient to implement this directly in `notmuch-hello'
> without any hook. If `notmuch-hello-refresh-status-query' is nil
> (default) no message would be shown. If it is configured to something
> else, the message would be shown provided that no-display is nil. This
> way you don't have to break existing user's hooks and achieve the same
> behavior, don't you?

I think it would be useful to pass no-display to hooks anyway,
regardless of the use here. I don't see that as a big reason to do this
one way or the other. Having this implemented directly in notmuch-hello
does not make this less complicated either. The only difference would be
having an if clause within notmuch-hello rather than an option in
notmuch-hello-refresh-hook.

This leaves us the matter of style. Tomi also expressed preference for
having this built-in to notmuch-hello rather than as a hook. I like
having it as a hook for a number of reasons:

* I think it provides a nice abstract interface without messing with the
  rest of notmuch-hello.

* I think toggling hooks on and off in the customization interface is
  nice (see e.g. notmuch-show-insert-text/plain-hook under
  notmuch-show). No need to add more and more customizations for things
  that can be options.

* If the user doesn't like the messages, it's easy to copy-paste the
  code to .emacs, modify, and add-hook.

* It serves as an example of what can be done in the notmuch-hello
  hooks.

If you and Tomi still insist on not having this as a hook, changing it
is not a big deal (faster than writing this email *sigh*). But even then
I'd propose merging patches 1-3 as those allow the user to write the
kind of hook he chooses.


BR,
Jani.


[PATCH] Add notmuch-remove-duplicates.py script to contrib.

2012-09-04 Thread Dmitry Kurochkin
The script removes duplicate message files.  It takes no options.

Files are assumed duplicates if their content is the same except for
ignored headers.  Currently, the only ignored header is Received:.
---
 contrib/notmuch-remove-duplicates.py |   95 ++
 1 file changed, 95 insertions(+)
 create mode 100755 contrib/notmuch-remove-duplicates.py

diff --git a/contrib/notmuch-remove-duplicates.py 
b/contrib/notmuch-remove-duplicates.py
new file mode 100755
index 000..dbe2e25
--- /dev/null
+++ b/contrib/notmuch-remove-duplicates.py
@@ -0,0 +1,95 @@
+#!/usr/bin/env python
+
+import sys
+
+IGNORED_HEADERS = [ "Received:" ]
+
+if len(sys.argv) != 1:
+print "Usage: %s" % sys.argv[0]
+print
+print "The script removes duplicate message files.  Takes no options."
+print "Requires notmuch python module."
+print
+print "Files are assumed duplicates if their content is the same"
+print "except for the following headers: %s." % ", ".join(IGNORED_HEADERS)
+exit(1)
+
+import notmuch
+import os
+import time
+
+class MailComparator:
+"""Checks if mail files are duplicates."""
+def __init__(self, filename):
+self.filename = filename
+self.mail = self.readFile(self.filename)
+
+def isDuplicate(self, filename):
+return self.mail == self.readFile(filename)
+
+@staticmethod
+def readFile(filename):
+with open(filename) as f:
+data = ""
+while True:
+line = f.readline()
+for header in IGNORED_HEADERS:
+if line.startswith(header):
+# skip header continuation lines
+while True:
+line = f.readline()
+if len(line) == 0 or line[0] not in [" ", "\t"]:
+break
+break
+else:
+data += line
+if line == "\n":
+break
+data += f.read()
+return data
+
+db = notmuch.Database()
+query = db.create_query('*')
+print "Number of messages: %s" % query.count_messages()
+
+files_count = 0
+for root, dirs, files in os.walk(db.get_path()):
+if not root.startswith(os.path.join(db.get_path(), ".notmuch/")):
+files_count += len(files)
+print "Number of files: %s" % files_count
+print "Estimated number of duplicates: %s" % (files_count - 
query.count_messages())
+
+msgs = query.search_messages()
+msg_count = 0
+suspected_duplicates_count = 0
+duplicates_count = 0
+timestamp = time.time()
+for msg in msgs:
+msg_count += 1
+if len(msg.get_filenames()) > 1:
+filenames = msg.get_filenames()
+comparator = MailComparator(filenames.next())
+for filename in filenames:
+if os.path.realpath(comparator.filename) == 
os.path.realpath(filename):
+print "Message '%s' has filenames pointing to the same file: 
'%s' '%s'" % (msg.get_message_id(), comparator.filename, filename)
+elif comparator.isDuplicate(filename):
+os.remove(filename)
+duplicates_count += 1
+else:
+#print "Potential duplicates: %s" % msg.get_message_id()
+suspected_duplicates_count += 1
+
+new_timestamp = time.time()
+if new_timestamp - timestamp > 1:
+timestamp = new_timestamp
+sys.stdout.write("\rProcessed %s messages, removed %s duplicates..." % 
(msg_count, duplicates_count))
+sys.stdout.flush()
+
+print "\rFinished. Processed %s messages, removed %s duplicates." % 
(msg_count, duplicates_count)
+if duplicates_count > 0:
+print "You might want to run 'notmuch new' now."
+
+if suspected_duplicates_count > 0:
+print
+print "Found %s messages with duplicate IDs but different content." % 
suspected_duplicates_count
+print "Perhaps we should ignore more headers."
-- 
1.7.10.4



[PATCH] Add notmuch-remove-duplicates.py script to contrib.

2012-09-04 Thread Michal Nazarewicz
>> On Tue, Sep 04 2012, Dmitry Kurochkin wrote:
>>> +class MailComparator:
>>> +"""Checks if mail files are duplicates."""
>>> +def __init__(self, filename):
>>> +self.filename = filename
>>> +self.mail = self.readFile(self.filename)
>>> +
>>> +def isDuplicate(self, filename):
>>> +return self.mail == self.readFile(filename)
>>> +
>>> +@staticmethod
>>> +def readFile(filename):
>>> +with open(filename) as f:
>>> +data = ""
>>> +while True:
>>> +line = f.readline()
>>> +for header in IGNORED_HEADERS:
>>> +if line.startswith(header):

> Michal Nazarewicz  writes:
>> Case of headers should be ignored, but this does not ignore it.

On Tue, Sep 04 2012, Dmitry Kurochkin wrote:
> It does.

Wait, how?  If line is ?received:? how does it starts with ?Received:??

>>> +if os.path.realpath(comparator.filename) == 
>>> os.path.realpath(filename):
>>> +print "Message '%s' has filenames pointing to the
>>> same file: '%s' '%s'" % (msg.get_message_id(), comparator.filename,
>>> filename)
>>
>> So why aren't those removed?
>>
>
> Because it is the same file indexed twice (probably because of
> symlinks).  We do not want to remove the only message file.

Ah, right, with symlinks this is troublesome, but than again, we can
check if there is at least one non-symlink.  If there is, delete
everything else, if there is not, delete all but one arbitrarily chosen
symlink.

>>> +elif comparator.isDuplicate(filename):
>>> +os.remove(filename)
>>> +duplicates_count += 1
>>> +else:
>>> +#print "Potential duplicates: %s" % msg.get_message_id()
>>> +suspected_duplicates_count += 1
>>> +
>>> +new_timestamp = time.time()
>>> +if new_timestamp - timestamp > 1:
>>> +timestamp = new_timestamp
>>> +sys.stdout.write("\rProcessed %s messages, removed %s 
>>> duplicates..." % (msg_count, duplicates_count))
>>> +sys.stdout.flush()
>>> +
>>> +print "\rFinished. Processed %s messages, removed %s duplicates." % 
>>> (msg_count, duplicates_count)
>>> +if duplicates_count > 0:
>>> +print "You might want to run 'notmuch new' now."
>>> +
>>> +if suspected_duplicates_count > 0:
>>> +print
>>> +print "Found %s messages with duplicate IDs but different content." % 
>>> suspected_duplicates_count
>>> +print "Perhaps we should ignore more headers."
>>
>> Please consider the following instead (not tested):

> Thanks for reviewing my poor python code :) I am afraid I do not have
> enough interest in improving it.  I just implemented a simple solution
> for my problem.  Though it looks like you already took time to rewrite
> the script.  Would be great if you send it as a proper patch obsoleting
> this one.

Bah, I'll probably won't have time to properly test it.

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Micha? ?mina86? Nazarewicz(o o)
ooo +--ooO--(_)--Ooo--
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120904/614610cc/attachment.pgp>


[PATCH] Add notmuch-remove-duplicates.py script to contrib.

2012-09-04 Thread Michal Nazarewicz
rint "You might want to run 'notmuch new' now."
> +
> +if suspected_duplicates_count > 0:
> +print
> +print "Found %s messages with duplicate IDs but different content." % 
> suspected_duplicates_count
> +print "Perhaps we should ignore more headers."

Please consider the following instead (not tested):


#!/usr/bin/env python

import collections
import notmuch
import os
import re
import sys
import time


IGNORED_HEADERS = [ 'Received' ]


isIgnoredHeadersLine = re.compile(
r'^(?:%s)\s*:' % '|'.join(IGNORED_HEADERS),
re.IGNORECASE).search

doesStartWithWS = re.compile(r'^\s').search


def usage(argv0):
print """Usage: %s []

The script removes duplicate message files.  Takes no options."
Requires notmuch python module."

Files are assumed duplicates if their content is the same"
except for the following headers: %s.""" % (argv0, ', '.join(IGNORED_HEADERS))


def readMailFile(filename):
with open(filename) as fd:
data = []
skip_header = False
for line in fd:
if doesStartWithWS(line):
if not skip_header:
data.append(line)
elif isIgnoredHeadersLine(line):
skip_header = True
else:
data.append(line)
if line == '\n':
break
data.append(fd.read())
return ''.join(data)


def dedupMessage(msg):
filenames = msg.get_filenames()
if len(filenames) <= 1:
return (0, 0)

realpaths = collections.defaultdict(list)
contents = collections.defaultdict(list)
for filename in filenames:
real = os.path.realpath(filename)
lst = realpaths[real]
lst.append(filename)
if len(lst) == 1:
contents[readMailFile(real)].append(real)

duplicates = 0

for filenames in contents.itervalues():
if len(filenames) > 1:
print 'Files with the same content:'
print ' ', filenames.pop()
duplicates += len(filenames)
for filename in filenames:
del realpaths[filename]
# os.remane(filename)

for real, filenames in realpaths.iteritems():
if len(filenames) > 1:
print 'Files pointing to the same message:'
print ' ', filenames.pop()
duplicates += len(filenames)
# for filename in filenames:
# os.remane(filename)

return (duplicates, len(realpaths) - 1)


def dedupQuery(query):
print 'Number of messages: %s' % query.count_messages()
msg_count = 0
suspected_count = 0
duplicates_count = 0
timestamp = time.time()
msgs = query.search_messages()
for msg in msgs:
msg_count += 1
d, s = dedupMessage(msg)
duplicates_count += d
suspected_count += d

new_timestamp = time.time()
if new_timestamp - timestamp > 1:
timestamp = new_timestamp
sys.stdout.write('\rProcessed %s messages, removed %s duplicates...'
 % (msg_count, duplicates_count))
sys.stdout.flush()

print '\rFinished. Processed %s messages, removed %s duplicates.' % (
msg_count, duplicates_count)
if duplicates_count > 0:
print 'You might want to run "notmuch new" now.'

if suspected_duplicates_count > 0:
print """
Found %d messages with duplicate IDs but different content.
Perhaps we should ignore more headers.""" % suspected_count


def main(argv):
if len(argv) == 1:
query = '*'
elif len(argv) == 2:
query = argv[1]
else:
usage(argv[0])
return 1

db = notmuch.Database()
query = db.create_query(query)
dedupQuery(db, query)
return 0


if __name__ == '__main__':
sys.exit(main(sys.argv))



-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Micha? ?mina86? Nazarewicz(o o)
ooo +--ooO--(_)--Ooo--
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120904/dca6723b/attachment.pgp>


[PATCH] emacs: Add customization group for replying

2012-09-04 Thread Michal Nazarewicz
> On Tue, Sep 04 2012, Michal Nazarewicz wrote:
>> On semi-related note, does anyone know how to get rid of an empty line
>> *above* the attribution line?

On Tue, Sep 04 2012, Michal Sojka  wrote:
> It is probably caused by your configuration. I do not have any empty
> line above attribution line neither in my configuration nor when I run
> emacs with -q.

Thanks, yes, it seems to be the case.  I'll have to look at it more
closely...

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Micha? ?mina86? Nazarewicz(o o)
ooo +--ooO--(_)--Ooo--
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120904/b7041a3e/attachment-0001.pgp>


[PATCH v2 0/5] emacs: notmuch-hello status message refresh hook, etc

2012-09-04 Thread Michal Sojka
On Sun, Sep 02 2012, Jani Nikula wrote:
> Hi all, v2 of [1] addressing review comments: added NEWS, improved
> documentation, made the query customizable.
>
> [1]
> id:"37899e28dbf67e4620a53279a869be3174c02d6f.1339775602.git.jani at 
> nikula.org"

Hello Jani,

if I understand correctly, the goal of this patchset is to display the
message with the difference in the number of messages before and after
refresh of notmuch-hello.

I think the current implementation is unnecessarily complicated. It
would be sufficient to implement this directly in `notmuch-hello'
without any hook. If `notmuch-hello-refresh-status-query' is nil
(default) no message would be shown. If it is configured to something
else, the message would be shown provided that no-display is nil. This
way you don't have to break existing user's hooks and achieve the same
behavior, don't you?

-Michal


[PATCH v2 0/9] FreeBSD Support Patches

2012-09-04 Thread Mike Kelly
Thanks, I'll try to take care of the concerns with the other 2 patches
at some point, but I haven't had as much free time lately as I'd like
to have.

On Sat, Sep 1, 2012 at 10:41 PM, David Bremner  wrote:
> Mike Kelly  writes:
>
>> Hi,
>>
>> Here's a second attempt at adding FreeBSD support. Hopefully most of the
>> concerns raised about the initial patch set have been addressed.
>
> I pushed (finally) patches 1,2,4,5,6 and 8. The others either no longer
> apply, or there were some outstanding issues in the discussion on the
> list.
>
> d



-- 
Mike Kelly


[PATCH] emacs: Add customization group for replying

2012-09-04 Thread Michal Sojka
On Tue, Sep 04 2012, Michal Nazarewicz wrote:
> On Thu, Jul 26 2012, Michal Sojka wrote:
>> Because I was getting annoyed by the empty line the between citation
>> line and the quoted message, I figured out that changing this is fairly
>> easy when one knows what to customize.
>
> On semi-related note, does anyone know how to get rid of an empty line
> *above* the attribution line?

It is probably caused by your configuration. I do not have any empty
line above attribution line neither in my configuration nor when I run
emacs with -q.

-Michal


[PATCH] emacs: Add customization group for replying

2012-09-04 Thread Michal Sojka
On Tue, Sep 04 2012, Tomi Ollila wrote:
> On Tue, Sep 04 2012, Michal Sojka  wrote:
>
>> On Thu, Jul 26 2012, Michal Sojka wrote:
>>> When one wants to customize the format of reply message, there nothing
>>> to tell the user how to do it.  Without knowing that construction of
>>> reply buffer is actually implemented in the message package, it seems
>>> that replying cannot be customized.
>>>
>>> Because I was getting annoyed by the empty line the between citation
>>> line and the quoted message, I figured out that changing this is fairly
>>> easy when one knows what to customize.
>>>
>>> This patch adds notmuch-reply customization group that that contains
>>> references to the relevant customization options. The new group is easy
>>> to find as it is shown as a result of running "M-x customize-group RET
>>> notmuch RET".
>>
>> Ping.
>>
>> Any objections against applying?
>
> Nobody dares to say anything due to infamiliriaty of this spesific case ;/.
>
> I could not find any reference this has been made before.

It's at least documented at
http://www.gnu.org/software/emacs/manual/html_node/elisp/Group-Definitions.html

  The argument members is a list specifying an initial set of
  customization items to be members of the group. However, most often
  members is nil, and you specify the group's members by using the
  :group keyword when defining those members.

> I could not find any discussion about this issue.
>
> With little effort I could not extract the customization tree to
> stdout I could have attempted to grep whether there is same variable
> in many groups.

I tried to grep emacs sources and found the following:

(defgroup message '((user-mail-address custom-variable)
(defgroup gnus-message '((message custom-group))
(defgroup ps-print-printer '((lpr custom-group))
(defgroup customize '((widgets custom-group))
(defgroup font-lock '((jit-lock custom-group))

At least the first line corresponds exactly to what is proposed in my
patch.

Cheers,
-Michal


[PATCH v3 2/2] {., man}/Makefile.local: edit/remove release-checks.sh related targets

2012-09-04 Thread Tomi Ollila
Use new target release-checks in place of verify-version-debian,
verify-version-python verify-version-manpage. This target executes
devel/release-checks.sh which does all the verifications the three
dropped targets did, and some more.
---
 Makefile.local |   28 
 man/Makefile.local |9 +
 2 files changed, 5 insertions(+), 32 deletions(-)

diff --git a/Makefile.local b/Makefile.local
index de984ab..7f2d4f1 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -187,7 +187,7 @@ release-message:
 verify-source-tree-and-version: verify-no-dirty-code

 .PHONY: verify-no-dirty-code
-verify-no-dirty-code: verify-version-debian verify-version-python 
verify-version-manpage
+verify-no-dirty-code: release-checks
 ifeq ($(IS_GIT),yes)
@printf "Checking that source tree is clean..."
 ifneq ($(shell git ls-files -m),)
@@ -204,29 +204,9 @@ else
 endif
 endif

-.PHONY: verify-version-debian
-verify-version-debian: verify-version-components
-   @echo -n "Checking that Debian package version is $(VERSION)-1..."
-   @[ "$(VERSION)-1" = $$(sed '1{ s/).*//; s/.*(//; q; }' 
debian/changelog) ] || \
-   (echo "No." && \
-echo "Please edit version and debian/changelog to have 
consistent versions." && false)
-   @echo "Good."
-
-.PHONY: verify-version-python
-verify-version-python: verify-version-components
-   @echo -n "Checking that python bindings version is $(VERSION)..."
-   @[ "$(VERSION)" = $$(python -c "execfile('$(PV_FILE)'); print 
__VERSION__") ] || \
-   (echo "No." && \
-echo "Please edit version and $(PV_FILE) to have consistent 
versions." && false)
-   @echo "Good."
-
-.PHONY: verify-version-components
-verify-version-components:
-   @echo -n "Checking that $(VERSION) consists only of digits and 
periods..."
-   @echo $(VERSION) | grep -q -x '^[0-9.]*$$' || \
-   (echo "No." && \
-echo "Please follow the instructions in RELEASING to choose a 
version" && false)
-   @echo "Good."
+.PHONY: release-checks
+release-checks:
+   devel/release-checks.sh

 .PHONY: verify-newer
 verify-newer:
diff --git a/man/Makefile.local b/man/Makefile.local
index d43a949..72e2a18 100644
--- a/man/Makefile.local
+++ b/man/Makefile.local
@@ -32,7 +32,7 @@ COMPRESSED_MAN := $(MAN1_GZ) $(MAN5_GZ) $(MAN7_GZ)
 %.gz: %
gzip --stdout $^ > $@

-.PHONY: install-man update-man-versions verify-version-manpage
+.PHONY: install-man update-man-versions

 install-man: $(COMPRESSED_MAN)
mkdir -p "$(DESTDIR)$(mandir)/man1"
@@ -43,13 +43,6 @@ install-man: $(COMPRESSED_MAN)
install -m0644 $(MAN7_GZ) $(DESTDIR)/$(mandir)/man7
cd $(DESTDIR)/$(mandir)/man1 && ln -sf notmuch.1.gz notmuch-setup.1.gz

-verify-version-manpage: verify-version-components
-   @echo -n "Checking that manual page version is $(VERSION)..."
-   @[ "$(VERSION)" = $$(sed -n '/^[.]TH NOTMUCH 1/{s/.*"Notmuch 
//;s/".*//p;}' $(MAIN_PAGE)) ] || \
-   (echo "No." && \
-echo "Please edit version and notmuch.1 to have consistent 
versions." && false)
-   @echo "Good."
-
 update-man-versions: $(MAN_SOURCE)
for file in $(MAN_SOURCE); do \
cp $$file $$file.bak ; \
-- 
1.7.1



[PATCH v3 1/2] devel: add release-checks.sh

2012-09-04 Thread Tomi Ollila
Currently Makefile.local contains some machine executable release
checking functionality. This is unnecessarily complex way to do it:

Multiline script functionality is hard to embed -- from Makefile point
of view there is just one line split using backslashes and every line
ends with ';'. It is hard to maintain such "script" when it gets longer.

The embedded script does not fail as robust as separate script; set -eu
could be added to get same level of robustness -- but the provided
Bourne Again Shell (bash) script exceeds this with 'set -o pipefail',
making the script to fail when any of the commands in pipeline fails
(and not just the last one).

Checking for release is done very seldom compared to all other use;
The whole Makefile.local gets simpler and easier to grasp when most
release checking targets are removed.

When release checking is done, the steps are executed sequentially;
nothing is allowed to be skipped due to some satisfied dependency.
---
 devel/release-checks.sh |  209 +++
 1 files changed, 209 insertions(+), 0 deletions(-)
 create mode 100755 devel/release-checks.sh

diff --git a/devel/release-checks.sh b/devel/release-checks.sh
new file mode 100755
index 000..e1d19f2
--- /dev/null
+++ b/devel/release-checks.sh
@@ -0,0 +1,209 @@
+#!/usr/bin/env bash
+
+set -eu
+#set -x # or enter bash -x ... on command line
+
+if [ x"${BASH_VERSION-}" = x ]
+then   echo
+   echo "Please execute this script using 'bash' interpreter"
+   echo
+   exit 1
+fi
+
+set -o posix
+set -o pipefail # bash feature
+
+# Avoid locale-specific differences in output of executed commands
+LANG=C LC_ALL=C; export LANG LC_ALL
+
+readonly PV_FILE='bindings/python/notmuch/version.py'
+
+# Using array here turned out to be unnecessarily complicated
+emsgs=''
+append_emsg ()
+{
+   emsgs="${emsgs:+$emsgs\n}  $1"
+}
+
+for f in ./version debian/changelog NEWS "$PV_FILE"
+do
+   if   [ ! -f "$f" ]; then append_emsg "File '$f' is missing"
+   elif [ ! -r "$f" ]; then append_emsg "File '$f' is unreadable"
+   elif [ ! -s "$f" ]; then append_emsg "File '$f' is empty"
+   fi
+done
+
+if [ -n "$emsgs" ]
+then
+   echo 'Release files problems; fix these and try again:'
+   echo -e "$emsgs"
+   exit 1
+fi
+
+if read VERSION
+then
+   if read rest
+   thenecho "'version' file contains more than one line"
+   exit 1
+   fi
+else
+   echo "Reading './version' file failed (suprisingly!)"
+   exit 1
+fi < ./version
+
+readonly VERSION
+
+verfail ()
+{
+   echo No.
+   echo "$@"
+   echo "Please follow the instructions in RELEASING to choose a version"
+   exit 1
+}
+
+echo -n "Checking that '$VERSION' is good with digits and periods... "
+case $VERSION in
+   *[^0-9.]*)
+   verfail "'$VERSION' contains other characters than digits and 
periods" ;;
+   .*) verfail "'$VERSION' begins with a period" ;;
+   *.) verfail "'$VERSION' ends with a period" ;;
+   *..*)   verfail "'$VERSION' contains two consecutive periods" ;;
+   *.*)echo Yes. ;;
+   *)  verfail "'$VERSION' is a single number" ;;
+esac
+
+
+# In the rest of this file, tests collect list of errors to be fixed
+
+echo -n "Checking that this is Debian package for notmuch... "
+read deb_notmuch deb_version rest < debian/changelog
+if [ "$deb_notmuch" = 'notmuch' ]
+then
+   echo Yes.
+else
+   echo No.
+   append_emsg "Package name '$deb_notmuch' is not 'notmuch' in 
debian/changelog"
+fi
+
+echo -n "Checking that Debian package version is $VERSION-1... "
+
+if [ "$deb_version" = "($VERSION-1)" ]
+then
+   echo Yes.
+else
+   echo No.
+   append_emsg "Version '$deb_version' is not '($VERSION-1)' in 
debian/changelog"
+fi
+
+echo -n "Checking that python bindings version is $VERSION... "
+py_version=`python -c "execfile('$PV_FILE'); print __VERSION__"`
+if [ "$py_version" = "$VERSION" ]
+then
+   echo Yes.
+else
+   echo No.
+   append_emsg "Version '$py_version' is not '$VERSION' in $PV_FILE"
+fi
+
+echo -n "Checking that this is Notmuch NEWS... "
+read news_notmuch news_version news_date < NEWS
+if [ "$news_notmuch" = "Notmuch" ]
+then
+   echo Yes.
+else
+   echo No.
+   append_emsg "First word '$news_notmuch' is not 'Notmuch' in NEWS file"
+fi
+
+echo -n "Checking that NEWS version is $VERSION... "
+if [ "$news_version" = "$VERSION" ]
+then
+   echo Yes.
+else
+   echo No.
+   append_emsg "Version '$news_version' in NEWS file is not '$VERSION'"
+fi
+
+#eval `date '+year=%Y mon=%m day=%d'`
+today0utc=`date --date=0Z +%s` # gnu date feature
+
+echo -n "Checking that NEWS date is right... "
+case $news_date in
+ '('[2-9][0-9][0-9][0-9]-[01][0-9]-[0123][0-9]')')
+   newsdate0utc=`nd=${news_date#\\(}; date --date="${nd%)} 0Z" +%s`
+   ddiff=$((newsdate0utc - today0utc))
+   if [ $ddiff -lt -86400 ] # since beginning of yest

Release checks v3

2012-09-04 Thread Tomi Ollila
This if V3 of release-check.sh patches, displacing

id:"1346491928-2356-1-git-send-email-tomi.ollila at iki.fi"

Changes:

Bash kept, mainly for pipefail -- and that possible future pipeline 
additions have more protection.

Added set -o posix lessens drifts to more bashishms -- and somewhere was 
mentioned that posix mode provides a bit more robust pipefail...

Changed that one short circuit & continues to if... elif... fi construct.

Used  *[^0-9.]*) for matching non-digit and non-dot characters; this
was really nice one.

One formatting change (added newline).

Removed last 'exit 0'.

---

Something related: Some good pages for shell differences can be browsed at
http://www.in-ulm.de/~mascheck/

Diffdiff of the changes follows:

--- v2/release-checks.sh
+++ v3/release-checks.sh
@@ -10,13 +10,12 @@ thenecho
exit 1
 fi

+set -o posix
 set -o pipefail # bash feature

 # Avoid locale-specific differences in output of executed commands
 LANG=C LC_ALL=C; export LANG LC_ALL

-readonly DEFAULT_IFS="$IFS"
-
 readonly PV_FILE='bindings/python/notmuch/version.py'

 # Using array here turned out to be unnecessarily complicated
@@ -28,9 +27,10 @@ append_emsg ()

 for f in ./version debian/changelog NEWS "$PV_FILE"
 do
-   test -f $f || { append_emsg "File '$f' is missing"; continue; }
-   test -r $f || { append_emsg "File '$f' is unreadable"; continue; }
-   test -s $f ||   append_emsg "File '$f' is empty"
+   if   [ ! -f "$f" ]; then append_emsg "File '$f' is missing"
+   elif [ ! -r "$f" ]; then append_emsg "File '$f' is unreadable"
+   elif [ ! -s "$f" ]; then append_emsg "File '$f' is empty"
+   fi
 done

 if [ -n "$emsgs" ]
@@ -62,18 +62,15 @@ verfail ()
 }

 echo -n "Checking that '$VERSION' is good with digits and periods... "
-if [ -z "${VERSION//[0123456789.]/}" ] # bash feature
-then
-   case $VERSION in
-   .*) verfail "'$VERSION' begins with a period" ;;
-   *.) verfail "'$VERSION' ends with a period" ;;
-   *..*)   verfail "'$VERSION' contains two consecutive periods" ;;
-   *.*)echo Yes. ;;
-   *)  verfail "'$VERSION' is a single number" ;;
-   esac
-else
-   verfail "'$VERSION' contains other characters than digits and periods"
-fi
+case $VERSION in
+   *[^0-9.]*)
+   verfail "'$VERSION' contains other characters than digits and 
periods" ;;
+   .*) verfail "'$VERSION' begins with a period" ;;
+   *.) verfail "'$VERSION' ends with a period" ;;
+   *..*)   verfail "'$VERSION' contains two consecutive periods" ;;
+   *.*)echo Yes. ;;
+   *)  verfail "'$VERSION' is a single number" ;;
+esac


 # In the rest of this file, tests collect list of errors to be fixed
@@ -168,7 +165,9 @@ manfiles=`find man -type f | sort`
 man_pages_ok=Yes
 for mp in $manfiles
 do
-   case $mp in *.[0-9]) ;; # fall below this 'case ... esac'
+   case $mp in
+   *.[0-9]) ;; # fall below this 'case ... esac'
+
*/Makefile.local | */Makefile ) continue ;;
*/.gitignore)   continue ;;
*.bak)  continue ;;
@@ -201,7 +200,6 @@ echo 'All checks this script executed completed 
successfully.'
 echo 'Make sure that everything else mentioned in RELEASING'
 echo 'file is in order, too.'

-exit 0

 # Local variables:
 # mode: shell-script




Release checks v3

2012-09-04 Thread Michal Nazarewicz
On Tue, Sep 04 2012, Tomi Ollila wrote:
> This if V3 of release-check.sh patches, displacing
>
> id:"1346491928-2356-1-git-send-email-tomi.ollila at iki.fi"
>
> Changes:
>
> Bash kept, mainly for pipefail -- and that possible future pipeline 
> additions have more protection.
>
> Added set -o posix lessens drifts to more bashishms -- and somewhere was 
> mentioned that posix mode provides a bit more robust pipefail...
>
> Changed that one short circuit & continues to if... elif... fi construct.
>
> Used  *[^0-9.]*) for matching non-digit and non-dot characters; this
> was really nice one.
>
> One formatting change (added newline).
>
> Removed last 'exit 0'.

Looks good to me.

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Micha? ?mina86? Nazarewicz(o o)
ooo +--ooO--(_)--Ooo--
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120904/17975933/attachment.pgp>


[PATCH] emacs: Add customization group for replying

2012-09-04 Thread Michal Nazarewicz
On Thu, Jul 26 2012, Michal Sojka wrote:
> Because I was getting annoyed by the empty line the between citation
> line and the quoted message, I figured out that changing this is fairly
> easy when one knows what to customize.

On semi-related note, does anyone know how to get rid of an empty line
*above* the attribution line?

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Micha? ?mina86? Nazarewicz(o o)
ooo +--ooO--(_)--Ooo--
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120904/3a23c6a8/attachment.pgp>


Re: [PATCH] Add notmuch-remove-duplicates.py script to contrib.

2012-09-04 Thread Dmitry Kurochkin
Michal Nazarewicz  writes:

>>> On Tue, Sep 04 2012, Dmitry Kurochkin wrote:
 +class MailComparator:
 +"""Checks if mail files are duplicates."""
 +def __init__(self, filename):
 +self.filename = filename
 +self.mail = self.readFile(self.filename)
 +
 +def isDuplicate(self, filename):
 +return self.mail == self.readFile(filename)
 +
 +@staticmethod
 +def readFile(filename):
 +with open(filename) as f:
 +data = ""
 +while True:
 +line = f.readline()
 +for header in IGNORED_HEADERS:
 +if line.startswith(header):
>
>> Michal Nazarewicz  writes:
>>> Case of headers should be ignored, but this does not ignore it.
>
> On Tue, Sep 04 2012, Dmitry Kurochkin wrote:
>> It does.
>
> Wait, how?  If line is “received:” how does it starts with “Received:”?
>

Sorry, I misunderstood your comment.  It does not ignore the case indeed.

 +if os.path.realpath(comparator.filename) == 
 os.path.realpath(filename):
 +print "Message '%s' has filenames pointing to the
 same file: '%s' '%s'" % (msg.get_message_id(), comparator.filename,
 filename)
>>>
>>> So why aren't those removed?
>>>
>>
>> Because it is the same file indexed twice (probably because of
>> symlinks).  We do not want to remove the only message file.
>
> Ah, right, with symlinks this is troublesome, but than again, we can
> check if there is at least one non-symlink.  If there is, delete
> everything else, if there is not, delete all but one arbitrarily chosen
> symlink.
>

Sure, we could do that.

 +elif comparator.isDuplicate(filename):
 +os.remove(filename)
 +duplicates_count += 1
 +else:
 +#print "Potential duplicates: %s" % msg.get_message_id()
 +suspected_duplicates_count += 1
 +
 +new_timestamp = time.time()
 +if new_timestamp - timestamp > 1:
 +timestamp = new_timestamp
 +sys.stdout.write("\rProcessed %s messages, removed %s 
 duplicates..." % (msg_count, duplicates_count))
 +sys.stdout.flush()
 +
 +print "\rFinished. Processed %s messages, removed %s duplicates." % 
 (msg_count, duplicates_count)
 +if duplicates_count > 0:
 +print "You might want to run 'notmuch new' now."
 +
 +if suspected_duplicates_count > 0:
 +print
 +print "Found %s messages with duplicate IDs but different content." % 
 suspected_duplicates_count
 +print "Perhaps we should ignore more headers."
>>>
>>> Please consider the following instead (not tested):
>
>> Thanks for reviewing my poor python code :) I am afraid I do not have
>> enough interest in improving it.  I just implemented a simple solution
>> for my problem.  Though it looks like you already took time to rewrite
>> the script.  Would be great if you send it as a proper patch obsoleting
>> this one.
>
> Bah, I'll probably won't have time to properly test it.
>

Same problem :)

Regards,
  Dmitry

> -- 
> Best regards, _ _
> .o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
> ..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
> ooo +--ooO--(_)--Ooo--
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v2 0/5] emacs: notmuch-hello status message refresh hook, etc

2012-09-04 Thread Jani Nikula
On Tue, 04 Sep 2012, Michal Sojka  wrote:
> On Sun, Sep 02 2012, Jani Nikula wrote:
>> Hi all, v2 of [1] addressing review comments: added NEWS, improved
>> documentation, made the query customizable.
>>
>> [1]
>> 
>> id:"37899e28dbf67e4620a53279a869be3174c02d6f.1339775602.git.j...@nikula.org"
>
> Hello Jani,
>
> if I understand correctly, the goal of this patchset is to display the
> message with the difference in the number of messages before and after
> refresh of notmuch-hello.

Difference between two refreshes of notmuch-hello to be specific.

> I think the current implementation is unnecessarily complicated. It
> would be sufficient to implement this directly in `notmuch-hello'
> without any hook. If `notmuch-hello-refresh-status-query' is nil
> (default) no message would be shown. If it is configured to something
> else, the message would be shown provided that no-display is nil. This
> way you don't have to break existing user's hooks and achieve the same
> behavior, don't you?

I think it would be useful to pass no-display to hooks anyway,
regardless of the use here. I don't see that as a big reason to do this
one way or the other. Having this implemented directly in notmuch-hello
does not make this less complicated either. The only difference would be
having an if clause within notmuch-hello rather than an option in
notmuch-hello-refresh-hook.

This leaves us the matter of style. Tomi also expressed preference for
having this built-in to notmuch-hello rather than as a hook. I like
having it as a hook for a number of reasons:

* I think it provides a nice abstract interface without messing with the
  rest of notmuch-hello.

* I think toggling hooks on and off in the customization interface is
  nice (see e.g. notmuch-show-insert-text/plain-hook under
  notmuch-show). No need to add more and more customizations for things
  that can be options.

* If the user doesn't like the messages, it's easy to copy-paste the
  code to .emacs, modify, and add-hook.

* It serves as an example of what can be done in the notmuch-hello
  hooks.

If you and Tomi still insist on not having this as a hook, changing it
is not a big deal (faster than writing this email *sigh*). But even then
I'd propose merging patches 1-3 as those allow the user to write the
kind of hook he chooses.


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


Re: [PATCH] Add notmuch-remove-duplicates.py script to contrib.

2012-09-04 Thread Michal Nazarewicz
>> On Tue, Sep 04 2012, Dmitry Kurochkin wrote:
>>> +class MailComparator:
>>> +"""Checks if mail files are duplicates."""
>>> +def __init__(self, filename):
>>> +self.filename = filename
>>> +self.mail = self.readFile(self.filename)
>>> +
>>> +def isDuplicate(self, filename):
>>> +return self.mail == self.readFile(filename)
>>> +
>>> +@staticmethod
>>> +def readFile(filename):
>>> +with open(filename) as f:
>>> +data = ""
>>> +while True:
>>> +line = f.readline()
>>> +for header in IGNORED_HEADERS:
>>> +if line.startswith(header):

> Michal Nazarewicz  writes:
>> Case of headers should be ignored, but this does not ignore it.

On Tue, Sep 04 2012, Dmitry Kurochkin wrote:
> It does.

Wait, how?  If line is “received:” how does it starts with “Received:”?

>>> +if os.path.realpath(comparator.filename) == 
>>> os.path.realpath(filename):
>>> +print "Message '%s' has filenames pointing to the
>>> same file: '%s' '%s'" % (msg.get_message_id(), comparator.filename,
>>> filename)
>>
>> So why aren't those removed?
>>
>
> Because it is the same file indexed twice (probably because of
> symlinks).  We do not want to remove the only message file.

Ah, right, with symlinks this is troublesome, but than again, we can
check if there is at least one non-symlink.  If there is, delete
everything else, if there is not, delete all but one arbitrarily chosen
symlink.

>>> +elif comparator.isDuplicate(filename):
>>> +os.remove(filename)
>>> +duplicates_count += 1
>>> +else:
>>> +#print "Potential duplicates: %s" % msg.get_message_id()
>>> +suspected_duplicates_count += 1
>>> +
>>> +new_timestamp = time.time()
>>> +if new_timestamp - timestamp > 1:
>>> +timestamp = new_timestamp
>>> +sys.stdout.write("\rProcessed %s messages, removed %s 
>>> duplicates..." % (msg_count, duplicates_count))
>>> +sys.stdout.flush()
>>> +
>>> +print "\rFinished. Processed %s messages, removed %s duplicates." % 
>>> (msg_count, duplicates_count)
>>> +if duplicates_count > 0:
>>> +print "You might want to run 'notmuch new' now."
>>> +
>>> +if suspected_duplicates_count > 0:
>>> +print
>>> +print "Found %s messages with duplicate IDs but different content." % 
>>> suspected_duplicates_count
>>> +print "Perhaps we should ignore more headers."
>>
>> Please consider the following instead (not tested):

> Thanks for reviewing my poor python code :) I am afraid I do not have
> enough interest in improving it.  I just implemented a simple solution
> for my problem.  Though it looks like you already took time to rewrite
> the script.  Would be great if you send it as a proper patch obsoleting
> this one.

Bah, I'll probably won't have time to properly test it.

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +--ooO--(_)--Ooo--

pgphELIVAND14.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] Add notmuch-remove-duplicates.py script to contrib.

2012-09-04 Thread Dmitry Kurochkin
Hi Michal.

Michal Nazarewicz  writes:

> On Tue, Sep 04 2012, Dmitry Kurochkin wrote:
>> The script removes duplicate message files.  It takes no options.
>>
>> Files are assumed duplicates if their content is the same except for
>> ignored headers.  Currently, the only ignored header is Received:.
>> ---
>>  contrib/notmuch-remove-duplicates.py |   95 
>> ++
>>  1 file changed, 95 insertions(+)
>>  create mode 100755 contrib/notmuch-remove-duplicates.py
>>
>> diff --git a/contrib/notmuch-remove-duplicates.py 
>> b/contrib/notmuch-remove-duplicates.py
>> new file mode 100755
>> index 000..dbe2e25
>> --- /dev/null
>> +++ b/contrib/notmuch-remove-duplicates.py
>> @@ -0,0 +1,95 @@
>> +#!/usr/bin/env python
>> +
>> +import sys
>> +
>> +IGNORED_HEADERS = [ "Received:" ]
>> +
>> +if len(sys.argv) != 1:
>> +print "Usage: %s" % sys.argv[0]
>> +print
>> +print "The script removes duplicate message files.  Takes no options."
>> +print "Requires notmuch python module."
>> +print
>> +print "Files are assumed duplicates if their content is the same"
>> +print "except for the following headers: %s." % ", 
>> ".join(IGNORED_HEADERS)
>> +exit(1)
>
> It's much better put inside a main() function, which is than called only
> if the script is run directly.
>

Good point.  My python skill is pretty low :)

>> +
>> +import notmuch
>> +import os
>> +import time
>> +
>> +class MailComparator:
>> +"""Checks if mail files are duplicates."""
>> +def __init__(self, filename):
>> +self.filename = filename
>> +self.mail = self.readFile(self.filename)
>> +
>> +def isDuplicate(self, filename):
>> +return self.mail == self.readFile(filename)
>> +
>> +@staticmethod
>> +def readFile(filename):
>> +with open(filename) as f:
>> +data = ""
>> +while True:
>> +line = f.readline()
>> +for header in IGNORED_HEADERS:
>> +if line.startswith(header):
>
> Case of headers should be ignored, but this does not ignore it.
>

It does.

>> +# skip header continuation lines
>> +while True:
>> +line = f.readline()
>> +if len(line) == 0 or line[0] not in [" ", "\t"]:
>> +break
>> +break
>
> This will ignore line just after the ignored header.
>

The first header line is ignored as well because line is added to data
in else block.

>> +else:
>> +data += line
>> +if line == "\n":
>> +break
>> +data += f.read()
>> +return data
>> +
>> +db = notmuch.Database()
>> +query = db.create_query('*')
>> +print "Number of messages: %s" % query.count_messages()
>> +
>> +files_count = 0
>> +for root, dirs, files in os.walk(db.get_path()):
>> +if not root.startswith(os.path.join(db.get_path(), ".notmuch/")):
>> +files_count += len(files)
>> +print "Number of files: %s" % files_count
>> +print "Estimated number of duplicates: %s" % (files_count - 
>> query.count_messages())
>> +
>> +msgs = query.search_messages()
>> +msg_count = 0
>> +suspected_duplicates_count = 0
>> +duplicates_count = 0
>> +timestamp = time.time()
>> +for msg in msgs:
>> +msg_count += 1
>> +if len(msg.get_filenames()) > 1:
>> +filenames = msg.get_filenames()
>> +comparator = MailComparator(filenames.next())
>> +for filename in filenames:
>
> Strictly speaking, you need to compare each file to each file, and not
> just every file to the first file.
>
>> +if os.path.realpath(comparator.filename) == 
>> os.path.realpath(filename):
>> +print "Message '%s' has filenames pointing to the
>> same file: '%s' '%s'" % (msg.get_message_id(), comparator.filename,
>> filename)
>
> So why aren't those removed?
>

Because it is the same file indexed twice (probably because of
symlinks).  We do not want to remove the only message file.

>> +elif comparator.isDuplicate(filename):
>> +os.remove(filename)
>> +duplicates_count += 1
>> +else:
>> +#print "Potential duplicates: %s" % msg.get_message_id()
>> +suspected_duplicates_count += 1
>> +
>> +new_timestamp = time.time()
>> +if new_timestamp - timestamp > 1:
>> +timestamp = new_timestamp
>> +sys.stdout.write("\rProcessed %s messages, removed %s 
>> duplicates..." % (msg_count, duplicates_count))
>> +sys.stdout.flush()
>> +
>> +print "\rFinished. Processed %s messages, removed %s duplicates." % 
>> (msg_count, duplicates_count)
>> +if duplicates_count > 0:
>> +print "You might want to run 'notmuch new' now."
>> +
>> +if suspected_duplicates_count > 0:
>> +print
>> +print "Found %s messages with duplicate IDs but different 

Re: [PATCH] Add notmuch-remove-duplicates.py script to contrib.

2012-09-04 Thread Michal Nazarewicz
On Tue, Sep 04 2012, Dmitry Kurochkin wrote:
> The script removes duplicate message files.  It takes no options.
>
> Files are assumed duplicates if their content is the same except for
> ignored headers.  Currently, the only ignored header is Received:.
> ---
>  contrib/notmuch-remove-duplicates.py |   95 
> ++
>  1 file changed, 95 insertions(+)
>  create mode 100755 contrib/notmuch-remove-duplicates.py
>
> diff --git a/contrib/notmuch-remove-duplicates.py 
> b/contrib/notmuch-remove-duplicates.py
> new file mode 100755
> index 000..dbe2e25
> --- /dev/null
> +++ b/contrib/notmuch-remove-duplicates.py
> @@ -0,0 +1,95 @@
> +#!/usr/bin/env python
> +
> +import sys
> +
> +IGNORED_HEADERS = [ "Received:" ]
> +
> +if len(sys.argv) != 1:
> +print "Usage: %s" % sys.argv[0]
> +print
> +print "The script removes duplicate message files.  Takes no options."
> +print "Requires notmuch python module."
> +print
> +print "Files are assumed duplicates if their content is the same"
> +print "except for the following headers: %s." % ", 
> ".join(IGNORED_HEADERS)
> +exit(1)

It's much better put inside a main() function, which is than called only
if the script is run directly.

> +
> +import notmuch
> +import os
> +import time
> +
> +class MailComparator:
> +"""Checks if mail files are duplicates."""
> +def __init__(self, filename):
> +self.filename = filename
> +self.mail = self.readFile(self.filename)
> +
> +def isDuplicate(self, filename):
> +return self.mail == self.readFile(filename)
> +
> +@staticmethod
> +def readFile(filename):
> +with open(filename) as f:
> +data = ""
> +while True:
> +line = f.readline()
> +for header in IGNORED_HEADERS:
> +if line.startswith(header):

Case of headers should be ignored, but this does not ignore it.

> +# skip header continuation lines
> +while True:
> +line = f.readline()
> +if len(line) == 0 or line[0] not in [" ", "\t"]:
> +break
> +break

This will ignore line just after the ignored header.

> +else:
> +data += line
> +if line == "\n":
> +break
> +data += f.read()
> +return data
> +
> +db = notmuch.Database()
> +query = db.create_query('*')
> +print "Number of messages: %s" % query.count_messages()
> +
> +files_count = 0
> +for root, dirs, files in os.walk(db.get_path()):
> +if not root.startswith(os.path.join(db.get_path(), ".notmuch/")):
> +files_count += len(files)
> +print "Number of files: %s" % files_count
> +print "Estimated number of duplicates: %s" % (files_count - 
> query.count_messages())
> +
> +msgs = query.search_messages()
> +msg_count = 0
> +suspected_duplicates_count = 0
> +duplicates_count = 0
> +timestamp = time.time()
> +for msg in msgs:
> +msg_count += 1
> +if len(msg.get_filenames()) > 1:
> +filenames = msg.get_filenames()
> +comparator = MailComparator(filenames.next())
> +for filename in filenames:

Strictly speaking, you need to compare each file to each file, and not
just every file to the first file.

> +if os.path.realpath(comparator.filename) == 
> os.path.realpath(filename):
> +print "Message '%s' has filenames pointing to the
> same file: '%s' '%s'" % (msg.get_message_id(), comparator.filename,
> filename)

So why aren't those removed?

> +elif comparator.isDuplicate(filename):
> +os.remove(filename)
> +duplicates_count += 1
> +else:
> +#print "Potential duplicates: %s" % msg.get_message_id()
> +suspected_duplicates_count += 1
> +
> +new_timestamp = time.time()
> +if new_timestamp - timestamp > 1:
> +timestamp = new_timestamp
> +sys.stdout.write("\rProcessed %s messages, removed %s duplicates..." 
> % (msg_count, duplicates_count))
> +sys.stdout.flush()
> +
> +print "\rFinished. Processed %s messages, removed %s duplicates." % 
> (msg_count, duplicates_count)
> +if duplicates_count > 0:
> +print "You might want to run 'notmuch new' now."
> +
> +if suspected_duplicates_count > 0:
> +print
> +print "Found %s messages with duplicate IDs but different content." % 
> suspected_duplicates_count
> +print "Perhaps we should ignore more headers."

Please consider the following instead (not tested):


#!/usr/bin/env python

import collections
import notmuch
import os
import re
import sys
import time


IGNORED_HEADERS = [ 'Received' ]


isIgnoredHeadersLine = re.compile(
r'^(?:%s)\s*:' % '|'.join(IGNORED_HEADERS),
re.IGNORECASE).search

doesStartWithWS = re.compile(r'^\s').search


def usage(ar

[PATCH] emacs: Add customization group for replying

2012-09-04 Thread Tomi Ollila
On Tue, Sep 04 2012, Michal Sojka  wrote:

> On Thu, Jul 26 2012, Michal Sojka wrote:
>> When one wants to customize the format of reply message, there nothing
>> to tell the user how to do it.  Without knowing that construction of
>> reply buffer is actually implemented in the message package, it seems
>> that replying cannot be customized.
>>
>> Because I was getting annoyed by the empty line the between citation
>> line and the quoted message, I figured out that changing this is fairly
>> easy when one knows what to customize.
>>
>> This patch adds notmuch-reply customization group that that contains
>> references to the relevant customization options. The new group is easy
>> to find as it is shown as a result of running "M-x customize-group RET
>> notmuch RET".
>
> Ping.
>
> Any objections against applying?

Nobody dares to say anything due to infamiliriaty of this spesific case ;/.

I could not find any reference this has been made before.

I could not find any discussion about this issue.

With little effort I could not extract the customization tree to
stdout I could have attempted to grep whether there is same variable
in many groups.

The code in custom.el & cus-edit.el is so complex I could not figure
out whether there is any problems having variable in many groups
(put apparently the changed variable is not written twice to the
customization block).

I do like the feature but with this knowledge I have I just cannot 
promote applying (I sure am not against :)

> -Michal

Tomi


Re: Bug (?) difference 24.1 and 23.3.1

2012-09-04 Thread Svend Sorensen
Tomi Ollila  writes:

> On Fri, Aug 03 2012, Svend Sorensen  wrote:
>
>>
>> I was also getting an error about gnus-inhibit-images when running emacs
>> 24. Adding (require 'gnus-art) to my emacs config fixed the problem.
>
> Where is your emacs24 from? From Debian sid?

I was using the emacs-snapshot package on Debian squeeze when I ran into
this problem. I am now using the emacs-snapshot package on Debian
testing (wheezy).

http://emacs.naquadah.org/

Svend

> David has some gnus-inhibit-images related tests failing on his
> system and he is using emacs24 from debian sid. My
> gnus-inhibit-images related emacs24 tests don't fail (I've compiled
> emacs 24.1 & emacs 24.2 from source). Also buildbot at
> http://notmuch.hocat.ca/builders/master-emacs24/builds/173
> have now successful build (we assume it uses emacs24 from gentoo
> -- until Tom verifies this).
>
>>
>> http://notmuchmail.org/pipermail/notmuch/2012/008405.html
>>
>> Svend
>
> Tomi
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Bug (?) difference 24.1 and 23.3.1

2012-09-04 Thread Svend Sorensen
Tomi Ollila  writes:

> On Fri, Aug 03 2012, Svend Sorensen  wrote:
>
>>
>> I was also getting an error about gnus-inhibit-images when running emacs
>> 24. Adding (require 'gnus-art) to my emacs config fixed the problem.
>
> Where is your emacs24 from? From Debian sid?

I was using the emacs-snapshot package on Debian squeeze when I ran into
this problem. I am now using the emacs-snapshot package on Debian
testing (wheezy).

http://emacs.naquadah.org/

Svend

> David has some gnus-inhibit-images related tests failing on his
> system and he is using emacs24 from debian sid. My
> gnus-inhibit-images related emacs24 tests don't fail (I've compiled
> emacs 24.1 & emacs 24.2 from source). Also buildbot at
> http://notmuch.hocat.ca/builders/master-emacs24/builds/173
> have now successful build (we assume it uses emacs24 from gentoo
> -- until Tom verifies this).
>
>>
>> http://notmuchmail.org/pipermail/notmuch/2012/008405.html
>>
>> Svend
>
> Tomi


[PATCH] Add notmuch-remove-duplicates.py script to contrib.

2012-09-04 Thread Dmitry Kurochkin
The script removes duplicate message files.  It takes no options.

Files are assumed duplicates if their content is the same except for
ignored headers.  Currently, the only ignored header is Received:.
---
 contrib/notmuch-remove-duplicates.py |   95 ++
 1 file changed, 95 insertions(+)
 create mode 100755 contrib/notmuch-remove-duplicates.py

diff --git a/contrib/notmuch-remove-duplicates.py 
b/contrib/notmuch-remove-duplicates.py
new file mode 100755
index 000..dbe2e25
--- /dev/null
+++ b/contrib/notmuch-remove-duplicates.py
@@ -0,0 +1,95 @@
+#!/usr/bin/env python
+
+import sys
+
+IGNORED_HEADERS = [ "Received:" ]
+
+if len(sys.argv) != 1:
+print "Usage: %s" % sys.argv[0]
+print
+print "The script removes duplicate message files.  Takes no options."
+print "Requires notmuch python module."
+print
+print "Files are assumed duplicates if their content is the same"
+print "except for the following headers: %s." % ", ".join(IGNORED_HEADERS)
+exit(1)
+
+import notmuch
+import os
+import time
+
+class MailComparator:
+"""Checks if mail files are duplicates."""
+def __init__(self, filename):
+self.filename = filename
+self.mail = self.readFile(self.filename)
+
+def isDuplicate(self, filename):
+return self.mail == self.readFile(filename)
+
+@staticmethod
+def readFile(filename):
+with open(filename) as f:
+data = ""
+while True:
+line = f.readline()
+for header in IGNORED_HEADERS:
+if line.startswith(header):
+# skip header continuation lines
+while True:
+line = f.readline()
+if len(line) == 0 or line[0] not in [" ", "\t"]:
+break
+break
+else:
+data += line
+if line == "\n":
+break
+data += f.read()
+return data
+
+db = notmuch.Database()
+query = db.create_query('*')
+print "Number of messages: %s" % query.count_messages()
+
+files_count = 0
+for root, dirs, files in os.walk(db.get_path()):
+if not root.startswith(os.path.join(db.get_path(), ".notmuch/")):
+files_count += len(files)
+print "Number of files: %s" % files_count
+print "Estimated number of duplicates: %s" % (files_count - 
query.count_messages())
+
+msgs = query.search_messages()
+msg_count = 0
+suspected_duplicates_count = 0
+duplicates_count = 0
+timestamp = time.time()
+for msg in msgs:
+msg_count += 1
+if len(msg.get_filenames()) > 1:
+filenames = msg.get_filenames()
+comparator = MailComparator(filenames.next())
+for filename in filenames:
+if os.path.realpath(comparator.filename) == 
os.path.realpath(filename):
+print "Message '%s' has filenames pointing to the same file: 
'%s' '%s'" % (msg.get_message_id(), comparator.filename, filename)
+elif comparator.isDuplicate(filename):
+os.remove(filename)
+duplicates_count += 1
+else:
+#print "Potential duplicates: %s" % msg.get_message_id()
+suspected_duplicates_count += 1
+
+new_timestamp = time.time()
+if new_timestamp - timestamp > 1:
+timestamp = new_timestamp
+sys.stdout.write("\rProcessed %s messages, removed %s duplicates..." % 
(msg_count, duplicates_count))
+sys.stdout.flush()
+
+print "\rFinished. Processed %s messages, removed %s duplicates." % 
(msg_count, duplicates_count)
+if duplicates_count > 0:
+print "You might want to run 'notmuch new' now."
+
+if suspected_duplicates_count > 0:
+print
+print "Found %s messages with duplicate IDs but different content." % 
suspected_duplicates_count
+print "Perhaps we should ignore more headers."
-- 
1.7.10.4

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


Re: [PATCH] emacs: Add customization group for replying

2012-09-04 Thread Michal Nazarewicz
> On Tue, Sep 04 2012, Michal Nazarewicz wrote:
>> On semi-related note, does anyone know how to get rid of an empty line
>> *above* the attribution line?

On Tue, Sep 04 2012, Michal Sojka  wrote:
> It is probably caused by your configuration. I do not have any empty
> line above attribution line neither in my configuration nor when I run
> emacs with -q.

Thanks, yes, it seems to be the case.  I'll have to look at it more
closely...

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +--ooO--(_)--Ooo--

pgpSmwm6rwuis.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v2 0/5] emacs: notmuch-hello status message refresh hook, etc

2012-09-04 Thread Michal Sojka
On Sun, Sep 02 2012, Jani Nikula wrote:
> Hi all, v2 of [1] addressing review comments: added NEWS, improved
> documentation, made the query customizable.
>
> [1]
> 
> id:"37899e28dbf67e4620a53279a869be3174c02d6f.1339775602.git.j...@nikula.org"

Hello Jani,

if I understand correctly, the goal of this patchset is to display the
message with the difference in the number of messages before and after
refresh of notmuch-hello.

I think the current implementation is unnecessarily complicated. It
would be sufficient to implement this directly in `notmuch-hello'
without any hook. If `notmuch-hello-refresh-status-query' is nil
(default) no message would be shown. If it is configured to something
else, the message would be shown provided that no-display is nil. This
way you don't have to break existing user's hooks and achieve the same
behavior, don't you?

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


[PATCH] emacs: Add customization group for replying

2012-09-04 Thread Michal Sojka
On Thu, Jul 26 2012, Michal Sojka wrote:
> When one wants to customize the format of reply message, there nothing
> to tell the user how to do it.  Without knowing that construction of
> reply buffer is actually implemented in the message package, it seems
> that replying cannot be customized.
>
> Because I was getting annoyed by the empty line the between citation
> line and the quoted message, I figured out that changing this is fairly
> easy when one knows what to customize.
>
> This patch adds notmuch-reply customization group that that contains
> references to the relevant customization options. The new group is easy
> to find as it is shown as a result of running "M-x customize-group RET
> notmuch RET".

Ping.

Any objections against applying?

-Michal


Re: [PATCH] emacs: Add customization group for replying

2012-09-04 Thread Michal Sojka
On Tue, Sep 04 2012, Michal Nazarewicz wrote:
> On Thu, Jul 26 2012, Michal Sojka wrote:
>> Because I was getting annoyed by the empty line the between citation
>> line and the quoted message, I figured out that changing this is fairly
>> easy when one knows what to customize.
>
> On semi-related note, does anyone know how to get rid of an empty line
> *above* the attribution line?

It is probably caused by your configuration. I do not have any empty
line above attribution line neither in my configuration nor when I run
emacs with -q.

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


Re: [PATCH] emacs: Add customization group for replying

2012-09-04 Thread Michal Sojka
On Tue, Sep 04 2012, Tomi Ollila wrote:
> On Tue, Sep 04 2012, Michal Sojka  wrote:
>
>> On Thu, Jul 26 2012, Michal Sojka wrote:
>>> When one wants to customize the format of reply message, there nothing
>>> to tell the user how to do it.  Without knowing that construction of
>>> reply buffer is actually implemented in the message package, it seems
>>> that replying cannot be customized.
>>>
>>> Because I was getting annoyed by the empty line the between citation
>>> line and the quoted message, I figured out that changing this is fairly
>>> easy when one knows what to customize.
>>>
>>> This patch adds notmuch-reply customization group that that contains
>>> references to the relevant customization options. The new group is easy
>>> to find as it is shown as a result of running "M-x customize-group RET
>>> notmuch RET".
>>
>> Ping.
>>
>> Any objections against applying?
>
> Nobody dares to say anything due to infamiliriaty of this spesific case ;/.
>
> I could not find any reference this has been made before.

It's at least documented at
http://www.gnu.org/software/emacs/manual/html_node/elisp/Group-Definitions.html

  The argument members is a list specifying an initial set of
  customization items to be members of the group. However, most often
  members is nil, and you specify the group's members by using the
  :group keyword when defining those members.

> I could not find any discussion about this issue.
>
> With little effort I could not extract the customization tree to
> stdout I could have attempted to grep whether there is same variable
> in many groups.

I tried to grep emacs sources and found the following:

(defgroup message '((user-mail-address custom-variable)
(defgroup gnus-message '((message custom-group))
(defgroup ps-print-printer '((lpr custom-group))
(defgroup customize '((widgets custom-group))
(defgroup font-lock '((jit-lock custom-group))

At least the first line corresponds exactly to what is proposed in my
patch.

Cheers,
-Michal
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: Release checks v3

2012-09-04 Thread Michal Nazarewicz
On Tue, Sep 04 2012, Tomi Ollila wrote:
> This if V3 of release-check.sh patches, displacing
>
> id:"1346491928-2356-1-git-send-email-tomi.oll...@iki.fi"
>
> Changes:
>
> Bash kept, mainly for pipefail -- and that possible future pipeline 
> additions have more protection.
>
> Added set -o posix lessens drifts to more bashishms -- and somewhere was 
> mentioned that posix mode provides a bit more robust pipefail...
>
> Changed that one short circuit & continues to if... elif... fi construct.
>
> Used  *[^0-9.]*) for matching non-digit and non-dot characters; this
> was really nice one.
>
> One formatting change (added newline).
>
> Removed last 'exit 0'.

Looks good to me.

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +--ooO--(_)--Ooo--

pgpcP5aV0AeKV.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 0/6] emacs: customization for tag changes on archive

2012-09-04 Thread Mark Walters

Hi

The overall series looks good to me +1. 

I do like the slight tweak suggested by Michal in
id:"xa1tipbvwdb0.fsf at mina86.com" (but don't feel strongly). Also,
ideally there should be some tests, particularly for the multiple tag
case as I imagine most people will just have a single tag so breakage
would be unnoticed.

However, neither of these should hold up the series.

Finally:

> An interesting by-product is that you can filter your mail into multiple
> different inboxes, each with their own inbox tag, and (after you setup
> `notmuch-archive-tags') you can read and archive each inbox separately
> with built-in archiving functions.

I am assuming that you are suggesting adding -inbox1 -inbox2 etc to
notmuch-archive-tags? So the "unarchive" option will not work in this
case? (This is *definitely* not a complaint: just a query in case I am
missing something)

Best wishes

Mark

>
> BR,
> Jani.
>
>
> Jani Nikula (6):
>   emacs: add helper for tag change list manipulation
>   emacs: fix notmuch-message-replied-tags defcustom type
>   emacs: use new tag change helper to mark messages as replied
>   emacs: add support for custom tag changes on message/thread archive
>   emacs: add support for reversing notmuch-search-archive-thread tag
> changes
>   emacs: add support for reversing notmuch-show-mark-read tag changes
>
>  emacs/notmuch-lib.el |   14 
>  emacs/notmuch-message.el |   26 ++
>  emacs/notmuch-show.el|   54 
> +++---
>  emacs/notmuch-tag.el |   17 +++
>  emacs/notmuch.el |   16 ++
>  5 files changed, 91 insertions(+), 36 deletions(-)
>
> -- 
> 1.7.9.5
>
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


Release checks v3

2012-09-04 Thread Tomi Ollila
This if V3 of release-check.sh patches, displacing

id:"1346491928-2356-1-git-send-email-tomi.oll...@iki.fi"

Changes:

Bash kept, mainly for pipefail -- and that possible future pipeline 
additions have more protection.

Added set -o posix lessens drifts to more bashishms -- and somewhere was 
mentioned that posix mode provides a bit more robust pipefail...

Changed that one short circuit & continues to if... elif... fi construct.

Used  *[^0-9.]*) for matching non-digit and non-dot characters; this
was really nice one.

One formatting change (added newline).

Removed last 'exit 0'.

---

Something related: Some good pages for shell differences can be browsed at
http://www.in-ulm.de/~mascheck/

Diffdiff of the changes follows:

--- v2/release-checks.sh
+++ v3/release-checks.sh
@@ -10,13 +10,12 @@ thenecho
exit 1
 fi
 
+set -o posix
 set -o pipefail # bash feature
 
 # Avoid locale-specific differences in output of executed commands
 LANG=C LC_ALL=C; export LANG LC_ALL
 
-readonly DEFAULT_IFS="$IFS"
-
 readonly PV_FILE='bindings/python/notmuch/version.py'
 
 # Using array here turned out to be unnecessarily complicated
@@ -28,9 +27,10 @@ append_emsg ()
 
 for f in ./version debian/changelog NEWS "$PV_FILE"
 do
-   test -f $f || { append_emsg "File '$f' is missing"; continue; }
-   test -r $f || { append_emsg "File '$f' is unreadable"; continue; }
-   test -s $f ||   append_emsg "File '$f' is empty"
+   if   [ ! -f "$f" ]; then append_emsg "File '$f' is missing"
+   elif [ ! -r "$f" ]; then append_emsg "File '$f' is unreadable"
+   elif [ ! -s "$f" ]; then append_emsg "File '$f' is empty"
+   fi
 done
 
 if [ -n "$emsgs" ]
@@ -62,18 +62,15 @@ verfail ()
 }
 
 echo -n "Checking that '$VERSION' is good with digits and periods... "
-if [ -z "${VERSION//[0123456789.]/}" ] # bash feature
-then
-   case $VERSION in
-   .*) verfail "'$VERSION' begins with a period" ;;
-   *.) verfail "'$VERSION' ends with a period" ;;
-   *..*)   verfail "'$VERSION' contains two consecutive periods" ;;
-   *.*)echo Yes. ;;
-   *)  verfail "'$VERSION' is a single number" ;;
-   esac
-else
-   verfail "'$VERSION' contains other characters than digits and periods"
-fi
+case $VERSION in
+   *[^0-9.]*)
+   verfail "'$VERSION' contains other characters than digits and 
periods" ;;
+   .*) verfail "'$VERSION' begins with a period" ;;
+   *.) verfail "'$VERSION' ends with a period" ;;
+   *..*)   verfail "'$VERSION' contains two consecutive periods" ;;
+   *.*)echo Yes. ;;
+   *)  verfail "'$VERSION' is a single number" ;;
+esac
 
 
 # In the rest of this file, tests collect list of errors to be fixed
@@ -168,7 +165,9 @@ manfiles=`find man -type f | sort`
 man_pages_ok=Yes
 for mp in $manfiles
 do
-   case $mp in *.[0-9]) ;; # fall below this 'case ... esac'
+   case $mp in
+   *.[0-9]) ;; # fall below this 'case ... esac'
+
*/Makefile.local | */Makefile ) continue ;;
*/.gitignore)   continue ;;
*.bak)  continue ;;
@@ -201,7 +200,6 @@ echo 'All checks this script executed completed 
successfully.'
 echo 'Make sure that everything else mentioned in RELEASING'
 echo 'file is in order, too.'
 
-exit 0
 
 # Local variables:
 # mode: shell-script


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


[PATCH v3 1/2] devel: add release-checks.sh

2012-09-04 Thread Tomi Ollila
Currently Makefile.local contains some machine executable release
checking functionality. This is unnecessarily complex way to do it:

Multiline script functionality is hard to embed -- from Makefile point
of view there is just one line split using backslashes and every line
ends with ';'. It is hard to maintain such "script" when it gets longer.

The embedded script does not fail as robust as separate script; set -eu
could be added to get same level of robustness -- but the provided
Bourne Again Shell (bash) script exceeds this with 'set -o pipefail',
making the script to fail when any of the commands in pipeline fails
(and not just the last one).

Checking for release is done very seldom compared to all other use;
The whole Makefile.local gets simpler and easier to grasp when most
release checking targets are removed.

When release checking is done, the steps are executed sequentially;
nothing is allowed to be skipped due to some satisfied dependency.
---
 devel/release-checks.sh |  209 +++
 1 files changed, 209 insertions(+), 0 deletions(-)
 create mode 100755 devel/release-checks.sh

diff --git a/devel/release-checks.sh b/devel/release-checks.sh
new file mode 100755
index 000..e1d19f2
--- /dev/null
+++ b/devel/release-checks.sh
@@ -0,0 +1,209 @@
+#!/usr/bin/env bash
+
+set -eu
+#set -x # or enter bash -x ... on command line
+
+if [ x"${BASH_VERSION-}" = x ]
+then   echo
+   echo "Please execute this script using 'bash' interpreter"
+   echo
+   exit 1
+fi
+
+set -o posix
+set -o pipefail # bash feature
+
+# Avoid locale-specific differences in output of executed commands
+LANG=C LC_ALL=C; export LANG LC_ALL
+
+readonly PV_FILE='bindings/python/notmuch/version.py'
+
+# Using array here turned out to be unnecessarily complicated
+emsgs=''
+append_emsg ()
+{
+   emsgs="${emsgs:+$emsgs\n}  $1"
+}
+
+for f in ./version debian/changelog NEWS "$PV_FILE"
+do
+   if   [ ! -f "$f" ]; then append_emsg "File '$f' is missing"
+   elif [ ! -r "$f" ]; then append_emsg "File '$f' is unreadable"
+   elif [ ! -s "$f" ]; then append_emsg "File '$f' is empty"
+   fi
+done
+
+if [ -n "$emsgs" ]
+then
+   echo 'Release files problems; fix these and try again:'
+   echo -e "$emsgs"
+   exit 1
+fi
+
+if read VERSION
+then
+   if read rest
+   thenecho "'version' file contains more than one line"
+   exit 1
+   fi
+else
+   echo "Reading './version' file failed (suprisingly!)"
+   exit 1
+fi < ./version
+
+readonly VERSION
+
+verfail ()
+{
+   echo No.
+   echo "$@"
+   echo "Please follow the instructions in RELEASING to choose a version"
+   exit 1
+}
+
+echo -n "Checking that '$VERSION' is good with digits and periods... "
+case $VERSION in
+   *[^0-9.]*)
+   verfail "'$VERSION' contains other characters than digits and 
periods" ;;
+   .*) verfail "'$VERSION' begins with a period" ;;
+   *.) verfail "'$VERSION' ends with a period" ;;
+   *..*)   verfail "'$VERSION' contains two consecutive periods" ;;
+   *.*)echo Yes. ;;
+   *)  verfail "'$VERSION' is a single number" ;;
+esac
+
+
+# In the rest of this file, tests collect list of errors to be fixed
+
+echo -n "Checking that this is Debian package for notmuch... "
+read deb_notmuch deb_version rest < debian/changelog
+if [ "$deb_notmuch" = 'notmuch' ]
+then
+   echo Yes.
+else
+   echo No.
+   append_emsg "Package name '$deb_notmuch' is not 'notmuch' in 
debian/changelog"
+fi
+
+echo -n "Checking that Debian package version is $VERSION-1... "
+
+if [ "$deb_version" = "($VERSION-1)" ]
+then
+   echo Yes.
+else
+   echo No.
+   append_emsg "Version '$deb_version' is not '($VERSION-1)' in 
debian/changelog"
+fi
+
+echo -n "Checking that python bindings version is $VERSION... "
+py_version=`python -c "execfile('$PV_FILE'); print __VERSION__"`
+if [ "$py_version" = "$VERSION" ]
+then
+   echo Yes.
+else
+   echo No.
+   append_emsg "Version '$py_version' is not '$VERSION' in $PV_FILE"
+fi
+
+echo -n "Checking that this is Notmuch NEWS... "
+read news_notmuch news_version news_date < NEWS
+if [ "$news_notmuch" = "Notmuch" ]
+then
+   echo Yes.
+else
+   echo No.
+   append_emsg "First word '$news_notmuch' is not 'Notmuch' in NEWS file"
+fi
+
+echo -n "Checking that NEWS version is $VERSION... "
+if [ "$news_version" = "$VERSION" ]
+then
+   echo Yes.
+else
+   echo No.
+   append_emsg "Version '$news_version' in NEWS file is not '$VERSION'"
+fi
+
+#eval `date '+year=%Y mon=%m day=%d'`
+today0utc=`date --date=0Z +%s` # gnu date feature
+
+echo -n "Checking that NEWS date is right... "
+case $news_date in
+ '('[2-9][0-9][0-9][0-9]-[01][0-9]-[0123][0-9]')')
+   newsdate0utc=`nd=${news_date#\\(}; date --date="${nd%)} 0Z" +%s`
+   ddiff=$((newsdate0utc - today0utc))
+   if [ $ddiff -lt -86400 ] # since beginning of yest

[PATCH v3 2/2] {., man}/Makefile.local: edit/remove release-checks.sh related targets

2012-09-04 Thread Tomi Ollila
Use new target release-checks in place of verify-version-debian,
verify-version-python verify-version-manpage. This target executes
devel/release-checks.sh which does all the verifications the three
dropped targets did, and some more.
---
 Makefile.local |   28 
 man/Makefile.local |9 +
 2 files changed, 5 insertions(+), 32 deletions(-)

diff --git a/Makefile.local b/Makefile.local
index de984ab..7f2d4f1 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -187,7 +187,7 @@ release-message:
 verify-source-tree-and-version: verify-no-dirty-code
 
 .PHONY: verify-no-dirty-code
-verify-no-dirty-code: verify-version-debian verify-version-python 
verify-version-manpage
+verify-no-dirty-code: release-checks
 ifeq ($(IS_GIT),yes)
@printf "Checking that source tree is clean..."
 ifneq ($(shell git ls-files -m),)
@@ -204,29 +204,9 @@ else
 endif
 endif
 
-.PHONY: verify-version-debian
-verify-version-debian: verify-version-components
-   @echo -n "Checking that Debian package version is $(VERSION)-1..."
-   @[ "$(VERSION)-1" = $$(sed '1{ s/).*//; s/.*(//; q; }' 
debian/changelog) ] || \
-   (echo "No." && \
-echo "Please edit version and debian/changelog to have 
consistent versions." && false)
-   @echo "Good."
-
-.PHONY: verify-version-python
-verify-version-python: verify-version-components
-   @echo -n "Checking that python bindings version is $(VERSION)..."
-   @[ "$(VERSION)" = $$(python -c "execfile('$(PV_FILE)'); print 
__VERSION__") ] || \
-   (echo "No." && \
-echo "Please edit version and $(PV_FILE) to have consistent 
versions." && false)
-   @echo "Good."
-
-.PHONY: verify-version-components
-verify-version-components:
-   @echo -n "Checking that $(VERSION) consists only of digits and 
periods..."
-   @echo $(VERSION) | grep -q -x '^[0-9.]*$$' || \
-   (echo "No." && \
-echo "Please follow the instructions in RELEASING to choose a 
version" && false)
-   @echo "Good."
+.PHONY: release-checks
+release-checks:
+   devel/release-checks.sh
 
 .PHONY: verify-newer
 verify-newer:
diff --git a/man/Makefile.local b/man/Makefile.local
index d43a949..72e2a18 100644
--- a/man/Makefile.local
+++ b/man/Makefile.local
@@ -32,7 +32,7 @@ COMPRESSED_MAN := $(MAN1_GZ) $(MAN5_GZ) $(MAN7_GZ)
 %.gz: %
gzip --stdout $^ > $@
 
-.PHONY: install-man update-man-versions verify-version-manpage
+.PHONY: install-man update-man-versions
 
 install-man: $(COMPRESSED_MAN)
mkdir -p "$(DESTDIR)$(mandir)/man1"
@@ -43,13 +43,6 @@ install-man: $(COMPRESSED_MAN)
install -m0644 $(MAN7_GZ) $(DESTDIR)/$(mandir)/man7
cd $(DESTDIR)/$(mandir)/man1 && ln -sf notmuch.1.gz notmuch-setup.1.gz
 
-verify-version-manpage: verify-version-components
-   @echo -n "Checking that manual page version is $(VERSION)..."
-   @[ "$(VERSION)" = $$(sed -n '/^[.]TH NOTMUCH 1/{s/.*"Notmuch 
//;s/".*//p;}' $(MAIN_PAGE)) ] || \
-   (echo "No." && \
-echo "Please edit version and notmuch.1 to have consistent 
versions." && false)
-   @echo "Good."
-
 update-man-versions: $(MAN_SOURCE)
for file in $(MAN_SOURCE); do \
cp $$file $$file.bak ; \
-- 
1.7.1

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


Re: [PATCH] emacs: Add customization group for replying

2012-09-04 Thread Michal Nazarewicz
On Thu, Jul 26 2012, Michal Sojka wrote:
> Because I was getting annoyed by the empty line the between citation
> line and the quoted message, I figured out that changing this is fairly
> easy when one knows what to customize.

On semi-related note, does anyone know how to get rid of an empty line
*above* the attribution line?

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +--ooO--(_)--Ooo--

pgpgRJFZLFe9B.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: Add customization group for replying

2012-09-04 Thread Tomi Ollila
On Tue, Sep 04 2012, Michal Sojka  wrote:

> On Thu, Jul 26 2012, Michal Sojka wrote:
>> When one wants to customize the format of reply message, there nothing
>> to tell the user how to do it.  Without knowing that construction of
>> reply buffer is actually implemented in the message package, it seems
>> that replying cannot be customized.
>>
>> Because I was getting annoyed by the empty line the between citation
>> line and the quoted message, I figured out that changing this is fairly
>> easy when one knows what to customize.
>>
>> This patch adds notmuch-reply customization group that that contains
>> references to the relevant customization options. The new group is easy
>> to find as it is shown as a result of running "M-x customize-group RET
>> notmuch RET".
>
> Ping.
>
> Any objections against applying?

Nobody dares to say anything due to infamiliriaty of this spesific case ;/.

I could not find any reference this has been made before.

I could not find any discussion about this issue.

With little effort I could not extract the customization tree to
stdout I could have attempted to grep whether there is same variable
in many groups.

The code in custom.el & cus-edit.el is so complex I could not figure
out whether there is any problems having variable in many groups
(put apparently the changed variable is not written twice to the
customization block).

I do like the feature but with this knowledge I have I just cannot 
promote applying (I sure am not against :)

> -Michal

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


Re: [PATCH] emacs: Add customization group for replying

2012-09-04 Thread Michal Sojka
On Thu, Jul 26 2012, Michal Sojka wrote:
> When one wants to customize the format of reply message, there nothing
> to tell the user how to do it.  Without knowing that construction of
> reply buffer is actually implemented in the message package, it seems
> that replying cannot be customized.
>
> Because I was getting annoyed by the empty line the between citation
> line and the quoted message, I figured out that changing this is fairly
> easy when one knows what to customize.
>
> This patch adds notmuch-reply customization group that that contains
> references to the relevant customization options. The new group is easy
> to find as it is shown as a result of running "M-x customize-group RET
> notmuch RET".

Ping.

Any objections against applying?

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


Re: [PATCH 0/6] emacs: customization for tag changes on archive

2012-09-04 Thread Mark Walters

Hi

The overall series looks good to me +1. 

I do like the slight tweak suggested by Michal in
id:"xa1tipbvwdb0@mina86.com" (but don't feel strongly). Also,
ideally there should be some tests, particularly for the multiple tag
case as I imagine most people will just have a single tag so breakage
would be unnoticed.

However, neither of these should hold up the series.

Finally:

> An interesting by-product is that you can filter your mail into multiple
> different inboxes, each with their own inbox tag, and (after you setup
> `notmuch-archive-tags') you can read and archive each inbox separately
> with built-in archiving functions.

I am assuming that you are suggesting adding -inbox1 -inbox2 etc to
notmuch-archive-tags? So the "unarchive" option will not work in this
case? (This is *definitely* not a complaint: just a query in case I am
missing something)

Best wishes

Mark

>
> BR,
> Jani.
>
>
> Jani Nikula (6):
>   emacs: add helper for tag change list manipulation
>   emacs: fix notmuch-message-replied-tags defcustom type
>   emacs: use new tag change helper to mark messages as replied
>   emacs: add support for custom tag changes on message/thread archive
>   emacs: add support for reversing notmuch-search-archive-thread tag
> changes
>   emacs: add support for reversing notmuch-show-mark-read tag changes
>
>  emacs/notmuch-lib.el |   14 
>  emacs/notmuch-message.el |   26 ++
>  emacs/notmuch-show.el|   54 
> +++---
>  emacs/notmuch-tag.el |   17 +++
>  emacs/notmuch.el |   16 ++
>  5 files changed, 91 insertions(+), 36 deletions(-)
>
> -- 
> 1.7.9.5
>
> ___
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch