* Small bug in json-search changes
@ 2012-08-06 23:10 Mark Walters
2012-08-06 23:47 ` Austin Clements
0 siblings, 1 reply; 9+ messages in thread
From: Mark Walters @ 2012-08-06 23:10 UTC (permalink / raw)
To: Austin Clements, notmuch
Hi
I have found a small bug in the recent changes to notmuch search to use
the JSON output. If you refresh the search buffer "point" does not stay
on the same thread.
I think the problem is that notmuch-search-refresh-view calls notmuch
search with target-thread set to notmuch-search-find-thread-id which
returns the thread-id with "thread:" prefixed, whereas
notmuch-search-show-result checks for a match with (plist-get result
:thread) which is the thread id with no prefix.
The patch below fixes this but I am not sure it is the nicest fix.
Best wishes
Mark
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index d2d82a9..a53d5a0 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -798,7 +798,7 @@ non-authors is found, assume that all of the authors match."
(insert "\n")
(notmuch-search-color-line beg (point) (plist-get result :tags))
(put-text-property beg (point) 'notmuch-search-result result))
- (when (string= (plist-get result :thread) notmuch-search-target-thread)
+ (when (string= (concat "thread:" (plist-get result :thread)) notmuch-search-target-thread)
(setq notmuch-search-target-thread "found")
(goto-char beg)))))
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: Small bug in json-search changes
2012-08-06 23:10 Small bug in json-search changes Mark Walters
@ 2012-08-06 23:47 ` Austin Clements
2012-08-07 15:40 ` [PATCH] emacs: notmuch search bugfix Mark Walters
0 siblings, 1 reply; 9+ messages in thread
From: Austin Clements @ 2012-08-06 23:47 UTC (permalink / raw)
To: Mark Walters; +Cc: notmuch
Nice catch. I think the solution is either exactly this, or we should
strip "thread:" off notmuch-search-target-thread when we set it. I
would lean slightly toward the latter so we don't have to generate up
a new (identical) string on every notmuch-search-show-result call, but
I doubt it would make much difference in the grand scheme of things.
Quoth Mark Walters on Aug 07 at 12:10 am:
>
> Hi
>
> I have found a small bug in the recent changes to notmuch search to use
> the JSON output. If you refresh the search buffer "point" does not stay
> on the same thread.
>
> I think the problem is that notmuch-search-refresh-view calls notmuch
> search with target-thread set to notmuch-search-find-thread-id which
> returns the thread-id with "thread:" prefixed, whereas
> notmuch-search-show-result checks for a match with (plist-get result
> :thread) which is the thread id with no prefix.
>
> The patch below fixes this but I am not sure it is the nicest fix.
>
> Best wishes
>
> Mark
>
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index d2d82a9..a53d5a0 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -798,7 +798,7 @@ non-authors is found, assume that all of the authors match."
> (insert "\n")
> (notmuch-search-color-line beg (point) (plist-get result :tags))
> (put-text-property beg (point) 'notmuch-search-result result))
> - (when (string= (plist-get result :thread) notmuch-search-target-thread)
> + (when (string= (concat "thread:" (plist-get result :thread)) notmuch-search-target-thread)
> (setq notmuch-search-target-thread "found")
> (goto-char beg)))))
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] emacs: notmuch search bugfix
2012-08-06 23:47 ` Austin Clements
@ 2012-08-07 15:40 ` Mark Walters
2012-08-07 16:03 ` Austin Clements
2012-08-07 16:09 ` [PATCH] " Tomi Ollila
0 siblings, 2 replies; 9+ messages in thread
From: Mark Walters @ 2012-08-07 15:40 UTC (permalink / raw)
To: Austin Clements; +Cc: notmuch
The recent change to use json for notmuch-search.el introduced a bug
in the code for keeping position on refresh. The problem is a
comparison between (plist-get result :thread) and a thread-id returned
by notmuch-search-find-thread-id: the latter is prefixed with
"thread:"
We fix this by adding an option to notmuch-search-find-thread-id to
return the bare thread-id. It appears that notmuch-search-refresh-view
is the only caller of notmuch-search that supplies a thread-id so this
change should be safe (but could theoretically break users .emacs
functions).
---
This is a different version of the bugfix suggested in the parent to
this thread. I think it is nicer but there is a slight risk of breaking
users .emacs lisp functions.
In general I think the thread: prefix should be present where the term
is "really" a search term, but absent when it is must be a thread-id,
and this fits with that idea.
With 0.14 freeze pretty close it might be best to apply this to master
and the simpler no breakage option (in id:"87boinpqfg.fsf@qmul.ac.uk")
to the branch.
Best wishes
Mark
emacs/notmuch.el | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index d2d82a9..0fff58a 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -475,10 +475,12 @@ BEG."
(push (plist-get (notmuch-search-get-result pos) property) output)))
output))
-(defun notmuch-search-find-thread-id ()
- "Return the thread for the current thread"
+(defun notmuch-search-find-thread-id (&optional bare)
+ "Return the thread for the current thread
+
+If BARE is set then do not prefix with \"thread:\""
(let ((thread (plist-get (notmuch-search-get-result) :thread)))
- (when thread (concat "thread:" thread))))
+ (when thread (concat (when (not bare) "thread:") thread))))
(defun notmuch-search-find-thread-id-region (beg end)
"Return a list of threads for the current region"
@@ -993,7 +995,7 @@ same relative position within the new buffer."
(interactive)
(let ((target-line (line-number-at-pos))
(oldest-first notmuch-search-oldest-first)
- (target-thread (notmuch-search-find-thread-id))
+ (target-thread (notmuch-search-find-thread-id t))
(query notmuch-search-query-string)
(continuation notmuch-search-continuation))
(notmuch-kill-this-buffer)
--
1.7.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] emacs: notmuch search bugfix
2012-08-07 15:40 ` [PATCH] emacs: notmuch search bugfix Mark Walters
@ 2012-08-07 16:03 ` Austin Clements
2012-08-07 16:32 ` [PATCH v2] " Mark Walters
2012-08-07 16:09 ` [PATCH] " Tomi Ollila
1 sibling, 1 reply; 9+ messages in thread
From: Austin Clements @ 2012-08-07 16:03 UTC (permalink / raw)
To: Mark Walters; +Cc: notmuch
Quoth Mark Walters on Aug 07 at 4:40 pm:
>
> The recent change to use json for notmuch-search.el introduced a bug
> in the code for keeping position on refresh. The problem is a
> comparison between (plist-get result :thread) and a thread-id returned
> by notmuch-search-find-thread-id: the latter is prefixed with
> "thread:"
>
> We fix this by adding an option to notmuch-search-find-thread-id to
> return the bare thread-id. It appears that notmuch-search-refresh-view
> is the only caller of notmuch-search that supplies a thread-id so this
> change should be safe (but could theoretically break users .emacs
> functions).
> ---
>
> This is a different version of the bugfix suggested in the parent to
> this thread. I think it is nicer but there is a slight risk of breaking
> users .emacs lisp functions.
>
> In general I think the thread: prefix should be present where the term
> is "really" a search term, but absent when it is must be a thread-id,
> and this fits with that idea.
Agreed.
> With 0.14 freeze pretty close it might be best to apply this to master
> and the simpler no breakage option (in id:"87boinpqfg.fsf@qmul.ac.uk")
> to the branch.
>
> Best wishes
>
> Mark
>
> emacs/notmuch.el | 10 ++++++----
> 1 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index d2d82a9..0fff58a 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -475,10 +475,12 @@ BEG."
> (push (plist-get (notmuch-search-get-result pos) property) output)))
> output))
>
> -(defun notmuch-search-find-thread-id ()
> - "Return the thread for the current thread"
> +(defun notmuch-search-find-thread-id (&optional bare)
> + "Return the thread for the current thread
> +
> +If BARE is set then do not prefix with \"thread:\""
> (let ((thread (plist-get (notmuch-search-get-result) :thread)))
> - (when thread (concat "thread:" thread))))
> + (when thread (concat (when (not bare) "thread:") thread))))
(unless bare "thread:")?
>
> (defun notmuch-search-find-thread-id-region (beg end)
> "Return a list of threads for the current region"
> @@ -993,7 +995,7 @@ same relative position within the new buffer."
> (interactive)
> (let ((target-line (line-number-at-pos))
> (oldest-first notmuch-search-oldest-first)
> - (target-thread (notmuch-search-find-thread-id))
> + (target-thread (notmuch-search-find-thread-id t))
Perhaps pass 'bare instead of t to make this self-documenting?
> (query notmuch-search-query-string)
> (continuation notmuch-search-continuation))
> (notmuch-kill-this-buffer)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] emacs: notmuch search bugfix
2012-08-07 15:40 ` [PATCH] emacs: notmuch search bugfix Mark Walters
2012-08-07 16:03 ` Austin Clements
@ 2012-08-07 16:09 ` Tomi Ollila
1 sibling, 0 replies; 9+ messages in thread
From: Tomi Ollila @ 2012-08-07 16:09 UTC (permalink / raw)
To: Mark Walters, Austin Clements; +Cc: notmuch
On Tue, Aug 07 2012, Mark Walters wrote:
> The recent change to use json for notmuch-search.el introduced a bug
> in the code for keeping position on refresh. The problem is a
> comparison between (plist-get result :thread) and a thread-id returned
> by notmuch-search-find-thread-id: the latter is prefixed with
> "thread:"
>
> We fix this by adding an option to notmuch-search-find-thread-id to
> return the bare thread-id. It appears that notmuch-search-refresh-view
> is the only caller of notmuch-search that supplies a thread-id so this
> change should be safe (but could theoretically break users .emacs
> functions).
> ---
>
> This is a different version of the bugfix suggested in the parent to
> this thread. I think it is nicer but there is a slight risk of breaking
> users .emacs lisp functions.
>
> In general I think the thread: prefix should be present where the term
> is "really" a search term, but absent when it is must be a thread-id,
> and this fits with that idea.
>
> With 0.14 freeze pretty close it might be best to apply this to master
> and the simpler no breakage option (in id:"87boinpqfg.fsf@qmul.ac.uk")
> to the branch.
LGTM.
IMHO you're too shy with this patch to be included in 0.14 :D
-- at least I cannot imagine a case this would fail...
My change would have been:
(when thread (if bare thread (concat "thread:" thread)))
or even (which changes irrelevant part):
(if thread (if bare thread (concat "thread:" thread)))
Anyway, this is good as it is "in the grand scheme of things".
Tomi
>
> Best wishes
>
> Mark
>
> emacs/notmuch.el | 10 ++++++----
> 1 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index d2d82a9..0fff58a 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -475,10 +475,12 @@ BEG."
> (push (plist-get (notmuch-search-get-result pos) property) output)))
> output))
>
> -(defun notmuch-search-find-thread-id ()
> - "Return the thread for the current thread"
> +(defun notmuch-search-find-thread-id (&optional bare)
> + "Return the thread for the current thread
> +
> +If BARE is set then do not prefix with \"thread:\""
> (let ((thread (plist-get (notmuch-search-get-result) :thread)))
> - (when thread (concat "thread:" thread))))
> + (when thread (concat (when (not bare) "thread:") thread))))
>
> (defun notmuch-search-find-thread-id-region (beg end)
> "Return a list of threads for the current region"
> @@ -993,7 +995,7 @@ same relative position within the new buffer."
> (interactive)
> (let ((target-line (line-number-at-pos))
> (oldest-first notmuch-search-oldest-first)
> - (target-thread (notmuch-search-find-thread-id))
> + (target-thread (notmuch-search-find-thread-id t))
> (query notmuch-search-query-string)
> (continuation notmuch-search-continuation))
> (notmuch-kill-this-buffer)
> --
> 1.7.9.1
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2] emacs: notmuch search bugfix
2012-08-07 16:03 ` Austin Clements
@ 2012-08-07 16:32 ` Mark Walters
2012-08-07 18:26 ` Austin Clements
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Mark Walters @ 2012-08-07 16:32 UTC (permalink / raw)
To: Austin Clements; +Cc: notmuch
The recent change to use json for notmuch-search.el introduced a bug
in the code for keeping position on refresh. The problem is a
comparison between (plist-get result :thread) and a thread-id returned
by notmuch-search-find-thread-id: the latter is prefixed with
"thread:"
We fix this by adding an option to notmuch-search-find-thread-id to
return the bare thread-id. It appears that notmuch-search-refresh-view
is the only caller of notmuch-search that supplies a thread-id so this
change should be safe (but could theoretically break users .emacs
functions).
---
I think this implements all of Austin's suggestions, and it adds a short
remark to NEWS (since in unlikely cases it could break users' functions)
and updates the docstring for notmuch-search.
Best wishes
Mark
NEWS | 3 +++
emacs/notmuch.el | 12 +++++++-----
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/NEWS b/NEWS
index 761b2c1..9916c91 100644
--- a/NEWS
+++ b/NEWS
@@ -55,6 +55,9 @@ user-specified formatting
you've customized this variable, you may have to change your date
format from `"%s "` to `"%12s "`.
+The thread-id for the `target-thread` argument for `notmuch-search` should
+now be supplied without the "thread:" prefix.
+
Notmuch 0.13.2 (2012-06-02)
===========================
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index d2d82a9..7b61e9b 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -475,10 +475,12 @@ BEG."
(push (plist-get (notmuch-search-get-result pos) property) output)))
output))
-(defun notmuch-search-find-thread-id ()
- "Return the thread for the current thread"
+(defun notmuch-search-find-thread-id (&optional bare)
+ "Return the thread for the current thread
+
+If BARE is set then do not prefix with \"thread:\""
(let ((thread (plist-get (notmuch-search-get-result) :thread)))
- (when thread (concat "thread:" thread))))
+ (when thread (concat (unless bare "thread:") thread))))
(defun notmuch-search-find-thread-id-region (beg end)
"Return a list of threads for the current region"
@@ -936,7 +938,7 @@ If `query' is nil, it is read interactively from the minibuffer.
Other optional parameters are used as follows:
oldest-first: A Boolean controlling the sort order of returned threads
- target-thread: A thread ID (with the thread: prefix) that will be made
+ target-thread: A thread ID (without the thread: prefix) that will be made
current if it appears in the search results.
target-line: The line number to move to if the target thread does not
appear in the search results."
@@ -993,7 +995,7 @@ same relative position within the new buffer."
(interactive)
(let ((target-line (line-number-at-pos))
(oldest-first notmuch-search-oldest-first)
- (target-thread (notmuch-search-find-thread-id))
+ (target-thread (notmuch-search-find-thread-id 'bare))
(query notmuch-search-query-string)
(continuation notmuch-search-continuation))
(notmuch-kill-this-buffer)
--
1.7.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2] emacs: notmuch search bugfix
2012-08-07 16:32 ` [PATCH v2] " Mark Walters
@ 2012-08-07 18:26 ` Austin Clements
2012-08-08 6:01 ` Tomi Ollila
2012-08-12 19:51 ` David Bremner
2 siblings, 0 replies; 9+ messages in thread
From: Austin Clements @ 2012-08-07 18:26 UTC (permalink / raw)
To: Mark Walters; +Cc: notmuch
On Tue, 07 Aug 2012, Mark Walters <markwalters1009@gmail.com> wrote:
> The recent change to use json for notmuch-search.el introduced a bug
> in the code for keeping position on refresh. The problem is a
> comparison between (plist-get result :thread) and a thread-id returned
> by notmuch-search-find-thread-id: the latter is prefixed with
> "thread:"
>
> We fix this by adding an option to notmuch-search-find-thread-id to
> return the bare thread-id. It appears that notmuch-search-refresh-view
> is the only caller of notmuch-search that supplies a thread-id so this
> change should be safe (but could theoretically break users .emacs
> functions).
> ---
>
> I think this implements all of Austin's suggestions, and it adds a short
> remark to NEWS (since in unlikely cases it could break users' functions)
> and updates the docstring for notmuch-search.
LGTM.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] emacs: notmuch search bugfix
2012-08-07 16:32 ` [PATCH v2] " Mark Walters
2012-08-07 18:26 ` Austin Clements
@ 2012-08-08 6:01 ` Tomi Ollila
2012-08-12 19:51 ` David Bremner
2 siblings, 0 replies; 9+ messages in thread
From: Tomi Ollila @ 2012-08-08 6:01 UTC (permalink / raw)
To: Mark Walters, Austin Clements; +Cc: notmuch
On Tue, Aug 07 2012, Mark Walters <markwalters1009@gmail.com> wrote:
> The recent change to use json for notmuch-search.el introduced a bug
> in the code for keeping position on refresh. The problem is a
> comparison between (plist-get result :thread) and a thread-id returned
> by notmuch-search-find-thread-id: the latter is prefixed with
> "thread:"
>
> We fix this by adding an option to notmuch-search-find-thread-id to
> return the bare thread-id. It appears that notmuch-search-refresh-view
> is the only caller of notmuch-search that supplies a thread-id so this
> change should be safe (but could theoretically break users .emacs
> functions).
> ---
LGTM.
Tomi
>
> I think this implements all of Austin's suggestions, and it adds a short
> remark to NEWS (since in unlikely cases it could break users' functions)
> and updates the docstring for notmuch-search.
>
> Best wishes
>
> Mark
>
> NEWS | 3 +++
> emacs/notmuch.el | 12 +++++++-----
> 2 files changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/NEWS b/NEWS
> index 761b2c1..9916c91 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -55,6 +55,9 @@ user-specified formatting
> you've customized this variable, you may have to change your date
> format from `"%s "` to `"%12s "`.
>
> +The thread-id for the `target-thread` argument for `notmuch-search` should
> +now be supplied without the "thread:" prefix.
> +
> Notmuch 0.13.2 (2012-06-02)
> ===========================
>
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index d2d82a9..7b61e9b 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -475,10 +475,12 @@ BEG."
> (push (plist-get (notmuch-search-get-result pos) property) output)))
> output))
>
> -(defun notmuch-search-find-thread-id ()
> - "Return the thread for the current thread"
> +(defun notmuch-search-find-thread-id (&optional bare)
> + "Return the thread for the current thread
> +
> +If BARE is set then do not prefix with \"thread:\""
> (let ((thread (plist-get (notmuch-search-get-result) :thread)))
> - (when thread (concat "thread:" thread))))
> + (when thread (concat (unless bare "thread:") thread))))
>
> (defun notmuch-search-find-thread-id-region (beg end)
> "Return a list of threads for the current region"
> @@ -936,7 +938,7 @@ If `query' is nil, it is read interactively from the minibuffer.
> Other optional parameters are used as follows:
>
> oldest-first: A Boolean controlling the sort order of returned threads
> - target-thread: A thread ID (with the thread: prefix) that will be made
> + target-thread: A thread ID (without the thread: prefix) that will be made
> current if it appears in the search results.
> target-line: The line number to move to if the target thread does not
> appear in the search results."
> @@ -993,7 +995,7 @@ same relative position within the new buffer."
> (interactive)
> (let ((target-line (line-number-at-pos))
> (oldest-first notmuch-search-oldest-first)
> - (target-thread (notmuch-search-find-thread-id))
> + (target-thread (notmuch-search-find-thread-id 'bare))
> (query notmuch-search-query-string)
> (continuation notmuch-search-continuation))
> (notmuch-kill-this-buffer)
> --
> 1.7.9.1
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] emacs: notmuch search bugfix
2012-08-07 16:32 ` [PATCH v2] " Mark Walters
2012-08-07 18:26 ` Austin Clements
2012-08-08 6:01 ` Tomi Ollila
@ 2012-08-12 19:51 ` David Bremner
2 siblings, 0 replies; 9+ messages in thread
From: David Bremner @ 2012-08-12 19:51 UTC (permalink / raw)
To: Mark Walters, Austin Clements; +Cc: notmuch
Mark Walters <markwalters1009@gmail.com> writes:
> The recent change to use json for notmuch-search.el introduced a bug
> in the code for keeping position on refresh. The problem is a
> comparison between (plist-get result :thread) and a thread-id returned
pushed,
d
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2012-08-12 19:51 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-06 23:10 Small bug in json-search changes Mark Walters
2012-08-06 23:47 ` Austin Clements
2012-08-07 15:40 ` [PATCH] emacs: notmuch search bugfix Mark Walters
2012-08-07 16:03 ` Austin Clements
2012-08-07 16:32 ` [PATCH v2] " Mark Walters
2012-08-07 18:26 ` Austin Clements
2012-08-08 6:01 ` Tomi Ollila
2012-08-12 19:51 ` David Bremner
2012-08-07 16:09 ` [PATCH] " Tomi Ollila
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).