unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 1/4] test: add `notmuch-hello-mode-hook-counter'
@ 2011-12-17  4:20 Dmitry Kurochkin
  2011-12-17  4:20 ` [PATCH 2/4] test: add test for `notmuch-hello-mode-hook' Dmitry Kurochkin
                   ` (5 more replies)
  0 siblings, 6 replies; 22+ messages in thread
From: Dmitry Kurochkin @ 2011-12-17  4:20 UTC (permalink / raw)
  To: notmuch

Add `notmuch-hello-mode-hook-counter' hook to count how many times
`notmuch-hello-mode-hook' was called.  The counter function increments
`notmuch-hello-mode-hook-counter' variable value if it is bount,
otherwise it does nothing.
---
 test/test-lib.el |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/test/test-lib.el b/test/test-lib.el
index 97ae593..3bca138 100644
--- a/test/test-lib.el
+++ b/test/test-lib.el
@@ -61,3 +61,12 @@ running, quit if it terminated."
   (if (not (process-attributes pid))
       (kill-emacs)
     (run-at-time "1 min" nil 'orphan-watchdog pid)))
+
+(defun notmuch-hello-mode-hook-counter ()
+  "Count how many times `notmuch-hello-mode-hook' is called.
+Increments `notmuch-hello-mode-hook-counter' variable value if it
+is bound, otherwise does nothing."
+  (if (boundp 'notmuch-hello-mode-hook-counter)
+      (setq notmuch-hello-mode-hook-counter
+	    (1+ notmuch-hello-mode-hook-counter))))
+(add-hook 'notmuch-hello-mode-hook 'notmuch-hello-mode-hook-counter)
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 2/4] test: add test for `notmuch-hello-mode-hook'
  2011-12-17  4:20 [PATCH 1/4] test: add `notmuch-hello-mode-hook-counter' Dmitry Kurochkin
@ 2011-12-17  4:20 ` Dmitry Kurochkin
  2011-12-17  4:20 ` [PATCH 3/4] test: add broken test for `notmuch-hello-mode-hook' called during update Dmitry Kurochkin
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 22+ messages in thread
From: Dmitry Kurochkin @ 2011-12-17  4:20 UTC (permalink / raw)
  To: notmuch

Test that `notmuch-hello-mode-hook' is called once when
`notmuch-hello' function is called.
---
 test/emacs |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/test/emacs b/test/emacs
index 6e922de..a864ffa 100755
--- a/test/emacs
+++ b/test/emacs
@@ -476,4 +476,13 @@ test_emacs "(let ((notmuch-command \"$notmuch_counter_command\"))
 	      (notmuch-show \"id:$id\"))"
 test_expect_equal $(notmuch_counter_value) 1
 
+test_begin_subtest "notmuch-hello-mode hook is called"
+counter=$(test_emacs \
+    '(let ((notmuch-hello-mode-hook-counter 0))
+       (kill-buffer "*notmuch-hello*")
+       (notmuch-hello)
+       notmuch-hello-mode-hook-counter)'
+)
+test_expect_equal "$counter" 1
+
 test_done
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 3/4] test: add broken test for `notmuch-hello-mode-hook' called during update
  2011-12-17  4:20 [PATCH 1/4] test: add `notmuch-hello-mode-hook-counter' Dmitry Kurochkin
  2011-12-17  4:20 ` [PATCH 2/4] test: add test for `notmuch-hello-mode-hook' Dmitry Kurochkin
@ 2011-12-17  4:20 ` Dmitry Kurochkin
  2011-12-17  4:20 ` [PATCH 4/4] emacs: do not call `notmuch-hello-mode' on update Dmitry Kurochkin
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 22+ messages in thread
From: Dmitry Kurochkin @ 2011-12-17  4:20 UTC (permalink / raw)
  To: notmuch

Test that `notmuch-hello-mode-hook' is not called during
`notmuch-hello' buffer updates.  The test is currently broken.
---
 test/emacs |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/test/emacs b/test/emacs
index a864ffa..b4c2444 100755
--- a/test/emacs
+++ b/test/emacs
@@ -485,4 +485,15 @@ counter=$(test_emacs \
 )
 test_expect_equal "$counter" 1
 
+test_begin_subtest "notmuch-hello-mode hook is not called on updates"
+test_subtest_known_broken
+counter=$(test_emacs \
+    '(let ((notmuch-hello-mode-hook-counter 0))
+       (kill-buffer "*notmuch-hello*")
+       (notmuch-hello)
+       (notmuch-hello-update)
+       notmuch-hello-mode-hook-counter)'
+)
+test_expect_equal "$counter" 1
+
 test_done
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH 4/4] emacs: do not call `notmuch-hello-mode' on update
  2011-12-17  4:20 [PATCH 1/4] test: add `notmuch-hello-mode-hook-counter' Dmitry Kurochkin
  2011-12-17  4:20 ` [PATCH 2/4] test: add test for `notmuch-hello-mode-hook' Dmitry Kurochkin
  2011-12-17  4:20 ` [PATCH 3/4] test: add broken test for `notmuch-hello-mode-hook' called during update Dmitry Kurochkin
@ 2011-12-17  4:20 ` Dmitry Kurochkin
  2011-12-17 20:16 ` [PATCH v2 0/4] " Dmitry Kurochkin
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 22+ messages in thread
From: Dmitry Kurochkin @ 2011-12-17  4:20 UTC (permalink / raw)
  To: notmuch

`notmuch-hello' should call `notmuch-hello-mode' function only when
run for the first time.  But before the change, `notmuch-hello' used
`kill-all-local-variables' to remove editable widgets fields.  This
caused the major mode to be reset, and `notmuch-hello-mode' to be
called every time.

The patch manually deletes all editable widget fields and removes
`kill-all-local-variables' call.
---
 emacs/notmuch-hello.el |   11 +++++++----
 test/emacs             |    1 -
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index ca3a381..3b21f55 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -403,11 +403,14 @@ Complete list of currently available key bindings:
 		     (progn
 		       (widget-forward 1)
 		       (widget-value (widget-at)))
-		   (error nil)))))
+		   (error nil))))
+	(inhibit-read-only t))
 
-    (kill-all-local-variables)
-    (let ((inhibit-read-only t))
-      (erase-buffer))
+    ;; delete all editable widget fields
+    (let ((all widget-field-list))
+      (mapc 'widget-delete widget-field-list))
+
+    (erase-buffer)
 
     (unless (eq major-mode 'notmuch-hello-mode)
       (notmuch-hello-mode))
diff --git a/test/emacs b/test/emacs
index b4c2444..dffad0f 100755
--- a/test/emacs
+++ b/test/emacs
@@ -486,7 +486,6 @@ counter=$(test_emacs \
 test_expect_equal "$counter" 1
 
 test_begin_subtest "notmuch-hello-mode hook is not called on updates"
-test_subtest_known_broken
 counter=$(test_emacs \
     '(let ((notmuch-hello-mode-hook-counter 0))
        (kill-buffer "*notmuch-hello*")
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v2 0/4] emacs: do not call `notmuch-hello-mode' on update
  2011-12-17  4:20 [PATCH 1/4] test: add `notmuch-hello-mode-hook-counter' Dmitry Kurochkin
                   ` (2 preceding siblings ...)
  2011-12-17  4:20 ` [PATCH 4/4] emacs: do not call `notmuch-hello-mode' on update Dmitry Kurochkin
@ 2011-12-17 20:16 ` Dmitry Kurochkin
  2011-12-17 20:16   ` [PATCH v2 1/4] test: add `notmuch-hello-mode-hook-counter' Dmitry Kurochkin
                     ` (3 more replies)
  2011-12-17 23:39 ` [PATCH v3 0/4] " Dmitry Kurochkin
  2011-12-18  0:21 ` [PATCH v4 0/4] " Dmitry Kurochkin
  5 siblings, 4 replies; 22+ messages in thread
From: Dmitry Kurochkin @ 2011-12-17 20:16 UTC (permalink / raw)
  To: notmuch

Changes in v2 since v1:

* actually use `all' variable in `mapc' call, thanks Tomi

Regards,
  Dmitry

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v2 1/4] test: add `notmuch-hello-mode-hook-counter'
  2011-12-17 20:16 ` [PATCH v2 0/4] " Dmitry Kurochkin
@ 2011-12-17 20:16   ` Dmitry Kurochkin
  2011-12-17 20:16   ` [PATCH v2 2/4] test: add test for `notmuch-hello-mode-hook' Dmitry Kurochkin
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 22+ messages in thread
From: Dmitry Kurochkin @ 2011-12-17 20:16 UTC (permalink / raw)
  To: notmuch

Add `notmuch-hello-mode-hook-counter' hook to count how many times
`notmuch-hello-mode-hook' was called.  The counter function increments
`notmuch-hello-mode-hook-counter' variable value if it is bount,
otherwise it does nothing.
---
 test/test-lib.el |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/test/test-lib.el b/test/test-lib.el
index 97ae593..3bca138 100644
--- a/test/test-lib.el
+++ b/test/test-lib.el
@@ -61,3 +61,12 @@ running, quit if it terminated."
   (if (not (process-attributes pid))
       (kill-emacs)
     (run-at-time "1 min" nil 'orphan-watchdog pid)))
+
+(defun notmuch-hello-mode-hook-counter ()
+  "Count how many times `notmuch-hello-mode-hook' is called.
+Increments `notmuch-hello-mode-hook-counter' variable value if it
+is bound, otherwise does nothing."
+  (if (boundp 'notmuch-hello-mode-hook-counter)
+      (setq notmuch-hello-mode-hook-counter
+	    (1+ notmuch-hello-mode-hook-counter))))
+(add-hook 'notmuch-hello-mode-hook 'notmuch-hello-mode-hook-counter)
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v2 2/4] test: add test for `notmuch-hello-mode-hook'
  2011-12-17 20:16 ` [PATCH v2 0/4] " Dmitry Kurochkin
  2011-12-17 20:16   ` [PATCH v2 1/4] test: add `notmuch-hello-mode-hook-counter' Dmitry Kurochkin
@ 2011-12-17 20:16   ` Dmitry Kurochkin
  2011-12-17 20:16   ` [PATCH v2 3/4] test: add broken test for `notmuch-hello-mode-hook' called during update Dmitry Kurochkin
  2011-12-17 20:17   ` [PATCH v2 4/4] emacs: do not call `notmuch-hello-mode' on update Dmitry Kurochkin
  3 siblings, 0 replies; 22+ messages in thread
From: Dmitry Kurochkin @ 2011-12-17 20:16 UTC (permalink / raw)
  To: notmuch

Test that `notmuch-hello-mode-hook' is called once when
`notmuch-hello' function is called.
---
 test/emacs |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/test/emacs b/test/emacs
index 6e922de..a864ffa 100755
--- a/test/emacs
+++ b/test/emacs
@@ -476,4 +476,13 @@ test_emacs "(let ((notmuch-command \"$notmuch_counter_command\"))
 	      (notmuch-show \"id:$id\"))"
 test_expect_equal $(notmuch_counter_value) 1
 
+test_begin_subtest "notmuch-hello-mode hook is called"
+counter=$(test_emacs \
+    '(let ((notmuch-hello-mode-hook-counter 0))
+       (kill-buffer "*notmuch-hello*")
+       (notmuch-hello)
+       notmuch-hello-mode-hook-counter)'
+)
+test_expect_equal "$counter" 1
+
 test_done
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v2 3/4] test: add broken test for `notmuch-hello-mode-hook' called during update
  2011-12-17 20:16 ` [PATCH v2 0/4] " Dmitry Kurochkin
  2011-12-17 20:16   ` [PATCH v2 1/4] test: add `notmuch-hello-mode-hook-counter' Dmitry Kurochkin
  2011-12-17 20:16   ` [PATCH v2 2/4] test: add test for `notmuch-hello-mode-hook' Dmitry Kurochkin
@ 2011-12-17 20:16   ` Dmitry Kurochkin
  2011-12-17 20:17   ` [PATCH v2 4/4] emacs: do not call `notmuch-hello-mode' on update Dmitry Kurochkin
  3 siblings, 0 replies; 22+ messages in thread
From: Dmitry Kurochkin @ 2011-12-17 20:16 UTC (permalink / raw)
  To: notmuch

Test that `notmuch-hello-mode-hook' is not called during
`notmuch-hello' buffer updates.  The test is currently broken.
---
 test/emacs |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/test/emacs b/test/emacs
index a864ffa..b4c2444 100755
--- a/test/emacs
+++ b/test/emacs
@@ -485,4 +485,15 @@ counter=$(test_emacs \
 )
 test_expect_equal "$counter" 1
 
+test_begin_subtest "notmuch-hello-mode hook is not called on updates"
+test_subtest_known_broken
+counter=$(test_emacs \
+    '(let ((notmuch-hello-mode-hook-counter 0))
+       (kill-buffer "*notmuch-hello*")
+       (notmuch-hello)
+       (notmuch-hello-update)
+       notmuch-hello-mode-hook-counter)'
+)
+test_expect_equal "$counter" 1
+
 test_done
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v2 4/4] emacs: do not call `notmuch-hello-mode' on update
  2011-12-17 20:16 ` [PATCH v2 0/4] " Dmitry Kurochkin
                     ` (2 preceding siblings ...)
  2011-12-17 20:16   ` [PATCH v2 3/4] test: add broken test for `notmuch-hello-mode-hook' called during update Dmitry Kurochkin
@ 2011-12-17 20:17   ` Dmitry Kurochkin
  3 siblings, 0 replies; 22+ messages in thread
From: Dmitry Kurochkin @ 2011-12-17 20:17 UTC (permalink / raw)
  To: notmuch

`notmuch-hello' should call `notmuch-hello-mode' function only when
run for the first time.  But before the change, `notmuch-hello' used
`kill-all-local-variables' to remove editable widgets fields.  This
caused the major mode to be reset, and `notmuch-hello-mode' to be
called every time.

The patch manually deletes all editable widget fields and removes
`kill-all-local-variables' call.
---
 emacs/notmuch-hello.el |   11 +++++++----
 test/emacs             |    1 -
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index ca3a381..fbbec66 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -403,11 +403,14 @@ Complete list of currently available key bindings:
 		     (progn
 		       (widget-forward 1)
 		       (widget-value (widget-at)))
-		   (error nil)))))
+		   (error nil))))
+	(inhibit-read-only t))
 
-    (kill-all-local-variables)
-    (let ((inhibit-read-only t))
-      (erase-buffer))
+    ;; delete all editable widget fields
+    (let ((all widget-field-list))
+      (mapc 'widget-delete all))
+
+    (erase-buffer)
 
     (unless (eq major-mode 'notmuch-hello-mode)
       (notmuch-hello-mode))
diff --git a/test/emacs b/test/emacs
index b4c2444..dffad0f 100755
--- a/test/emacs
+++ b/test/emacs
@@ -486,7 +486,6 @@ counter=$(test_emacs \
 test_expect_equal "$counter" 1
 
 test_begin_subtest "notmuch-hello-mode hook is not called on updates"
-test_subtest_known_broken
 counter=$(test_emacs \
     '(let ((notmuch-hello-mode-hook-counter 0))
        (kill-buffer "*notmuch-hello*")
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 0/4] emacs: do not call `notmuch-hello-mode' on update
  2011-12-17  4:20 [PATCH 1/4] test: add `notmuch-hello-mode-hook-counter' Dmitry Kurochkin
                   ` (3 preceding siblings ...)
  2011-12-17 20:16 ` [PATCH v2 0/4] " Dmitry Kurochkin
@ 2011-12-17 23:39 ` Dmitry Kurochkin
  2011-12-17 23:39   ` [PATCH v3 1/4] test: add `notmuch-hello-mode-hook-counter' Dmitry Kurochkin
                     ` (3 more replies)
  2011-12-18  0:21 ` [PATCH v4 0/4] " Dmitry Kurochkin
  5 siblings, 4 replies; 22+ messages in thread
From: Dmitry Kurochkin @ 2011-12-17 23:39 UTC (permalink / raw)
  To: notmuch

Changes:

v3:

* remove useless let with `widget-field-list', thanks Austin

v2:

* actually use `all' variable in `mapc' call, thanks Tomi

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v3 1/4] test: add `notmuch-hello-mode-hook-counter'
  2011-12-17 23:39 ` [PATCH v3 0/4] " Dmitry Kurochkin
@ 2011-12-17 23:39   ` Dmitry Kurochkin
  2011-12-17 23:39   ` [PATCH v3 2/4] test: add test for `notmuch-hello-mode-hook' Dmitry Kurochkin
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 22+ messages in thread
From: Dmitry Kurochkin @ 2011-12-17 23:39 UTC (permalink / raw)
  To: notmuch

Add `notmuch-hello-mode-hook-counter' hook to count how many times
`notmuch-hello-mode-hook' was called.  The counter function increments
`notmuch-hello-mode-hook-counter' variable value if it is bount,
otherwise it does nothing.
---
 test/test-lib.el |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/test/test-lib.el b/test/test-lib.el
index 97ae593..3bca138 100644
--- a/test/test-lib.el
+++ b/test/test-lib.el
@@ -61,3 +61,12 @@ running, quit if it terminated."
   (if (not (process-attributes pid))
       (kill-emacs)
     (run-at-time "1 min" nil 'orphan-watchdog pid)))
+
+(defun notmuch-hello-mode-hook-counter ()
+  "Count how many times `notmuch-hello-mode-hook' is called.
+Increments `notmuch-hello-mode-hook-counter' variable value if it
+is bound, otherwise does nothing."
+  (if (boundp 'notmuch-hello-mode-hook-counter)
+      (setq notmuch-hello-mode-hook-counter
+	    (1+ notmuch-hello-mode-hook-counter))))
+(add-hook 'notmuch-hello-mode-hook 'notmuch-hello-mode-hook-counter)
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 2/4] test: add test for `notmuch-hello-mode-hook'
  2011-12-17 23:39 ` [PATCH v3 0/4] " Dmitry Kurochkin
  2011-12-17 23:39   ` [PATCH v3 1/4] test: add `notmuch-hello-mode-hook-counter' Dmitry Kurochkin
@ 2011-12-17 23:39   ` Dmitry Kurochkin
  2011-12-17 23:39   ` [PATCH v3 3/4] test: add broken test for `notmuch-hello-mode-hook' called during update Dmitry Kurochkin
  2011-12-17 23:39   ` [PATCH v3 4/4] emacs: do not call `notmuch-hello-mode' on update Dmitry Kurochkin
  3 siblings, 0 replies; 22+ messages in thread
From: Dmitry Kurochkin @ 2011-12-17 23:39 UTC (permalink / raw)
  To: notmuch

Test that `notmuch-hello-mode-hook' is called once when
`notmuch-hello' function is called.
---
 test/emacs |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/test/emacs b/test/emacs
index 6e922de..a864ffa 100755
--- a/test/emacs
+++ b/test/emacs
@@ -476,4 +476,13 @@ test_emacs "(let ((notmuch-command \"$notmuch_counter_command\"))
 	      (notmuch-show \"id:$id\"))"
 test_expect_equal $(notmuch_counter_value) 1
 
+test_begin_subtest "notmuch-hello-mode hook is called"
+counter=$(test_emacs \
+    '(let ((notmuch-hello-mode-hook-counter 0))
+       (kill-buffer "*notmuch-hello*")
+       (notmuch-hello)
+       notmuch-hello-mode-hook-counter)'
+)
+test_expect_equal "$counter" 1
+
 test_done
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 3/4] test: add broken test for `notmuch-hello-mode-hook' called during update
  2011-12-17 23:39 ` [PATCH v3 0/4] " Dmitry Kurochkin
  2011-12-17 23:39   ` [PATCH v3 1/4] test: add `notmuch-hello-mode-hook-counter' Dmitry Kurochkin
  2011-12-17 23:39   ` [PATCH v3 2/4] test: add test for `notmuch-hello-mode-hook' Dmitry Kurochkin
@ 2011-12-17 23:39   ` Dmitry Kurochkin
  2011-12-17 23:39   ` [PATCH v3 4/4] emacs: do not call `notmuch-hello-mode' on update Dmitry Kurochkin
  3 siblings, 0 replies; 22+ messages in thread
From: Dmitry Kurochkin @ 2011-12-17 23:39 UTC (permalink / raw)
  To: notmuch

Test that `notmuch-hello-mode-hook' is not called during
`notmuch-hello' buffer updates.  The test is currently broken.
---
 test/emacs |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/test/emacs b/test/emacs
index a864ffa..b4c2444 100755
--- a/test/emacs
+++ b/test/emacs
@@ -485,4 +485,15 @@ counter=$(test_emacs \
 )
 test_expect_equal "$counter" 1
 
+test_begin_subtest "notmuch-hello-mode hook is not called on updates"
+test_subtest_known_broken
+counter=$(test_emacs \
+    '(let ((notmuch-hello-mode-hook-counter 0))
+       (kill-buffer "*notmuch-hello*")
+       (notmuch-hello)
+       (notmuch-hello-update)
+       notmuch-hello-mode-hook-counter)'
+)
+test_expect_equal "$counter" 1
+
 test_done
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v3 4/4] emacs: do not call `notmuch-hello-mode' on update
  2011-12-17 23:39 ` [PATCH v3 0/4] " Dmitry Kurochkin
                     ` (2 preceding siblings ...)
  2011-12-17 23:39   ` [PATCH v3 3/4] test: add broken test for `notmuch-hello-mode-hook' called during update Dmitry Kurochkin
@ 2011-12-17 23:39   ` Dmitry Kurochkin
  2011-12-18  0:16     ` Austin Clements
  3 siblings, 1 reply; 22+ messages in thread
From: Dmitry Kurochkin @ 2011-12-17 23:39 UTC (permalink / raw)
  To: notmuch

`notmuch-hello' should call `notmuch-hello-mode' function only when
run for the first time.  But before the change, `notmuch-hello' used
`kill-all-local-variables' to remove editable widgets fields.  This
caused the major mode to be reset, and `notmuch-hello-mode' to be
called every time.

The patch manually deletes all editable widget fields and removes
`kill-all-local-variables' call.
---
 emacs/notmuch-hello.el |   10 ++++++----
 test/emacs             |    1 -
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index ca3a381..c158e89 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -403,11 +403,13 @@ Complete list of currently available key bindings:
 		     (progn
 		       (widget-forward 1)
 		       (widget-value (widget-at)))
-		   (error nil)))))
+		   (error nil))))
+	(inhibit-read-only t))
 
-    (kill-all-local-variables)
-    (let ((inhibit-read-only t))
-      (erase-buffer))
+    ;; delete all editable widget fields
+    (mapc 'widget-delete widget-field-list)
+
+    (erase-buffer)
 
     (unless (eq major-mode 'notmuch-hello-mode)
       (notmuch-hello-mode))
diff --git a/test/emacs b/test/emacs
index b4c2444..dffad0f 100755
--- a/test/emacs
+++ b/test/emacs
@@ -486,7 +486,6 @@ counter=$(test_emacs \
 test_expect_equal "$counter" 1
 
 test_begin_subtest "notmuch-hello-mode hook is not called on updates"
-test_subtest_known_broken
 counter=$(test_emacs \
     '(let ((notmuch-hello-mode-hook-counter 0))
        (kill-buffer "*notmuch-hello*")
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH v3 4/4] emacs: do not call `notmuch-hello-mode' on update
  2011-12-17 23:39   ` [PATCH v3 4/4] emacs: do not call `notmuch-hello-mode' on update Dmitry Kurochkin
@ 2011-12-18  0:16     ` Austin Clements
  0 siblings, 0 replies; 22+ messages in thread
From: Austin Clements @ 2011-12-18  0:16 UTC (permalink / raw)
  To: Dmitry Kurochkin; +Cc: notmuch

This series looks good to me.  Just one nit below.

Quoth Dmitry Kurochkin on Dec 18 at  3:39 am:
> `notmuch-hello' should call `notmuch-hello-mode' function only when
> run for the first time.  But before the change, `notmuch-hello' used
> `kill-all-local-variables' to remove editable widgets fields.  This
> caused the major mode to be reset, and `notmuch-hello-mode' to be
> called every time.
> 
> The patch manually deletes all editable widget fields and removes
> `kill-all-local-variables' call.
> ---
>  emacs/notmuch-hello.el |   10 ++++++----
>  test/emacs             |    1 -
>  2 files changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
> index ca3a381..c158e89 100644
> --- a/emacs/notmuch-hello.el
> +++ b/emacs/notmuch-hello.el
> @@ -403,11 +403,13 @@ Complete list of currently available key bindings:
>  		     (progn
>  		       (widget-forward 1)
>  		       (widget-value (widget-at)))
> -		   (error nil)))))
> +		   (error nil))))
> +	(inhibit-read-only t))
>  
> -    (kill-all-local-variables)
> -    (let ((inhibit-read-only t))
> -      (erase-buffer))
> +    ;; delete all editable widget fields

It would be good to explain why this is necessary, so future
generations of notmuchers aren't as confused as I was by why this
dance is needed.

> +    (mapc 'widget-delete widget-field-list)
> +
> +    (erase-buffer)
>  
>      (unless (eq major-mode 'notmuch-hello-mode)
>        (notmuch-hello-mode))
> diff --git a/test/emacs b/test/emacs
> index b4c2444..dffad0f 100755
> --- a/test/emacs
> +++ b/test/emacs
> @@ -486,7 +486,6 @@ counter=$(test_emacs \
>  test_expect_equal "$counter" 1
>  
>  test_begin_subtest "notmuch-hello-mode hook is not called on updates"
> -test_subtest_known_broken
>  counter=$(test_emacs \
>      '(let ((notmuch-hello-mode-hook-counter 0))
>         (kill-buffer "*notmuch-hello*")

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v4 0/4] emacs: do not call `notmuch-hello-mode' on update
  2011-12-17  4:20 [PATCH 1/4] test: add `notmuch-hello-mode-hook-counter' Dmitry Kurochkin
                   ` (4 preceding siblings ...)
  2011-12-17 23:39 ` [PATCH v3 0/4] " Dmitry Kurochkin
@ 2011-12-18  0:21 ` Dmitry Kurochkin
  2011-12-18  0:21   ` [PATCH v4 1/4] test: add `notmuch-hello-mode-hook-counter' Dmitry Kurochkin
                     ` (5 more replies)
  5 siblings, 6 replies; 22+ messages in thread
From: Dmitry Kurochkin @ 2011-12-18  0:21 UTC (permalink / raw)
  To: notmuch

Changes:

v4:

* explain why we need to properly delete editable widget fields

v3:

* remove useless let with `widget-field-list', thanks Austin

v2:

* actually use `all' variable in `mapc' call, thanks Tomi

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v4 1/4] test: add `notmuch-hello-mode-hook-counter'
  2011-12-18  0:21 ` [PATCH v4 0/4] " Dmitry Kurochkin
@ 2011-12-18  0:21   ` Dmitry Kurochkin
  2011-12-18  0:21   ` [PATCH v4 2/4] test: add test for `notmuch-hello-mode-hook' Dmitry Kurochkin
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 22+ messages in thread
From: Dmitry Kurochkin @ 2011-12-18  0:21 UTC (permalink / raw)
  To: notmuch

Add `notmuch-hello-mode-hook-counter' hook to count how many times
`notmuch-hello-mode-hook' was called.  The counter function increments
`notmuch-hello-mode-hook-counter' variable value if it is bount,
otherwise it does nothing.
---
 test/test-lib.el |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/test/test-lib.el b/test/test-lib.el
index 97ae593..3bca138 100644
--- a/test/test-lib.el
+++ b/test/test-lib.el
@@ -61,3 +61,12 @@ running, quit if it terminated."
   (if (not (process-attributes pid))
       (kill-emacs)
     (run-at-time "1 min" nil 'orphan-watchdog pid)))
+
+(defun notmuch-hello-mode-hook-counter ()
+  "Count how many times `notmuch-hello-mode-hook' is called.
+Increments `notmuch-hello-mode-hook-counter' variable value if it
+is bound, otherwise does nothing."
+  (if (boundp 'notmuch-hello-mode-hook-counter)
+      (setq notmuch-hello-mode-hook-counter
+	    (1+ notmuch-hello-mode-hook-counter))))
+(add-hook 'notmuch-hello-mode-hook 'notmuch-hello-mode-hook-counter)
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 2/4] test: add test for `notmuch-hello-mode-hook'
  2011-12-18  0:21 ` [PATCH v4 0/4] " Dmitry Kurochkin
  2011-12-18  0:21   ` [PATCH v4 1/4] test: add `notmuch-hello-mode-hook-counter' Dmitry Kurochkin
@ 2011-12-18  0:21   ` Dmitry Kurochkin
  2011-12-18  0:21   ` [PATCH v4 3/4] test: add broken test for `notmuch-hello-mode-hook' called during update Dmitry Kurochkin
                     ` (3 subsequent siblings)
  5 siblings, 0 replies; 22+ messages in thread
From: Dmitry Kurochkin @ 2011-12-18  0:21 UTC (permalink / raw)
  To: notmuch

Test that `notmuch-hello-mode-hook' is called once when
`notmuch-hello' function is called.
---
 test/emacs |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/test/emacs b/test/emacs
index 6e922de..a864ffa 100755
--- a/test/emacs
+++ b/test/emacs
@@ -476,4 +476,13 @@ test_emacs "(let ((notmuch-command \"$notmuch_counter_command\"))
 	      (notmuch-show \"id:$id\"))"
 test_expect_equal $(notmuch_counter_value) 1
 
+test_begin_subtest "notmuch-hello-mode hook is called"
+counter=$(test_emacs \
+    '(let ((notmuch-hello-mode-hook-counter 0))
+       (kill-buffer "*notmuch-hello*")
+       (notmuch-hello)
+       notmuch-hello-mode-hook-counter)'
+)
+test_expect_equal "$counter" 1
+
 test_done
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 3/4] test: add broken test for `notmuch-hello-mode-hook' called during update
  2011-12-18  0:21 ` [PATCH v4 0/4] " Dmitry Kurochkin
  2011-12-18  0:21   ` [PATCH v4 1/4] test: add `notmuch-hello-mode-hook-counter' Dmitry Kurochkin
  2011-12-18  0:21   ` [PATCH v4 2/4] test: add test for `notmuch-hello-mode-hook' Dmitry Kurochkin
@ 2011-12-18  0:21   ` Dmitry Kurochkin
  2011-12-18  0:21   ` [PATCH v4 4/4] emacs: do not call `notmuch-hello-mode' on update Dmitry Kurochkin
                     ` (2 subsequent siblings)
  5 siblings, 0 replies; 22+ messages in thread
From: Dmitry Kurochkin @ 2011-12-18  0:21 UTC (permalink / raw)
  To: notmuch

Test that `notmuch-hello-mode-hook' is not called during
`notmuch-hello' buffer updates.  The test is currently broken.
---
 test/emacs |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/test/emacs b/test/emacs
index a864ffa..b4c2444 100755
--- a/test/emacs
+++ b/test/emacs
@@ -485,4 +485,15 @@ counter=$(test_emacs \
 )
 test_expect_equal "$counter" 1
 
+test_begin_subtest "notmuch-hello-mode hook is not called on updates"
+test_subtest_known_broken
+counter=$(test_emacs \
+    '(let ((notmuch-hello-mode-hook-counter 0))
+       (kill-buffer "*notmuch-hello*")
+       (notmuch-hello)
+       (notmuch-hello-update)
+       notmuch-hello-mode-hook-counter)'
+)
+test_expect_equal "$counter" 1
+
 test_done
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v4 4/4] emacs: do not call `notmuch-hello-mode' on update
  2011-12-18  0:21 ` [PATCH v4 0/4] " Dmitry Kurochkin
                     ` (2 preceding siblings ...)
  2011-12-18  0:21   ` [PATCH v4 3/4] test: add broken test for `notmuch-hello-mode-hook' called during update Dmitry Kurochkin
@ 2011-12-18  0:21   ` Dmitry Kurochkin
  2011-12-18  0:32   ` [PATCH v4 0/4] " Austin Clements
  2011-12-20 11:47   ` David Bremner
  5 siblings, 0 replies; 22+ messages in thread
From: Dmitry Kurochkin @ 2011-12-18  0:21 UTC (permalink / raw)
  To: notmuch

`notmuch-hello' should call `notmuch-hello-mode' function only when
run for the first time.  But before the change, `notmuch-hello' used
`kill-all-local-variables' to remove editable widgets fields.  This
caused the major mode to be reset, and `notmuch-hello-mode' to be
called every time.

The patch manually deletes all editable widget fields and removes
`kill-all-local-variables' call.
---
 emacs/notmuch-hello.el |   13 +++++++++----
 test/emacs             |    1 -
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index ca3a381..81b2605 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -403,11 +403,16 @@ Complete list of currently available key bindings:
 		     (progn
 		       (widget-forward 1)
 		       (widget-value (widget-at)))
-		   (error nil)))))
+		   (error nil))))
+	(inhibit-read-only t))
 
-    (kill-all-local-variables)
-    (let ((inhibit-read-only t))
-      (erase-buffer))
+    ;; Delete all editable widget fields.  Editable widget fields are
+    ;; tracked in a buffer local variable `widget-field-list' (and
+    ;; others).  If we do `erase-buffer' without properly deleting the
+    ;; widgets, some widget-related functions are confused later.
+    (mapc 'widget-delete widget-field-list)
+
+    (erase-buffer)
 
     (unless (eq major-mode 'notmuch-hello-mode)
       (notmuch-hello-mode))
diff --git a/test/emacs b/test/emacs
index b4c2444..dffad0f 100755
--- a/test/emacs
+++ b/test/emacs
@@ -486,7 +486,6 @@ counter=$(test_emacs \
 test_expect_equal "$counter" 1
 
 test_begin_subtest "notmuch-hello-mode hook is not called on updates"
-test_subtest_known_broken
 counter=$(test_emacs \
     '(let ((notmuch-hello-mode-hook-counter 0))
        (kill-buffer "*notmuch-hello*")
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH v4 0/4] emacs: do not call `notmuch-hello-mode' on update
  2011-12-18  0:21 ` [PATCH v4 0/4] " Dmitry Kurochkin
                     ` (3 preceding siblings ...)
  2011-12-18  0:21   ` [PATCH v4 4/4] emacs: do not call `notmuch-hello-mode' on update Dmitry Kurochkin
@ 2011-12-18  0:32   ` Austin Clements
  2011-12-20 11:47   ` David Bremner
  5 siblings, 0 replies; 22+ messages in thread
From: Austin Clements @ 2011-12-18  0:32 UTC (permalink / raw)
  To: Dmitry Kurochkin; +Cc: notmuch

LGTM.

Quoth Dmitry Kurochkin on Dec 18 at  4:21 am:
> Changes:
> 
> v4:
> 
> * explain why we need to properly delete editable widget fields
> 
> v3:
> 
> * remove useless let with `widget-field-list', thanks Austin
> 
> v2:
> 
> * actually use `all' variable in `mapc' call, thanks Tomi

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v4 0/4] emacs: do not call `notmuch-hello-mode' on update
  2011-12-18  0:21 ` [PATCH v4 0/4] " Dmitry Kurochkin
                     ` (4 preceding siblings ...)
  2011-12-18  0:32   ` [PATCH v4 0/4] " Austin Clements
@ 2011-12-20 11:47   ` David Bremner
  5 siblings, 0 replies; 22+ messages in thread
From: David Bremner @ 2011-12-20 11:47 UTC (permalink / raw)
  To: Dmitry Kurochkin, notmuch

On Sun, 18 Dec 2011 04:21:17 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:
> Changes:
> 
> v4:
> 
> * explain why we need to properly delete editable widget fields
> 

pushed.

d

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2011-12-20 11:47 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-17  4:20 [PATCH 1/4] test: add `notmuch-hello-mode-hook-counter' Dmitry Kurochkin
2011-12-17  4:20 ` [PATCH 2/4] test: add test for `notmuch-hello-mode-hook' Dmitry Kurochkin
2011-12-17  4:20 ` [PATCH 3/4] test: add broken test for `notmuch-hello-mode-hook' called during update Dmitry Kurochkin
2011-12-17  4:20 ` [PATCH 4/4] emacs: do not call `notmuch-hello-mode' on update Dmitry Kurochkin
2011-12-17 20:16 ` [PATCH v2 0/4] " Dmitry Kurochkin
2011-12-17 20:16   ` [PATCH v2 1/4] test: add `notmuch-hello-mode-hook-counter' Dmitry Kurochkin
2011-12-17 20:16   ` [PATCH v2 2/4] test: add test for `notmuch-hello-mode-hook' Dmitry Kurochkin
2011-12-17 20:16   ` [PATCH v2 3/4] test: add broken test for `notmuch-hello-mode-hook' called during update Dmitry Kurochkin
2011-12-17 20:17   ` [PATCH v2 4/4] emacs: do not call `notmuch-hello-mode' on update Dmitry Kurochkin
2011-12-17 23:39 ` [PATCH v3 0/4] " Dmitry Kurochkin
2011-12-17 23:39   ` [PATCH v3 1/4] test: add `notmuch-hello-mode-hook-counter' Dmitry Kurochkin
2011-12-17 23:39   ` [PATCH v3 2/4] test: add test for `notmuch-hello-mode-hook' Dmitry Kurochkin
2011-12-17 23:39   ` [PATCH v3 3/4] test: add broken test for `notmuch-hello-mode-hook' called during update Dmitry Kurochkin
2011-12-17 23:39   ` [PATCH v3 4/4] emacs: do not call `notmuch-hello-mode' on update Dmitry Kurochkin
2011-12-18  0:16     ` Austin Clements
2011-12-18  0:21 ` [PATCH v4 0/4] " Dmitry Kurochkin
2011-12-18  0:21   ` [PATCH v4 1/4] test: add `notmuch-hello-mode-hook-counter' Dmitry Kurochkin
2011-12-18  0:21   ` [PATCH v4 2/4] test: add test for `notmuch-hello-mode-hook' Dmitry Kurochkin
2011-12-18  0:21   ` [PATCH v4 3/4] test: add broken test for `notmuch-hello-mode-hook' called during update Dmitry Kurochkin
2011-12-18  0:21   ` [PATCH v4 4/4] emacs: do not call `notmuch-hello-mode' on update Dmitry Kurochkin
2011-12-18  0:32   ` [PATCH v4 0/4] " Austin Clements
2011-12-20 11:47   ` David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).