Re: [PATCH v2] Free the results of scandir()

2012-02-07 Thread Jani Nikula
On Tue,  7 Feb 2012 01:50:05 -0500, Ethan Glasser-Camp  
wrote:
> From: Ethan Glasser-Camp 
> 
> scandir() returns "strings allocated via malloc(3)" which are then
> "collected in array namelist which is allocated via
> malloc(3)". Currently we just free the array namelist. Instead, free
> all the entries of namelist, and then free namelist.
> 
> entry only points to elements of namelist, so we don't free it
> separately.

Looks good. Thanks, Ethan.

David, I'm not sure if this is worth a bugfix release on its own, but
definitely worth including if something else comes up.

id:"2flfwhht87d@diskless.uio.no" is a report about potential memory
leak in notmuch new from a few months back. CC Petter, the reporter.

> ---
> 
> Fixes the other use of scandir in count_files. Thanks, Jani.
> 
>  notmuch-new.c |   16 ++--
>  1 files changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/notmuch-new.c b/notmuch-new.c
> index a569a54..e62560b 100644
> --- a/notmuch-new.c
> +++ b/notmuch-new.c
> @@ -559,12 +559,14 @@ add_files_recursive (notmuch_database_t *notmuch,
>DONE:
>  if (next)
>   talloc_free (next);
> -if (entry)
> - free (entry);
>  if (dir)
>   closedir (dir);
> -if (fs_entries)
> +if (fs_entries){
> + for (i = 0; i < num_fs_entries; i++){
> + free (fs_entries[i]);
> + }
>   free (fs_entries);
> +}
>  if (db_subdirs)
>   notmuch_filenames_destroy (db_subdirs);
>  if (db_files)
> @@ -704,10 +706,12 @@ count_files (const char *path, int *count)
>  }
>  
>DONE:
> -if (entry)
> - free (entry);
> -if (fs_entries)
> +if (fs_entries){
> + for (i = 0; i < num_fs_entries; i++){
> + free (fs_entries[i]);
> + }
>  free (fs_entries);
> +}
>  }
>  
>  static void
> -- 
> 1.7.5.4
> 
> ___
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v2] Free the results of scandir()

2012-02-07 Thread Dmitry Kurochkin
Hi Ethan.

On Tue,  7 Feb 2012 01:50:05 -0500, Ethan Glasser-Camp  
wrote:
> From: Ethan Glasser-Camp 
> 
> scandir() returns "strings allocated via malloc(3)" which are then
> "collected in array namelist which is allocated via
> malloc(3)". Currently we just free the array namelist. Instead, free
> all the entries of namelist, and then free namelist.
> 
> entry only points to elements of namelist, so we don't free it
> separately.
> ---
> 
> Fixes the other use of scandir in count_files. Thanks, Jani.
> 

Few style comments below.  Otherwise looks good.

>  notmuch-new.c |   16 ++--
>  1 files changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/notmuch-new.c b/notmuch-new.c
> index a569a54..e62560b 100644
> --- a/notmuch-new.c
> +++ b/notmuch-new.c
> @@ -559,12 +559,14 @@ add_files_recursive (notmuch_database_t *notmuch,
>DONE:
>  if (next)
>   talloc_free (next);
> -if (entry)
> - free (entry);
>  if (dir)
>   closedir (dir);
> -if (fs_entries)
> +if (fs_entries){

Please add a space before '{'.

> + for (i = 0; i < num_fs_entries; i++){
> + free (fs_entries[i]);
> + }

Please remove "{}" around one line block.

>   free (fs_entries);
> +}
>  if (db_subdirs)
>   notmuch_filenames_destroy (db_subdirs);
>  if (db_files)
> @@ -704,10 +706,12 @@ count_files (const char *path, int *count)
>  }
>  
>DONE:
> -if (entry)
> - free (entry);
> -if (fs_entries)
> +if (fs_entries){
> + for (i = 0; i < num_fs_entries; i++){
> + free (fs_entries[i]);
> + }

Same two comments here.

Regards,
  Dmitry

>  free (fs_entries);
> +}
>  }
>  
>  static void
> -- 
> 1.7.5.4
> 
> ___
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v3 0/2] use text properties rather than overlays

2012-02-07 Thread David Edmondson
v3:
- Undo mistaken minor edit - no functional change.

David Edmondson (2):
  emacs: Use text properties rather than overlays in
`notmuch-show-mode'.
  test: Update test to match previous patch.

 emacs/notmuch-show.el  |   62 +---
 emacs/notmuch-wash.el  |8 ++-
 ...hread-maildir-storage-with-fourfold-indentation |8 +-
 3 files changed, 50 insertions(+), 28 deletions(-)

-- 
1.7.8.3

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


[PATCH v3 1/2] emacs: Use text properties rather than overlays in `notmuch-show-mode'.

2012-02-07 Thread David Edmondson
Except for where invisibility is involved, replace the use of overlays
in `notmuch-show-mode' with text properties, which are more efficient
and can be merged together more effectively.
---
 emacs/notmuch-show.el |   62 +++-
 emacs/notmuch-wash.el |8 -
 2 files changed, 46 insertions(+), 24 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 7469e2e..bc1e7db 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -264,10 +264,10 @@ operation on the contents of the current buffer."
   (t
'message-header-other
 
-(overlay-put (make-overlay (point) (re-search-forward ":"))
-'face 'message-header-name)
-(overlay-put (make-overlay (point) (re-search-forward ".*$"))
-'face face)))
+(put-text-property (point) (re-search-forward ":")
+  'face 'message-header-name)
+(put-text-property (point) (re-search-forward ".*$")
+  'face face)))
 
 (defun notmuch-show-colour-headers ()
   "Apply some colouring to the current headers."
@@ -284,12 +284,11 @@ operation on the contents of the current buffer."
   "Update the displayed tags of the current message."
   (save-excursion
 (goto-char (notmuch-show-message-top))
-(if (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)
-   (let ((inhibit-read-only t))
- (replace-match (concat "("
-(propertize (mapconcat 'identity tags " ")
-'face 'notmuch-tag-face)
-")"))
+(when (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)
+  (let ((inhibit-read-only t))
+   (replace-match (propertize (mapconcat 'identity tags " ")
+  'face '(notmuch-tag-face 
notmuch-message-summary-face))
+  nil nil nil 1)
 
 (defun notmuch-show-clean-address (address)
   "Try to clean a single email ADDRESS for display.  Return
@@ -352,15 +351,26 @@ unchanged ADDRESS if parsing fails."
   "Insert a notmuch style headerline based on HEADERS for a
 message at DEPTH in the current thread."
   (let ((start (point)))
-(insert (notmuch-show-spaces-n (* notmuch-show-indent-messages-width 
depth))
-   (notmuch-show-clean-address (plist-get headers :From))
-   " ("
-   date
-   ") ("
-   (propertize (mapconcat 'identity tags " ")
-   'face 'notmuch-tag-face)
-   ")\n")
-(overlay-put (make-overlay start (point)) 'face 
'notmuch-message-summary-face)))
+(insert
+ (propertize (concat (notmuch-show-clean-address (plist-get headers :From))
+" ("
+date
+") (")
+'face 'notmuch-message-summary-face)
+ (propertize (mapconcat 'identity tags " ")
+'face '(notmuch-tag-face notmuch-message-summary-face))
+ (propertize ")\n"
+'face 'notmuch-message-summary-face))
+
+;; Ensure that any insertions at the start of this line (usually
+;; just spaces for indentation purposes) inherit the face of the
+;; rest of the line...
+(put-text-property start (1+ start)
+  'front-sticky '(face))
+;; ...and that insertions at the end of this region do _not_
+;; inherit the face of the rest of this line.
+(put-text-property (1- (point)) (point)
+  'rear-nonsticky '(face
 
 (defun notmuch-show-insert-header (header header-value)
   "Insert a single header."
@@ -796,8 +806,15 @@ current buffer, if possible."
 (defun notmuch-show-insert-bodypart (msg part depth)
   "Insert the body part PART at depth DEPTH in the current thread."
   (let ((content-type (downcase (plist-get part :content-type)))
-   (nth (plist-get part :id)))
-(notmuch-show-insert-bodypart-internal msg part content-type nth depth 
content-type))
+   (nth (plist-get part :id))
+   (start (point)))
+(notmuch-show-insert-bodypart-internal msg part content-type nth depth 
content-type)
+
+;; Ensure that face properties applied to text in the buffer by
+;; the part handler don't leak into the following text.
+(put-text-property start (point-max)
+  'rear-nonsticky '(face)))
+
   ;; Some of the body part handlers leave point somewhere up in the
   ;; part, so we make sure that we're down at the end.
   (goto-char (point-max))
@@ -889,7 +906,8 @@ current buffer, if possible."
 (setq content-end (point-marker))
 
 ;; Indent according to the depth in the thread.
-(indent-rigidly content-start content-end (* 
notmuch-show-indent-messages-width depth))
+(indent-rigidly message-start message-end
+   (* notmuch-show-indent-messages-width depth))
 
 (setq message-end (point-max-marker))
 
diff --git a/emacs/notmuch-wash.

[PATCH v3 2/2] test: Update test to match previous patch.

2012-02-07 Thread David Edmondson
Indentation now uses tabs where possible.
---
 ...hread-maildir-storage-with-fourfold-indentation |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git 
a/test/emacs.expected-output/notmuch-show-thread-maildir-storage-with-fourfold-indentation
 
b/test/emacs.expected-output/notmuch-show-thread-maildir-storage-with-fourfold-indentation
index b0bf93e..1f7801e 100644
--- 
a/test/emacs.expected-output/notmuch-show-thread-maildir-storage-with-fourfold-indentation
+++ 
b/test/emacs.expected-output/notmuch-show-thread-maildir-storage-with-fourfold-indentation
@@ -69,7 +69,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
 notmuch mailing list
 notmuch@notmuchmail.org
 http://notmuchmail.org/mailman/listinfo/notmuch
-Lars Kellogg-Stedman  (2009-11-17) (inbox 
signed unread)
+   Lars Kellogg-Stedman  (2009-11-17) (inbox signed 
unread)
Subject: Re: [notmuch] Working with Maildir storage?
To: Mikhail Gusarov 
Cc: notmuch@notmuchmail.org
@@ -101,7 +101,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch
-Mikhail Gusarov  (2009-11-17) (inbox 
unread)
+   Mikhail Gusarov  (2009-11-17) (inbox 
unread)
Subject: [notmuch] Working with Maildir storage?
To: notmuch@notmuchmail.org
Date: Wed, 18 Nov 2009 02:50:48 +0600
@@ -129,7 +129,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
Desc: not available
URL:


-Keith Packard  (2009-11-17) (inbox unread)
+   Keith Packard  (2009-11-17) (inbox unread)
Subject: [notmuch] Working with Maildir storage?
To: notmuch@notmuchmail.org
Date: Tue, 17 Nov 2009 13:24:13 -0800
@@ -151,7 +151,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
Thanks to everyone for trying out notmuch!
 
-keith
-Lars Kellogg-Stedman  (2009-11-18) 
(inbox signed unread)
+   Lars Kellogg-Stedman  (2009-11-18) 
(inbox signed unread)
Subject: Re: [notmuch] Working with Maildir storage?
To: Keith Packard 
Cc: notmuch@notmuchmail.org
-- 
1.7.8.3

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


[PATCH] Free the results of scandir()

2012-02-07 Thread Ethan Glasser-Camp
From: Ethan Glasser-Camp 

scandir() returns "strings allocated via malloc(3)" which are then
"collected in array namelist which is allocated via
malloc(3)". Currently we just free the array namelist. Instead, free
all the entries of namelist, and then free namelist.

entry only points to elements of namelist, so we don't free it
separately.
---

v3: I'm still learning the house style. Thanks Dmitry.

 notmuch-new.c |   16 ++--
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/notmuch-new.c b/notmuch-new.c
index a569a54..8dbebb3 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -559,12 +559,14 @@ add_files_recursive (notmuch_database_t *notmuch,
   DONE:
 if (next)
talloc_free (next);
-if (entry)
-   free (entry);
 if (dir)
closedir (dir);
-if (fs_entries)
+if (fs_entries) {
+   for (i = 0; i < num_fs_entries; i++)
+   free (fs_entries[i]);
+
free (fs_entries);
+}
 if (db_subdirs)
notmuch_filenames_destroy (db_subdirs);
 if (db_files)
@@ -704,10 +706,12 @@ count_files (const char *path, int *count)
 }
 
   DONE:
-if (entry)
-   free (entry);
-if (fs_entries)
+if (fs_entries) {
+   for (i = 0; i < num_fs_entries; i++)
+   free (fs_entries[i]);
+
 free (fs_entries);
+}
 }
 
 static void
-- 
1.7.5.4

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


Re: [PATCH] Free the results of scandir()

2012-02-07 Thread Dmitry Kurochkin
On Tue,  7 Feb 2012 05:05:03 -0500, Ethan Glasser-Camp  
wrote:
> From: Ethan Glasser-Camp 
> 
> scandir() returns "strings allocated via malloc(3)" which are then
> "collected in array namelist which is allocated via
> malloc(3)". Currently we just free the array namelist. Instead, free
> all the entries of namelist, and then free namelist.
> 
> entry only points to elements of namelist, so we don't free it
> separately.
> ---
> 
> v3: I'm still learning the house style. Thanks Dmitry.
> 

Looks good.

Please use --subject-prefix='PATCH vN' parameter when sending new
versions of patches.  Also, sending new versions as replies to the first
email in the original thread makes it easier to track.

Regards,
  Dmitry

>  notmuch-new.c |   16 ++--
>  1 files changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/notmuch-new.c b/notmuch-new.c
> index a569a54..8dbebb3 100644
> --- a/notmuch-new.c
> +++ b/notmuch-new.c
> @@ -559,12 +559,14 @@ add_files_recursive (notmuch_database_t *notmuch,
>DONE:
>  if (next)
>   talloc_free (next);
> -if (entry)
> - free (entry);
>  if (dir)
>   closedir (dir);
> -if (fs_entries)
> +if (fs_entries) {
> + for (i = 0; i < num_fs_entries; i++)
> + free (fs_entries[i]);
> +
>   free (fs_entries);
> +}
>  if (db_subdirs)
>   notmuch_filenames_destroy (db_subdirs);
>  if (db_files)
> @@ -704,10 +706,12 @@ count_files (const char *path, int *count)
>  }
>  
>DONE:
> -if (entry)
> - free (entry);
> -if (fs_entries)
> +if (fs_entries) {
> + for (i = 0; i < num_fs_entries; i++)
> + free (fs_entries[i]);
> +
>  free (fs_entries);
> +}
>  }
>  
>  static void
> -- 
> 1.7.5.4
> 
> ___
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] Free the results of scandir()

2012-02-07 Thread Ethan Glasser-Camp

On 02/07/2012 05:10 AM, Dmitry Kurochkin wrote:

Please use --subject-prefix='PATCH vN' parameter when sending new
versions of patches.  Also, sending new versions as replies to the first
email in the original thread makes it easier to track.


Oops! Thanks again.

Ethan

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


Re: [PATCH] Free the results of scandir()

2012-02-07 Thread Tomi Ollila
On Tue,  7 Feb 2012 05:05:03 -0500, Ethan Glasser-Camp  
wrote:
> From: Ethan Glasser-Camp 
> 
> scandir() returns "strings allocated via malloc(3)" which are then
> "collected in array namelist which is allocated via
> malloc(3)". Currently we just free the array namelist. Instead, free
> all the entries of namelist, and then free namelist.
> 
> entry only points to elements of namelist, so we don't free it
> separately.
> ---

+1

Tomi


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


[PATCH v2] emacs: call "notmuch tag" only once when archiving a thread

2012-02-07 Thread Jani Nikula
Optimize thread archiving by combining all the -inbox tagging
operations to a single "notmuch tag" call. Also skip redisplay of tag
changes in current buffer, as it is immediately killed by the
archiving functions.

For threads in the order of tens or a hundred inbox tagged messages,
this gives a noticeable speedup. On two different machines, archiving
a thread of about 50 inbox tagged messages goes down from 10+ seconds
to about 0.5 seconds.

The bottleneck is not within emacs; the same behaviour can be observed
in the cli. This patch is a quick fix to thread archiving, but it
seems clear that generally the thread tagging functions should be
refactored to do tagging in one go. This approach would have the added
benefit of being more reliable: any of the individual tagging
operations might face a locked database, leading to partial results.

This introduces a limitation to the number of messages that can be
archived at the same time (through ARG_MAX limiting the command
line). While at least on Linux this seems more like a theoretical
limitation than a real one, it could be avoided by archiving at most a
few hundred messages at a time.

Signed-off-by: Jani Nikula 

---

v1 is at id:"1325615346-8302-1-git-send-email-j...@nikula.org".

Although this saves me several minutes a day, I don't have the time
for further improvements. I'm just too slow writing elisp...
---
 emacs/notmuch-show.el |   19 +--
 1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 7469e2e..a0b8eb3 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1614,6 +1614,21 @@ added."
   (if show-next
  (notmuch-search-show-thread)
 
+(defun notmuch-show-archive-thread-quick ()
+  "Remove \"inbox\" tag from the current set of messages.
+
+Note: This function does not call `notmuch-show-set-tags' on the
+messages to redisplay the changed tags. This is meant to be
+called by functions that archive the messages and kill the buffer
+afterwards."
+  (goto-char (point-min))
+  (let (message-ids)
+(loop do
+ (add-to-list 'message-ids (notmuch-show-get-message-id))
+ until (not (notmuch-show-goto-message-next)))
+(when message-ids
+  (notmuch-tag (mapconcat 'identity message-ids " OR ") "-inbox"
+
 (defun notmuch-show-archive-thread (&optional unarchive)
   "Archive each message in thread.
 
@@ -1637,13 +1652,13 @@ buffer."
 (defun notmuch-show-archive-thread-then-next ()
   "Archive each message in thread, then show next thread from search."
   (interactive)
-  (notmuch-show-archive-thread)
+  (notmuch-show-archive-thread-quick)
   (notmuch-show-next-thread t))
 
 (defun notmuch-show-archive-thread-then-exit ()
   "Archive each message in thread, then exit back to search results."
   (interactive)
-  (notmuch-show-archive-thread)
+  (notmuch-show-archive-thread-quick)
   (notmuch-show-next-thread))
 
 (defun notmuch-show-archive-message (&optional unarchive)
-- 
1.7.5.4

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


[PATCH] uncrustify.cfg: comments and more types

2012-02-07 Thread Tomi Ollila
Changes to devel/uncrustify.cfg:

* Updated header comment to state this is config file for *notmuch*.
* Added comment about the reason of 'type' keyword used.
* Added some more custom types woth 'type' keyword.
* Have (every) multiline comment lines start with '*'.
---
 devel/uncrustify.cfg |   21 +
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/devel/uncrustify.cfg b/devel/uncrustify.cfg
index d8075ba..bab9761 100644
--- a/devel/uncrustify.cfg
+++ b/devel/uncrustify.cfg
@@ -1,13 +1,13 @@
 #
-# uncrustify config file for the linux kernel
+# Uncrustify config file for notmuch.
+# Based on uncrustify config file for the linux kernel
 #
 # $Id: linux-indent.cfg 488 2006-09-09 12:44:38Z bengardner $
 # Taken from the uncrustify distribution under license (GPL2+)
 #
-# sample usage:
+# Sample usage:
 #uncrustify --replace -c uncrustify.cfg foo.c
 #
-#
 
 indent_with_tabs   = 2 # 1=indent to level only, 2=indent with 
tabs
 align_with_tabs= TRUE  # use tabs to align
@@ -18,6 +18,8 @@ indent_columns= 4
 
 indent_label   = -2# pos: absolute col, neg: relative 
column
 
+indent_cmt_with_tabs   = false # true would align to tabstop always...
+
 #
 # inter-symbol newlines
 #
@@ -54,11 +56,14 @@ nl_after_struct = 0
 # mod_full_brace_do= remove# "do a--; while ();" vs "do { a--; } 
while ();"
 # mod_full_brace_while = remove# "while (a) a--;" vs "while (a) { a--; 
}"
 
-#
-# Extra types used in notmuch source.
-# (add more on demand)
 
-type GMimeObject mime_node_t
+# In case some custom types aren't detected properly by uncrustify
+# add those to this section below. For example there are cases where
+# uncrustify doesn't know whether a 'token' is part of pointer type
+# or left operand of a binary multiplication operation.
+
+type GMimeObject GMimeCryptoContext GMimeCipherContext
+type mime_node_t notmuch_message_t
 
 #
 # inter-character spacing options
@@ -107,6 +112,6 @@ align_right_cmt_span= 8 # align 
comments span this much in func
 # align_pp_define_span = 8;
 # align_pp_define_gap  = 4;
 
-# cmt_star_cont= FALSE
+cmt_star_cont  = true
 
 # indent_brace = 0
-- 
1.7.6.5

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


A big thank you for the major tagging speedup

2012-02-07 Thread Florian Friesdorf

I just wanted to express my gratitude, that for a while now notmuch is
tagging by a factor 200 faster than it used to be!

-- 
Florian Friesdorf 
  GPG FPR: 7A13 5EEE 1421 9FC2 108D  BAAF 38F8 99A3 0C45 F083
Jabber/XMPP: f...@chaoflow.net
IRC: chaoflow on freenode,ircnet,blafasel,OFTC


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


[PATCH] emacs: Ensure that gnupg output goes at the end of the buffer.

2012-02-07 Thread David Edmondson
When showing the user some details of gnupg output, ensure that those
details are shown at the end of the gnupg status buffer
("*notmuch-crypto-gpg-out*"), otherwise it can end up mixed up with
earlier output.
---
 emacs/notmuch-crypto.el |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
index 80ac350..c7ef1eb 100644
--- a/emacs/notmuch-crypto.el
+++ b/emacs/notmuch-crypto.el
@@ -129,6 +129,7 @@ mode."
 (window (display-buffer buffer t nil)))
 (with-selected-window window
   (with-current-buffer buffer
+   (goto-char (point-max))
(call-process "gpg" nil t t "--list-keys" fingerprint))
   (recenter -1
 
@@ -139,6 +140,7 @@ mode."
 (window (display-buffer buffer t nil)))
 (with-selected-window window
   (with-current-buffer buffer
+   (goto-char (point-max))
(call-process "gpg" nil t t "--recv-keys" keyid)
(insert "\n")
(call-process "gpg" nil t t "--list-keys" keyid))
-- 
1.7.8.3

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


Re: [PATCH v7 1/8] emacs: Rework crypto switch toggle.

2012-02-07 Thread Austin Clements
Seems reasonable.  I'm definitely in favor of erasing buffers instead
of killing and recreating them.  Two questions below.

Quoth David Edmondson on Feb 06 at  9:21 am:
> Re-work the existing crypto switch toggle to be based on a persistant
> buffer-local variable.
> 
> To allow this, modify `notmuch-show-refresh-view' to erase and re-draw
> in the current buffer rather than killing the current buffer and
> creating a new one. (This will also allow more per-buffer behaviour in
> future patches.)
> 
> Add a binding ('$') to toggle crypto processing of the current buffer
> and remove the prefix argument approach that achieves a similar
> result.
> ---
>  emacs/notmuch-show.el |  126 
>  emacs/notmuch.el  |7 +--
>  2 files changed, 66 insertions(+), 67 deletions(-)
> 
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 7469e2e..4b29dbd 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -125,6 +125,22 @@ indentation."
>(const :tag "View interactively"
>   notmuch-show-interactively-view-part)))
>  
> +(defvar notmuch-show-thread-id nil)
> +(make-variable-buffer-local 'notmuch-show-thread-id)
> +(put 'notmuch-show-thread-id 'permanent-local t)
> +
> +(defvar notmuch-show-parent-buffer nil)
> +(make-variable-buffer-local 'notmuch-show-parent-buffer)
> +(put 'notmuch-show-parent-buffer 'permanent-local t)
> +
> +(defvar notmuch-show-query-context nil)
> +(make-variable-buffer-local 'notmuch-show-query-context)
> +(put 'notmuch-show-query-context 'permanent-local t)
> +
> +(defvar notmuch-show-process-crypto nil)
> +(make-variable-buffer-local 'notmuch-show-process-crypto)
> +(put 'notmuch-show-process-crypto 'permanent-local t)
> +

Do these need to be permanent-local given that refreshing is now done
by erasing the buffer instead of killing it?

>  (defmacro with-current-notmuch-show-message (&rest body)
>"Evaluate body with current buffer set to the text of current message"
>`(save-excursion
> @@ -421,14 +437,11 @@ message at DEPTH in the current thread."
>  
>  (defmacro notmuch-with-temp-part-buffer (message-id nth &rest body)
>(declare (indent 2))
> -  (let ((process-crypto (make-symbol "process-crypto")))
> -`(let ((,process-crypto notmuch-show-process-crypto))
> -   (with-temp-buffer
> -  (setq notmuch-show-process-crypto ,process-crypto)
> -  ;; Always acquires the part via `notmuch part', even if it is
> -  ;; available in the JSON output.
> -  (insert (notmuch-show-get-bodypart-internal ,message-id ,nth))
> -  ,@body
> +  `(with-temp-buffer
> + ;; Always acquires the part via `notmuch part', even if it is
> + ;; available in the JSON output.
> + (insert (notmuch-show-get-bodypart-internal ,message-id ,nth))
> + ,@body))

Why is the piping of notmuch-show-process-crypto no longer necessary?
It's still buffer-local, and hence will be nil in the temp buffer.

>  
>  (defun notmuch-show-save-part (message-id nth &optional filename 
> content-type)
>(notmuch-with-temp-part-buffer message-id nth
> @@ -610,7 +623,7 @@ current buffer, if possible."
>  (sigstatus (car (plist-get part :sigstatus
> (notmuch-crypto-insert-sigstatus-button sigstatus from))
>;; if we're not adding sigstatus, tell the user how they can get it
> -  (button-put button 'help-echo "Set notmuch-crypto-process-mime to 
> process cryptographic mime parts.")))
> +  (button-put button 'help-echo "Set notmuch-crypto-process-mime to 
> process cryptographic MIME parts.")))
>  
>(let ((inner-parts (plist-get part :content))
>   (start (point)))
> @@ -636,7 +649,7 @@ current buffer, if possible."
>(sigstatus (car (plist-get part :sigstatus
>   (notmuch-crypto-insert-sigstatus-button sigstatus from
>;; if we're not adding encstatus, tell the user how they can get it
> -  (button-put button 'help-echo "Set notmuch-crypto-process-mime to 
> process cryptographic mime parts.")))
> +  (button-put button 'help-echo "Set notmuch-crypto-process-mime to 
> process cryptographic MIME parts.")))
>  
>(let ((inner-parts (plist-get part :content))
>   (start (point)))
> @@ -763,8 +776,6 @@ current buffer, if possible."
>  
>  ;; Helper for parts which are generally not included in the default
>  ;; JSON output.
> -;; Uses the buffer-local variable notmuch-show-process-crypto to
> -;; determine if parts should be decrypted first.
>  (defun notmuch-show-get-bodypart-internal (message-id part-number)
>(let ((args '("show" "--format=raw"))
>   (part-arg (format "--part=%s" part-number)))
> @@ -918,6 +929,15 @@ current buffer, if possible."
>  ;; criteria.
>  (notmuch-show-message-visible msg (plist-get msg :match
>  
> +(defun notmuch-show-toggle-process-crypto ()
> +  "Toggle the processing of cryptographic MIME parts."
> +  (interactive)
> +

Re: [PATCH v7 1/8] emacs: Rework crypto switch toggle.

2012-02-07 Thread David Edmondson
On Wed, 8 Feb 2012 00:10:16 -0500, Austin Clements  wrote:
> Seems reasonable.  I'm definitely in favor of erasing buffers instead
> of killing and recreating them.  Two questions below.

Thanks for the review.

> Quoth David Edmondson on Feb 06 at  9:21 am:
> > Re-work the existing crypto switch toggle to be based on a persistant
> > buffer-local variable.
> > 
> > To allow this, modify `notmuch-show-refresh-view' to erase and re-draw
> > in the current buffer rather than killing the current buffer and
> > creating a new one. (This will also allow more per-buffer behaviour in
> > future patches.)
> > 
> > Add a binding ('$') to toggle crypto processing of the current buffer
> > and remove the prefix argument approach that achieves a similar
> > result.
> > ---
> >  emacs/notmuch-show.el |  126 
> > 
> >  emacs/notmuch.el  |7 +--
> >  2 files changed, 66 insertions(+), 67 deletions(-)
> > 
> > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> > index 7469e2e..4b29dbd 100644
> > --- a/emacs/notmuch-show.el
> > +++ b/emacs/notmuch-show.el
> > @@ -125,6 +125,22 @@ indentation."
> >  (const :tag "View interactively"
> > notmuch-show-interactively-view-part)))
> >  
> > +(defvar notmuch-show-thread-id nil)
> > +(make-variable-buffer-local 'notmuch-show-thread-id)
> > +(put 'notmuch-show-thread-id 'permanent-local t)
> > +
> > +(defvar notmuch-show-parent-buffer nil)
> > +(make-variable-buffer-local 'notmuch-show-parent-buffer)
> > +(put 'notmuch-show-parent-buffer 'permanent-local t)
> > +
> > +(defvar notmuch-show-query-context nil)
> > +(make-variable-buffer-local 'notmuch-show-query-context)
> > +(put 'notmuch-show-query-context 'permanent-local t)
> > +
> > +(defvar notmuch-show-process-crypto nil)
> > +(make-variable-buffer-local 'notmuch-show-process-crypto)
> > +(put 'notmuch-show-process-crypto 'permanent-local t)
> > +
> 
> Do these need to be permanent-local given that refreshing is now done
> by erasing the buffer instead of killing it?

Yes. `notmuch-show-worker' (which does the refreshing) still calls
`notmuch-show-mode', which still calls `kill-all-local-variables'.

Tidying that is for another patch.

> >  (defmacro with-current-notmuch-show-message (&rest body)
> >"Evaluate body with current buffer set to the text of current message"
> >`(save-excursion
> > @@ -421,14 +437,11 @@ message at DEPTH in the current thread."
> >  
> >  (defmacro notmuch-with-temp-part-buffer (message-id nth &rest body)
> >(declare (indent 2))
> > -  (let ((process-crypto (make-symbol "process-crypto")))
> > -`(let ((,process-crypto notmuch-show-process-crypto))
> > -   (with-temp-buffer
> > -(setq notmuch-show-process-crypto ,process-crypto)
> > -;; Always acquires the part via `notmuch part', even if it is
> > -;; available in the JSON output.
> > -(insert (notmuch-show-get-bodypart-internal ,message-id ,nth))
> > -,@body
> > +  `(with-temp-buffer
> > + ;; Always acquires the part via `notmuch part', even if it is
> > + ;; available in the JSON output.
> > + (insert (notmuch-show-get-bodypart-internal ,message-id ,nth))
> > + ,@body))
> 
> Why is the piping of notmuch-show-process-crypto no longer necessary?
> It's still buffer-local, and hence will be nil in the temp buffer.

It's a bug. v8 after breakfast.

> >  
> >  (defun notmuch-show-save-part (message-id nth &optional filename 
> > content-type)
> >(notmuch-with-temp-part-buffer message-id nth
> > @@ -610,7 +623,7 @@ current buffer, if possible."
> >(sigstatus (car (plist-get part :sigstatus
> >   (notmuch-crypto-insert-sigstatus-button sigstatus from))
> >;; if we're not adding sigstatus, tell the user how they can get it
> > -  (button-put button 'help-echo "Set notmuch-crypto-process-mime to 
> > process cryptographic mime parts.")))
> > +  (button-put button 'help-echo "Set notmuch-crypto-process-mime to 
> > process cryptographic MIME parts.")))
> >  
> >(let ((inner-parts (plist-get part :content))
> > (start (point)))
> > @@ -636,7 +649,7 @@ current buffer, if possible."
> >  (sigstatus (car (plist-get part :sigstatus
> > (notmuch-crypto-insert-sigstatus-button sigstatus from
> >;; if we're not adding encstatus, tell the user how they can get it
> > -  (button-put button 'help-echo "Set notmuch-crypto-process-mime to 
> > process cryptographic mime parts.")))
> > +  (button-put button 'help-echo "Set notmuch-crypto-process-mime to 
> > process cryptographic MIME parts.")))
> >  
> >(let ((inner-parts (plist-get part :content))
> > (start (point)))
> > @@ -763,8 +776,6 @@ current buffer, if possible."
> >  
> >  ;; Helper for parts which are generally not included in the default
> >  ;; JSON output.
> > -;; Uses the buffer-local variable notmuch-show-process-crypto to
> > -;; determine if par

[PATCH] Free the results of scandir()

2012-02-07 Thread Jani Nikula
On Mon,  6 Feb 2012 17:02:49 -0500, Ethan Glasser-Camp  
wrote:
> From: Ethan Glasser-Camp 
> 
> scandir() returns "strings allocated via malloc(3)" which are then
> "collected in array namelist which is allocated via
> malloc(3)". Currently we just free the array namelist. Instead, free
> all the entries of namelist, and then free namelist.
> 
> entry only points to elements of namelist, so we don't free it
> separately.
> ---
> 
> This should fix a minor memory leak in notmuch-new. Please confirm I'm
> reading the manpage correctly ;)

It looks right, good catch! Please do also fix the other scandir() usage
in count_files().

BR,
Jani.


> 
>  notmuch-new.c |8 +---
>  1 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/notmuch-new.c b/notmuch-new.c
> index a569a54..c536873 100644
> --- a/notmuch-new.c
> +++ b/notmuch-new.c
> @@ -559,12 +559,14 @@ add_files_recursive (notmuch_database_t *notmuch,
>DONE:
>  if (next)
>   talloc_free (next);
> -if (entry)
> - free (entry);
>  if (dir)
>   closedir (dir);
> -if (fs_entries)
> +if (fs_entries){
> + for (i = 0; i < num_fs_entries; i++){
> + free (fs_entries[i]);
> + }
>   free (fs_entries);
> +}
>  if (db_subdirs)
>   notmuch_filenames_destroy (db_subdirs);
>  if (db_files)
> -- 
> 1.7.5.4
> 
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v2] Free the results of scandir()

2012-02-07 Thread Ethan Glasser-Camp
From: Ethan Glasser-Camp 

scandir() returns "strings allocated via malloc(3)" which are then
"collected in array namelist which is allocated via
malloc(3)". Currently we just free the array namelist. Instead, free
all the entries of namelist, and then free namelist.

entry only points to elements of namelist, so we don't free it
separately.
---

Fixes the other use of scandir in count_files. Thanks, Jani.

 notmuch-new.c |   16 ++--
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/notmuch-new.c b/notmuch-new.c
index a569a54..e62560b 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -559,12 +559,14 @@ add_files_recursive (notmuch_database_t *notmuch,
   DONE:
 if (next)
talloc_free (next);
-if (entry)
-   free (entry);
 if (dir)
closedir (dir);
-if (fs_entries)
+if (fs_entries){
+   for (i = 0; i < num_fs_entries; i++){
+   free (fs_entries[i]);
+   }
free (fs_entries);
+}
 if (db_subdirs)
notmuch_filenames_destroy (db_subdirs);
 if (db_files)
@@ -704,10 +706,12 @@ count_files (const char *path, int *count)
 }

   DONE:
-if (entry)
-   free (entry);
-if (fs_entries)
+if (fs_entries){
+   for (i = 0; i < num_fs_entries; i++){
+   free (fs_entries[i]);
+   }
 free (fs_entries);
+}
 }

 static void
-- 
1.7.5.4



[PATCH v2] Free the results of scandir()

2012-02-07 Thread Jani Nikula
On Tue,  7 Feb 2012 01:50:05 -0500, Ethan Glasser-Camp  
wrote:
> From: Ethan Glasser-Camp 
> 
> scandir() returns "strings allocated via malloc(3)" which are then
> "collected in array namelist which is allocated via
> malloc(3)". Currently we just free the array namelist. Instead, free
> all the entries of namelist, and then free namelist.
> 
> entry only points to elements of namelist, so we don't free it
> separately.

Looks good. Thanks, Ethan.

David, I'm not sure if this is worth a bugfix release on its own, but
definitely worth including if something else comes up.

id:"2flfwhht87d.fsf at diskless.uio.no" is a report about potential memory
leak in notmuch new from a few months back. CC Petter, the reporter.

> ---
> 
> Fixes the other use of scandir in count_files. Thanks, Jani.
> 
>  notmuch-new.c |   16 ++--
>  1 files changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/notmuch-new.c b/notmuch-new.c
> index a569a54..e62560b 100644
> --- a/notmuch-new.c
> +++ b/notmuch-new.c
> @@ -559,12 +559,14 @@ add_files_recursive (notmuch_database_t *notmuch,
>DONE:
>  if (next)
>   talloc_free (next);
> -if (entry)
> - free (entry);
>  if (dir)
>   closedir (dir);
> -if (fs_entries)
> +if (fs_entries){
> + for (i = 0; i < num_fs_entries; i++){
> + free (fs_entries[i]);
> + }
>   free (fs_entries);
> +}
>  if (db_subdirs)
>   notmuch_filenames_destroy (db_subdirs);
>  if (db_files)
> @@ -704,10 +706,12 @@ count_files (const char *path, int *count)
>  }
>  
>DONE:
> -if (entry)
> - free (entry);
> -if (fs_entries)
> +if (fs_entries){
> + for (i = 0; i < num_fs_entries; i++){
> + free (fs_entries[i]);
> + }
>  free (fs_entries);
> +}
>  }
>  
>  static void
> -- 
> 1.7.5.4
> 
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v2] Free the results of scandir()

2012-02-07 Thread Dmitry Kurochkin
Hi Ethan.

On Tue,  7 Feb 2012 01:50:05 -0500, Ethan Glasser-Camp  
wrote:
> From: Ethan Glasser-Camp 
> 
> scandir() returns "strings allocated via malloc(3)" which are then
> "collected in array namelist which is allocated via
> malloc(3)". Currently we just free the array namelist. Instead, free
> all the entries of namelist, and then free namelist.
> 
> entry only points to elements of namelist, so we don't free it
> separately.
> ---
> 
> Fixes the other use of scandir in count_files. Thanks, Jani.
> 

Few style comments below.  Otherwise looks good.

>  notmuch-new.c |   16 ++--
>  1 files changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/notmuch-new.c b/notmuch-new.c
> index a569a54..e62560b 100644
> --- a/notmuch-new.c
> +++ b/notmuch-new.c
> @@ -559,12 +559,14 @@ add_files_recursive (notmuch_database_t *notmuch,
>DONE:
>  if (next)
>   talloc_free (next);
> -if (entry)
> - free (entry);
>  if (dir)
>   closedir (dir);
> -if (fs_entries)
> +if (fs_entries){

Please add a space before '{'.

> + for (i = 0; i < num_fs_entries; i++){
> + free (fs_entries[i]);
> + }

Please remove "{}" around one line block.

>   free (fs_entries);
> +}
>  if (db_subdirs)
>   notmuch_filenames_destroy (db_subdirs);
>  if (db_files)
> @@ -704,10 +706,12 @@ count_files (const char *path, int *count)
>  }
>  
>DONE:
> -if (entry)
> - free (entry);
> -if (fs_entries)
> +if (fs_entries){
> + for (i = 0; i < num_fs_entries; i++){
> + free (fs_entries[i]);
> + }

Same two comments here.

Regards,
  Dmitry

>  free (fs_entries);
> +}
>  }
>  
>  static void
> -- 
> 1.7.5.4
> 
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v3 0/2] use text properties rather than overlays

2012-02-07 Thread David Edmondson
v3:
- Undo mistaken minor edit - no functional change.

David Edmondson (2):
  emacs: Use text properties rather than overlays in
`notmuch-show-mode'.
  test: Update test to match previous patch.

 emacs/notmuch-show.el  |   62 +---
 emacs/notmuch-wash.el  |8 ++-
 ...hread-maildir-storage-with-fourfold-indentation |8 +-
 3 files changed, 50 insertions(+), 28 deletions(-)

-- 
1.7.8.3



[PATCH v3 1/2] emacs: Use text properties rather than overlays in `notmuch-show-mode'.

2012-02-07 Thread David Edmondson
Except for where invisibility is involved, replace the use of overlays
in `notmuch-show-mode' with text properties, which are more efficient
and can be merged together more effectively.
---
 emacs/notmuch-show.el |   62 +++-
 emacs/notmuch-wash.el |8 -
 2 files changed, 46 insertions(+), 24 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 7469e2e..bc1e7db 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -264,10 +264,10 @@ operation on the contents of the current buffer."
   (t
'message-header-other

-(overlay-put (make-overlay (point) (re-search-forward ":"))
-'face 'message-header-name)
-(overlay-put (make-overlay (point) (re-search-forward ".*$"))
-'face face)))
+(put-text-property (point) (re-search-forward ":")
+  'face 'message-header-name)
+(put-text-property (point) (re-search-forward ".*$")
+  'face face)))

 (defun notmuch-show-colour-headers ()
   "Apply some colouring to the current headers."
@@ -284,12 +284,11 @@ operation on the contents of the current buffer."
   "Update the displayed tags of the current message."
   (save-excursion
 (goto-char (notmuch-show-message-top))
-(if (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)
-   (let ((inhibit-read-only t))
- (replace-match (concat "("
-(propertize (mapconcat 'identity tags " ")
-'face 'notmuch-tag-face)
-")"))
+(when (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)
+  (let ((inhibit-read-only t))
+   (replace-match (propertize (mapconcat 'identity tags " ")
+  'face '(notmuch-tag-face 
notmuch-message-summary-face))
+  nil nil nil 1)

 (defun notmuch-show-clean-address (address)
   "Try to clean a single email ADDRESS for display.  Return
@@ -352,15 +351,26 @@ unchanged ADDRESS if parsing fails."
   "Insert a notmuch style headerline based on HEADERS for a
 message at DEPTH in the current thread."
   (let ((start (point)))
-(insert (notmuch-show-spaces-n (* notmuch-show-indent-messages-width 
depth))
-   (notmuch-show-clean-address (plist-get headers :From))
-   " ("
-   date
-   ") ("
-   (propertize (mapconcat 'identity tags " ")
-   'face 'notmuch-tag-face)
-   ")\n")
-(overlay-put (make-overlay start (point)) 'face 
'notmuch-message-summary-face)))
+(insert
+ (propertize (concat (notmuch-show-clean-address (plist-get headers :From))
+" ("
+date
+") (")
+'face 'notmuch-message-summary-face)
+ (propertize (mapconcat 'identity tags " ")
+'face '(notmuch-tag-face notmuch-message-summary-face))
+ (propertize ")\n"
+'face 'notmuch-message-summary-face))
+
+;; Ensure that any insertions at the start of this line (usually
+;; just spaces for indentation purposes) inherit the face of the
+;; rest of the line...
+(put-text-property start (1+ start)
+  'front-sticky '(face))
+;; ...and that insertions at the end of this region do _not_
+;; inherit the face of the rest of this line.
+(put-text-property (1- (point)) (point)
+  'rear-nonsticky '(face

 (defun notmuch-show-insert-header (header header-value)
   "Insert a single header."
@@ -796,8 +806,15 @@ current buffer, if possible."
 (defun notmuch-show-insert-bodypart (msg part depth)
   "Insert the body part PART at depth DEPTH in the current thread."
   (let ((content-type (downcase (plist-get part :content-type)))
-   (nth (plist-get part :id)))
-(notmuch-show-insert-bodypart-internal msg part content-type nth depth 
content-type))
+   (nth (plist-get part :id))
+   (start (point)))
+(notmuch-show-insert-bodypart-internal msg part content-type nth depth 
content-type)
+
+;; Ensure that face properties applied to text in the buffer by
+;; the part handler don't leak into the following text.
+(put-text-property start (point-max)
+  'rear-nonsticky '(face)))
+
   ;; Some of the body part handlers leave point somewhere up in the
   ;; part, so we make sure that we're down at the end.
   (goto-char (point-max))
@@ -889,7 +906,8 @@ current buffer, if possible."
 (setq content-end (point-marker))

 ;; Indent according to the depth in the thread.
-(indent-rigidly content-start content-end (* 
notmuch-show-indent-messages-width depth))
+(indent-rigidly message-start message-end
+   (* notmuch-show-indent-messages-width depth))

 (setq message-end (point-max-marker))

diff --git a/emacs/notmuch-wash.el b/em

[PATCH v3 2/2] test: Update test to match previous patch.

2012-02-07 Thread David Edmondson
Indentation now uses tabs where possible.
---
 ...hread-maildir-storage-with-fourfold-indentation |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git 
a/test/emacs.expected-output/notmuch-show-thread-maildir-storage-with-fourfold-indentation
 
b/test/emacs.expected-output/notmuch-show-thread-maildir-storage-with-fourfold-indentation
index b0bf93e..1f7801e 100644
--- 
a/test/emacs.expected-output/notmuch-show-thread-maildir-storage-with-fourfold-indentation
+++ 
b/test/emacs.expected-output/notmuch-show-thread-maildir-storage-with-fourfold-indentation
@@ -69,7 +69,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
 notmuch mailing list
 notmuch at notmuchmail.org
 http://notmuchmail.org/mailman/listinfo/notmuch
-Lars Kellogg-Stedman  (2009-11-17) (inbox 
signed unread)
+   Lars Kellogg-Stedman  (2009-11-17) (inbox 
signed unread)
Subject: Re: [notmuch] Working with Maildir storage?
To: Mikhail Gusarov 
Cc: notmuch at notmuchmail.org
@@ -101,7 +101,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
notmuch mailing list
notmuch at notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch
-Mikhail Gusarov  (2009-11-17) (inbox 
unread)
+   Mikhail Gusarov  (2009-11-17) (inbox 
unread)
Subject: [notmuch] Working with Maildir storage?
To: notmuch at notmuchmail.org
Date: Wed, 18 Nov 2009 02:50:48 +0600
@@ -129,7 +129,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
Desc: not available
URL:


-Keith Packard  (2009-11-17) (inbox unread)
+   Keith Packard  (2009-11-17) (inbox unread)
Subject: [notmuch] Working with Maildir storage?
To: notmuch at notmuchmail.org
Date: Tue, 17 Nov 2009 13:24:13 -0800
@@ -151,7 +151,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
Thanks to everyone for trying out notmuch!

-keith
-Lars Kellogg-Stedman  (2009-11-18) 
(inbox signed unread)
+   Lars Kellogg-Stedman  (2009-11-18) 
(inbox signed unread)
Subject: Re: [notmuch] Working with Maildir storage?
To: Keith Packard 
Cc: notmuch at notmuchmail.org
-- 
1.7.8.3



[PATCH] Free the results of scandir()

2012-02-07 Thread Ethan Glasser-Camp
From: Ethan Glasser-Camp 

scandir() returns "strings allocated via malloc(3)" which are then
"collected in array namelist which is allocated via
malloc(3)". Currently we just free the array namelist. Instead, free
all the entries of namelist, and then free namelist.

entry only points to elements of namelist, so we don't free it
separately.
---

v3: I'm still learning the house style. Thanks Dmitry.

 notmuch-new.c |   16 ++--
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/notmuch-new.c b/notmuch-new.c
index a569a54..8dbebb3 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -559,12 +559,14 @@ add_files_recursive (notmuch_database_t *notmuch,
   DONE:
 if (next)
talloc_free (next);
-if (entry)
-   free (entry);
 if (dir)
closedir (dir);
-if (fs_entries)
+if (fs_entries) {
+   for (i = 0; i < num_fs_entries; i++)
+   free (fs_entries[i]);
+
free (fs_entries);
+}
 if (db_subdirs)
notmuch_filenames_destroy (db_subdirs);
 if (db_files)
@@ -704,10 +706,12 @@ count_files (const char *path, int *count)
 }

   DONE:
-if (entry)
-   free (entry);
-if (fs_entries)
+if (fs_entries) {
+   for (i = 0; i < num_fs_entries; i++)
+   free (fs_entries[i]);
+
 free (fs_entries);
+}
 }

 static void
-- 
1.7.5.4



[PATCH] Free the results of scandir()

2012-02-07 Thread Dmitry Kurochkin
On Tue,  7 Feb 2012 05:05:03 -0500, Ethan Glasser-Camp  
wrote:
> From: Ethan Glasser-Camp 
> 
> scandir() returns "strings allocated via malloc(3)" which are then
> "collected in array namelist which is allocated via
> malloc(3)". Currently we just free the array namelist. Instead, free
> all the entries of namelist, and then free namelist.
> 
> entry only points to elements of namelist, so we don't free it
> separately.
> ---
> 
> v3: I'm still learning the house style. Thanks Dmitry.
> 

Looks good.

Please use --subject-prefix='PATCH vN' parameter when sending new
versions of patches.  Also, sending new versions as replies to the first
email in the original thread makes it easier to track.

Regards,
  Dmitry

>  notmuch-new.c |   16 ++--
>  1 files changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/notmuch-new.c b/notmuch-new.c
> index a569a54..8dbebb3 100644
> --- a/notmuch-new.c
> +++ b/notmuch-new.c
> @@ -559,12 +559,14 @@ add_files_recursive (notmuch_database_t *notmuch,
>DONE:
>  if (next)
>   talloc_free (next);
> -if (entry)
> - free (entry);
>  if (dir)
>   closedir (dir);
> -if (fs_entries)
> +if (fs_entries) {
> + for (i = 0; i < num_fs_entries; i++)
> + free (fs_entries[i]);
> +
>   free (fs_entries);
> +}
>  if (db_subdirs)
>   notmuch_filenames_destroy (db_subdirs);
>  if (db_files)
> @@ -704,10 +706,12 @@ count_files (const char *path, int *count)
>  }
>  
>DONE:
> -if (entry)
> - free (entry);
> -if (fs_entries)
> +if (fs_entries) {
> + for (i = 0; i < num_fs_entries; i++)
> + free (fs_entries[i]);
> +
>  free (fs_entries);
> +}
>  }
>  
>  static void
> -- 
> 1.7.5.4
> 
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] Free the results of scandir()

2012-02-07 Thread Ethan Glasser-Camp
On 02/07/2012 05:10 AM, Dmitry Kurochkin wrote:
> Please use --subject-prefix='PATCH vN' parameter when sending new
> versions of patches.  Also, sending new versions as replies to the first
> email in the original thread makes it easier to track.

Oops! Thanks again.

Ethan



[PATCH] Free the results of scandir()

2012-02-07 Thread Tomi Ollila
On Tue,  7 Feb 2012 05:05:03 -0500, Ethan Glasser-Camp  
wrote:
> From: Ethan Glasser-Camp 
> 
> scandir() returns "strings allocated via malloc(3)" which are then
> "collected in array namelist which is allocated via
> malloc(3)". Currently we just free the array namelist. Instead, free
> all the entries of namelist, and then free namelist.
> 
> entry only points to elements of namelist, so we don't free it
> separately.
> ---

+1

Tomi
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120207/a7f80825/attachment.pgp>


[PATCH v2] emacs: call "notmuch tag" only once when archiving a thread

2012-02-07 Thread Jani Nikula
Optimize thread archiving by combining all the -inbox tagging
operations to a single "notmuch tag" call. Also skip redisplay of tag
changes in current buffer, as it is immediately killed by the
archiving functions.

For threads in the order of tens or a hundred inbox tagged messages,
this gives a noticeable speedup. On two different machines, archiving
a thread of about 50 inbox tagged messages goes down from 10+ seconds
to about 0.5 seconds.

The bottleneck is not within emacs; the same behaviour can be observed
in the cli. This patch is a quick fix to thread archiving, but it
seems clear that generally the thread tagging functions should be
refactored to do tagging in one go. This approach would have the added
benefit of being more reliable: any of the individual tagging
operations might face a locked database, leading to partial results.

This introduces a limitation to the number of messages that can be
archived at the same time (through ARG_MAX limiting the command
line). While at least on Linux this seems more like a theoretical
limitation than a real one, it could be avoided by archiving at most a
few hundred messages at a time.

Signed-off-by: Jani Nikula 

---

v1 is at id:"1325615346-8302-1-git-send-email-jani at nikula.org".

Although this saves me several minutes a day, I don't have the time
for further improvements. I'm just too slow writing elisp...
---
 emacs/notmuch-show.el |   19 +--
 1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 7469e2e..a0b8eb3 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1614,6 +1614,21 @@ added."
   (if show-next
  (notmuch-search-show-thread)

+(defun notmuch-show-archive-thread-quick ()
+  "Remove \"inbox\" tag from the current set of messages.
+
+Note: This function does not call `notmuch-show-set-tags' on the
+messages to redisplay the changed tags. This is meant to be
+called by functions that archive the messages and kill the buffer
+afterwards."
+  (goto-char (point-min))
+  (let (message-ids)
+(loop do
+ (add-to-list 'message-ids (notmuch-show-get-message-id))
+ until (not (notmuch-show-goto-message-next)))
+(when message-ids
+  (notmuch-tag (mapconcat 'identity message-ids " OR ") "-inbox"
+
 (defun notmuch-show-archive-thread (&optional unarchive)
   "Archive each message in thread.

@@ -1637,13 +1652,13 @@ buffer."
 (defun notmuch-show-archive-thread-then-next ()
   "Archive each message in thread, then show next thread from search."
   (interactive)
-  (notmuch-show-archive-thread)
+  (notmuch-show-archive-thread-quick)
   (notmuch-show-next-thread t))

 (defun notmuch-show-archive-thread-then-exit ()
   "Archive each message in thread, then exit back to search results."
   (interactive)
-  (notmuch-show-archive-thread)
+  (notmuch-show-archive-thread-quick)
   (notmuch-show-next-thread))

 (defun notmuch-show-archive-message (&optional unarchive)
-- 
1.7.5.4



[PATCH] uncrustify.cfg: comments and more types

2012-02-07 Thread Tomi Ollila
Changes to devel/uncrustify.cfg:

* Updated header comment to state this is config file for *notmuch*.
* Added comment about the reason of 'type' keyword used.
* Added some more custom types woth 'type' keyword.
* Have (every) multiline comment lines start with '*'.
---
 devel/uncrustify.cfg |   21 +
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/devel/uncrustify.cfg b/devel/uncrustify.cfg
index d8075ba..bab9761 100644
--- a/devel/uncrustify.cfg
+++ b/devel/uncrustify.cfg
@@ -1,13 +1,13 @@
 #
-# uncrustify config file for the linux kernel
+# Uncrustify config file for notmuch.
+# Based on uncrustify config file for the linux kernel
 #
 # $Id: linux-indent.cfg 488 2006-09-09 12:44:38Z bengardner $
 # Taken from the uncrustify distribution under license (GPL2+)
 #
-# sample usage:
+# Sample usage:
 #uncrustify --replace -c uncrustify.cfg foo.c
 #
-#

 indent_with_tabs   = 2 # 1=indent to level only, 2=indent with 
tabs
 align_with_tabs= TRUE  # use tabs to align
@@ -18,6 +18,8 @@ indent_columns= 4

 indent_label   = -2# pos: absolute col, neg: relative 
column

+indent_cmt_with_tabs   = false # true would align to tabstop always...
+
 #
 # inter-symbol newlines
 #
@@ -54,11 +56,14 @@ nl_after_struct = 0
 # mod_full_brace_do= remove# "do a--; while ();" vs "do { a--; } 
while ();"
 # mod_full_brace_while = remove# "while (a) a--;" vs "while (a) { a--; 
}"

-#
-# Extra types used in notmuch source.
-# (add more on demand)

-type GMimeObject mime_node_t
+# In case some custom types aren't detected properly by uncrustify
+# add those to this section below. For example there are cases where
+# uncrustify doesn't know whether a 'token' is part of pointer type
+# or left operand of a binary multiplication operation.
+
+type GMimeObject GMimeCryptoContext GMimeCipherContext
+type mime_node_t notmuch_message_t

 #
 # inter-character spacing options
@@ -107,6 +112,6 @@ align_right_cmt_span= 8 # align 
comments span this much in func
 # align_pp_define_span = 8;
 # align_pp_define_gap  = 4;

-# cmt_star_cont= FALSE
+cmt_star_cont  = true

 # indent_brace = 0
-- 
1.7.6.5



A big thank you for the major tagging speedup

2012-02-07 Thread Florian Friesdorf

I just wanted to express my gratitude, that for a while now notmuch is
tagging by a factor 200 faster than it used to be!

-- 
Florian Friesdorf 
  GPG FPR: 7A13 5EEE 1421 9FC2 108D  BAAF 38F8 99A3 0C45 F083
Jabber/XMPP: flo at chaoflow.net
IRC: chaoflow on freenode,ircnet,blafasel,OFTC
-- 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/20120207/516bef31/attachment.pgp>


[PATCH] emacs: Ensure that gnupg output goes at the end of the buffer.

2012-02-07 Thread David Edmondson
When showing the user some details of gnupg output, ensure that those
details are shown at the end of the gnupg status buffer
("*notmuch-crypto-gpg-out*"), otherwise it can end up mixed up with
earlier output.
---
 emacs/notmuch-crypto.el |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el
index 80ac350..c7ef1eb 100644
--- a/emacs/notmuch-crypto.el
+++ b/emacs/notmuch-crypto.el
@@ -129,6 +129,7 @@ mode."
 (window (display-buffer buffer t nil)))
 (with-selected-window window
   (with-current-buffer buffer
+   (goto-char (point-max))
(call-process "gpg" nil t t "--list-keys" fingerprint))
   (recenter -1

@@ -139,6 +140,7 @@ mode."
 (window (display-buffer buffer t nil)))
 (with-selected-window window
   (with-current-buffer buffer
+   (goto-char (point-max))
(call-process "gpg" nil t t "--recv-keys" keyid)
(insert "\n")
(call-process "gpg" nil t t "--list-keys" keyid))
-- 
1.7.8.3