[PATCH 0/6] Add an unthreaded mode

classic Classic list List threaded Threaded
14 messages Options
Mark Walters Mark Walters
Reply | Threaded
Open this post in threaded view
|

[PATCH 0/6] Add an unthreaded mode

This series adds an unthreaded mode. In this mode all messages
matching the query are shown, one per line, in unthreaded (reverse)
date order. For some discussion of such a mode see
id:[hidden email] and subsequent thread.

The main key bindings are u to run an unthreaded search, and U to
rerun the current query in unthreaded view.

Most of the functionality comes from the existing notmuch-tree code so
it is relatively simple.

I have been running some very similar code for just over a year and
finally found time to tidy and submit it.

One note: --entire-thread=false outputs just the matching messages
(not the entire threads) but still in threaded order, and this option
can be used by pre-existing emacs functionality (depending on user
settings); this is why I added a new --unthreaded option.

Best wishes

Mark


Mark Walters (6):
  notmuch-show.c: add an option for messages to be returned unthreaded
  Introduce unthreaded mode
  Unthreaded mode: allow different result format
  Unthreaded mode: allow user to choose different `show out' than tree
  Add a U binding to switch to unthreaded from other views
  notmuch-hello/jump: allow saved searches to specify unthreaded mode

 emacs/notmuch-hello.el | 31 +++++++++++------
 emacs/notmuch-jump.el  | 10 ++++--
 emacs/notmuch-lib.el   |  1 +
 emacs/notmuch-show.el  | 12 ++++++-
 emacs/notmuch-tree.el  | 92 +++++++++++++++++++++++++++++++++++++++++++-------
 emacs/notmuch.el       |  6 ++++
 notmuch-show.c         | 61 +++++++++++++++++++++++++++++----
 7 files changed, 180 insertions(+), 33 deletions(-)

--
2.11.0

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Mark Walters Mark Walters
Reply | Threaded
Open this post in threaded view
|

[PATCH 1/6] notmuch-show.c: add an option for messages to be returned unthreaded

This adds a --unthreaded option to notmuch show to tell it to return
the matching messages in an unthreaded order (so just by date).

To make it easier for users, in particular for notmuch-tree.el, we
output each message with the same "nesting" as if it were an entire
thread in its own right.
---
 notmuch-show.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 55 insertions(+), 6 deletions(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index 21792a57..cf543ed9 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -1066,11 +1066,11 @@ do_show_single (void *ctx,
 
 /* Formatted output of threads */
 static int
-do_show (void *ctx,
- notmuch_query_t *query,
- const notmuch_show_format_t *format,
- sprinter_t *sp,
- notmuch_show_params_t *params)
+do_show_threaded (void *ctx,
+  notmuch_query_t *query,
+  const notmuch_show_format_t *format,
+  sprinter_t *sp,
+  notmuch_show_params_t *params)
 {
     notmuch_threads_t *threads;
     notmuch_thread_t *thread;
@@ -1107,6 +1107,50 @@ do_show (void *ctx,
     return res != NOTMUCH_STATUS_SUCCESS;
 }
 
+static int
+do_show_unthreaded (void *ctx,
+    notmuch_query_t *query,
+    const notmuch_show_format_t *format,
+    sprinter_t *sp,
+    notmuch_show_params_t *params)
+{
+    notmuch_messages_t *messages;
+    notmuch_message_t *message;
+    notmuch_status_t status, res = NOTMUCH_STATUS_SUCCESS;
+    notmuch_bool_t excluded;
+
+    status= notmuch_query_search_messages (query, &messages);
+    if (print_status_query ("notmuch show", query, status))
+ return 1;
+
+    sp->begin_list (sp);
+
+    for (;
+ notmuch_messages_valid (messages);
+ notmuch_messages_move_to_next (messages)) {
+ sp->begin_list (sp);
+ sp->begin_list (sp);
+
+ message = notmuch_messages_get (messages);
+
+ notmuch_message_set_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH, TRUE);
+ excluded = notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED);
+
+ if (!excluded || !params->omit_excluded) {
+    status = show_message (ctx, format, sp, message, 0, params);
+    if (status && !res)
+ res = status;
+ } else {
+    sp->null (sp);
+ }
+ notmuch_message_destroy (message);
+ sp->end (sp);
+ sp->end (sp);
+    }
+    sp->end (sp);
+    return res;
+}
+
 enum {
     NOTMUCH_FORMAT_NOT_SPECIFIED,
     NOTMUCH_FORMAT_JSON,
@@ -1168,6 +1212,7 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[])
     bool exclude = true;
     bool entire_thread_set = false;
     bool single_message;
+    bool unthreaded = FALSE;
 
     notmuch_opt_desc_t options[] = {
  { .opt_keyword = &format, .name = "format", .keywords =
@@ -1181,6 +1226,7 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[])
  { .opt_bool = &exclude, .name = "exclude" },
  { .opt_bool = &params.entire_thread, .name = "entire-thread",
   .present = &entire_thread_set },
+ { .opt_bool = &unthreaded, .name = "unthreaded" },
  { .opt_int = &params.part, .name = "part" },
  { .opt_keyword = (int *) (&params.crypto.decrypt), .name = "decrypt",
   .keyword_no_arg_value = "true", .keywords =
@@ -1317,7 +1363,10 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[])
     params.omit_excluded = false;
  }
 
- ret = do_show (config, query, formatter, sprinter, &params);
+ if (unthreaded)
+    ret = do_show_unthreaded (config, query, formatter, sprinter, &params);
+ else
+    ret = do_show_threaded (config, query, formatter, sprinter, &params);
     }
 
   DONE:
--
2.11.0

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Mark Walters Mark Walters
Reply | Threaded
Open this post in threaded view
|

[PATCH 2/6] Introduce unthreaded mode

In reply to this post by Mark Walters
This commit introduces a new 'unthreaded' search mode where each
matching message is shown on a separate line. It shares almost all of
its code with tree view. Subsequent commits will allow it to diverge
slightly in appearance.
---
 emacs/notmuch-hello.el |  2 +-
 emacs/notmuch-lib.el   |  1 +
 emacs/notmuch-show.el  |  2 +-
 emacs/notmuch-tree.el  | 28 +++++++++++++++++++++-------
 4 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index aff8beb5..858446df 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -31,7 +31,7 @@
 (declare-function notmuch-search "notmuch" (&optional query oldest-first target-thread target-line continuation))
 (declare-function notmuch-poll "notmuch" ())
 (declare-function notmuch-tree "notmuch-tree"
-                  (&optional query query-context target buffer-name open-target))
+  (&optional query query-context target buffer-name open-target unthreaded))
 
 (defun notmuch-saved-search-get (saved-search field)
   "Get FIELD from SAVED-SEARCH.
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 8acad267..73b165e4 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -154,6 +154,7 @@ For example, if you wanted to remove an \"inbox\" tag and add an
     (define-key map "q" 'notmuch-bury-or-kill-this-buffer)
     (define-key map "s" 'notmuch-search)
     (define-key map "z" 'notmuch-tree)
+    (define-key map "u" 'notmuch-unthreaded)
     (define-key map "m" 'notmuch-mua-new-mail)
     (define-key map "g" 'notmuch-refresh-this-buffer)
     (define-key map "=" 'notmuch-refresh-this-buffer)
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index ef2bf1e0..d4a1389b 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -48,7 +48,7 @@
 (declare-function notmuch-count-attachments "notmuch" (mm-handle))
 (declare-function notmuch-save-attachments "notmuch" (mm-handle &optional queryp))
 (declare-function notmuch-tree "notmuch-tree"
-  (&optional query query-context target buffer-name open-target))
+  (&optional query query-context target buffer-name open-target unthreaded))
 (declare-function notmuch-tree-get-message-properties "notmuch-tree" nil)
 (declare-function notmuch-read-query "notmuch" (prompt))
 (declare-function notmuch-draft-resume "notmuch-draft" (id))
diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index c00315e8..80b830dd 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -42,6 +42,11 @@
 ;; the following variable is defined in notmuch.el
 (defvar notmuch-search-query-string)
 
+;; this variable distinguishes the unthreaded display from the normal tree display
+(defvar notmuch-tree-unthreaded nil
+  "A buffer local copy of argument unthreaded to the function notmuch-tree")
+(make-variable-buffer-local 'notmuch-tree-unthreaded)
+
 (defgroup notmuch-tree nil
   "Showing message and thread structure."
   :group 'notmuch)
@@ -890,7 +895,7 @@ Complete list of currently available key bindings:
  (notmuch-sexp-parse-partial-list 'notmuch-tree-insert-forest-thread
  results-buf)))))
 
-(defun notmuch-tree-worker (basic-query &optional query-context target open-target)
+(defun notmuch-tree-worker (basic-query &optional query-context target open-target unthreaded)
   "Insert the tree view of the search in the current buffer.
 
 This is is a helper function for notmuch-tree. The arguments are
@@ -898,6 +903,7 @@ the same as for the function notmuch-tree."
   (interactive)
   (notmuch-tree-mode)
   (add-hook 'post-command-hook #'notmuch-tree-command-hook t t)
+  (setq notmuch-tree-unthreaded unthreaded)
   (setq notmuch-tree-basic-query basic-query)
   (setq notmuch-tree-query-context (if (or (string= query-context "")
    (string= query-context "*"))
@@ -915,7 +921,7 @@ the same as for the function notmuch-tree."
   (let* ((search-args (concat basic-query
        (if query-context (concat " and (" query-context ")"))
        ))
- (message-arg "--entire-thread"))
+ (message-arg (if unthreaded "--unthreaded" "--entire-thread")))
     (if (equal (car (process-lines notmuch-command "count" search-args)) "0")
  (setq search-args basic-query))
     (notmuch-tag-clear-cache)
@@ -940,7 +946,7 @@ the same as for the function notmuch-tree."
       ")")
     notmuch-tree-basic-query))
 
-(defun notmuch-tree (&optional query query-context target buffer-name open-target)
+(defun notmuch-tree (&optional query query-context target buffer-name open-target unthreaded)
   "Display threads matching QUERY in Tree View.
 
 The arguments are:
@@ -953,23 +959,31 @@ The arguments are:
       current if it appears in the tree view results.
   BUFFER-NAME: the name of the buffer to display the tree view. If
       it is nil \"*notmuch-tree\" followed by QUERY is used.
-  OPEN-TARGET: If TRUE open the target message in the message pane."
+  OPEN-TARGET: If TRUE open the target message in the message pane.
+  UNTHREADED: If TRUE only show matching messages in an unthreaded view."
   (interactive)
   (if (null query)
-      (setq query (notmuch-read-query "Notmuch tree view search: ")))
+      (setq query (notmuch-read-query (concat "Notmuch "
+      (if unthreaded "unthreaded " "tree ")
+      "view search: "))))
   (let ((buffer (get-buffer-create (generate-new-buffer-name
     (or buffer-name
- (concat "*notmuch-tree-" query "*")))))
+ (concat "*notmuch-"
+ (if unthreaded "unthreaded-" "tree-")
+ query "*")))))
  (inhibit-read-only t))
 
     (switch-to-buffer buffer))
   ;; Don't track undo information for this buffer
   (set 'buffer-undo-list t)
 
-  (notmuch-tree-worker query query-context target open-target)
+  (notmuch-tree-worker query query-context target open-target unthreaded)
 
   (setq truncate-lines t))
 
+(defun notmuch-unthreaded (&optional query query-context target buffer-name open-target)
+  (interactive)
+  (notmuch-tree query query-context target buffer-name open-target t))
 
 ;;
 
--
2.11.0

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Mark Walters Mark Walters
Reply | Threaded
Open this post in threaded view
|

[PATCH 3/6] Unthreaded mode: allow different result format

In reply to this post by Mark Walters
It is likely that the user will want a different line format for
unthreaded mode from tree mode; in particular the thread structure
graphics are unnecessary in unthreaded mode.

Add a new customisable variable and set it to something sensible.
---
 emacs/notmuch-tree.el | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 80b830dd..760eaaec 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -76,6 +76,31 @@ Note the author string should not contain
   :type '(alist :key-type (string) :value-type (string))
   :group 'notmuch-tree)
 
+(defcustom notmuch-unthreaded-result-format
+  `(("date" . "%12s  ")
+    ("authors" . "%-20s")
+    ((("subject" . "%s")) ." %-54s ")
+    ("tags" . "(%s)"))
+  "Result formatting for unthreaded Tree view. Supported fields are: date,
+        authors, subject, tree, tags.  Tree means the thread tree
+        box graphics. The field may also be a list in which case
+        the formatting rules are applied recursively and then the
+        output of all the fields in the list is inserted
+        according to format-string.
+
+Note the author string should not contain
+        whitespace (put it in the neighbouring fields instead).
+        For example:
+        (setq notmuch-tree-result-format \(\(\"authors\" . \"%-40s\"\)
+                                             \(\"subject\" . \"%s\"\)\)\)"
+  :type '(alist :key-type (string) :value-type (string))
+  :group 'notmuch-tree)
+
+(defun notmuch-tree-result-format ()
+  (if notmuch-tree-unthreaded
+      notmuch-unthreaded-result-format
+    notmuch-tree-result-format))
+
 ;; Faces for messages that match the query.
 (defface notmuch-tree-match-face
   '((t :inherit default))
@@ -759,7 +784,7 @@ unchanged ADDRESS if parsing fails."
   ;; We need to save the previous subject as it will get overwritten
   ;; by the insert-field calls.
   (let ((previous-subject notmuch-tree-previous-subject))
-    (insert (notmuch-tree-format-field-list notmuch-tree-result-format msg))
+    (insert (notmuch-tree-format-field-list (notmuch-tree-result-format) msg))
     (notmuch-tree-set-message-properties msg)
     (notmuch-tree-set-prop :previous-subject previous-subject)
     (insert "\n")))
--
2.11.0

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Mark Walters Mark Walters
Reply | Threaded
Open this post in threaded view
|

[PATCH 4/6] Unthreaded mode: allow user to choose different `show out' than tree

In reply to this post by Mark Walters
Tree mode allows the user to choose whether to use the split screen
displaying just the current message or a full screen displaying the
entire thread. As unthreaded mode is quite different in use the user
may want a different customisation for this mode.
---
 emacs/notmuch-tree.el | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 760eaaec..895c05f4 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -56,6 +56,16 @@
   :type 'boolean
   :group 'notmuch-tree)
 
+(defcustom notmuch-unthreaded-show-out t
+  "View selected messages in new window rather than split-pane."
+  :type 'boolean
+  :group 'notmuch-tree)
+
+(defun notmuch-tree-show-out ()
+  (if notmuch-tree-unthreaded
+      notmuch-unthreaded-show-out
+    notmuch-tree-show-out))
+
 (defcustom notmuch-tree-result-format
   `(("date" . "%12s  ")
     ("authors" . "%-20s")
@@ -531,8 +541,8 @@ NOT change the database."
 Shows in split pane or whole window according to value of
 `notmuch-tree-show-out'. A prefix argument reverses the choice."
   (interactive "P")
-  (if (or (and notmuch-tree-show-out  (not arg))
-  (and (not notmuch-tree-show-out) arg))
+  (if (or (and (notmuch-tree-show-out) (not arg))
+  (and (not (notmuch-tree-show-out)) arg))
       (notmuch-tree-show-message-out)
     (notmuch-tree-show-message-in)))
 
--
2.11.0

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Mark Walters Mark Walters
Reply | Threaded
Open this post in threaded view
|

[PATCH 5/6] Add a U binding to switch to unthreaded from other views

In reply to this post by Mark Walters
We have shortcuts S and Z to let the user switch to Search view and
Tree view with the current search. Add U to let the user switch to
unthreaded view from the current search, and ensure that S and Z
switch from unthreaded to search and tree veiew respectively.
---
 emacs/notmuch-show.el | 10 ++++++++++
 emacs/notmuch-tree.el | 23 +++++++++++++++++++++--
 emacs/notmuch.el      |  6 ++++++
 3 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index d4a1389b..214e279f 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -50,6 +50,8 @@
 (declare-function notmuch-tree "notmuch-tree"
   (&optional query query-context target buffer-name open-target unthreaded))
 (declare-function notmuch-tree-get-message-properties "notmuch-tree" nil)
+(declare-function notmuch-unthreaded
+  (&optional query query-context target buffer-name open-target))
 (declare-function notmuch-read-query "notmuch" (prompt))
 (declare-function notmuch-draft-resume "notmuch-draft" (id))
 
@@ -1471,6 +1473,7 @@ reset based on the original query."
   (let ((map (make-sparse-keymap)))
     (set-keymap-parent map notmuch-common-keymap)
     (define-key map "Z" 'notmuch-tree-from-show-current-query)
+    (define-key map "U" 'notmuch-unthreaded-from-show-current-query)
     (define-key map (kbd "<C-tab>") 'widget-backward)
     (define-key map (kbd "M-TAB") 'notmuch-show-previous-button)
     (define-key map (kbd "<backtab>") 'notmuch-show-previous-button)
@@ -1559,6 +1562,13 @@ All currently available key bindings:
  notmuch-show-query-context
  (notmuch-show-get-message-id)))
 
+(defun notmuch-unthreaded-from-show-current-query ()
+  "Call notmuch unthreaded with the current query"
+  (interactive)
+  (notmuch-unthreaded notmuch-show-thread-id
+      notmuch-show-query-context
+      (notmuch-show-get-message-id)))
+
 (defun notmuch-show-move-to-message-top ()
   (goto-char (notmuch-show-message-top)))
 
diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index 895c05f4..9a83292c 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -294,6 +294,8 @@ FUNC."
     (define-key map [remap notmuch-jump-search] (notmuch-tree-close-message-pane-and #'notmuch-jump-search))
 
     (define-key map "S" 'notmuch-search-from-tree-current-query)
+    (define-key map "U" 'notmuch-unthreaded-from-tree-current-query)
+    (define-key map "Z" 'notmuch-tree-from-unthreaded-current-query)
 
     ;; these use notmuch-show functions directly
     (define-key map "|" 'notmuch-show-pipe-message)
@@ -474,6 +476,18 @@ NOT change the database."
     (notmuch-tree-close-message-window)
     (notmuch-tree query)))
 
+(defun notmuch-unthreaded-from-tree-current-query ()
+  "Switch from tree view to unthreaded view"
+  (interactive)
+  (unless notmuch-tree-unthreaded
+    (notmuch-tree-refresh-view 'unthreaded)))
+
+(defun notmuch-tree-from-unthreaded-current-query ()
+  "Switch from unthreaded view to tree view"
+  (interactive)
+  (when notmuch-tree-unthreaded
+    (notmuch-tree-refresh-view 'tree)))
+
 (defun notmuch-search-from-tree-current-query ()
   "Call notmuch search with the current query"
   (interactive)
@@ -635,19 +649,24 @@ message will be \"unarchived\", i.e. the tag changes in
   (when (window-live-p notmuch-tree-message-window)
     (notmuch-tree-show-message-in)))
 
-(defun notmuch-tree-refresh-view ()
+(defun notmuch-tree-refresh-view (&optional view)
   "Refresh view."
   (interactive)
   (when (get-buffer-process (current-buffer))
     (error "notmuch tree process already running for current buffer"))
   (let ((inhibit-read-only t)
  (basic-query notmuch-tree-basic-query)
+ (unthreaded (cond ((eq view 'unthreaded) t)
+  ((eq view 'tree) nil)
+  (t notmuch-tree-unthreaded)))
  (query-context notmuch-tree-query-context)
  (target (notmuch-tree-get-message-id)))
     (erase-buffer)
     (notmuch-tree-worker basic-query
  query-context
- target)))
+ target
+ nil
+ unthreaded)))
 
 (defun notmuch-tree-thread-top ()
   (when (notmuch-tree-get-message-properties)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 0d68d123..f4789b4f 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -190,6 +190,7 @@ there will be called at other points of notmuch execution."
     (define-key map (kbd "RET") 'notmuch-search-show-thread)
     (define-key map (kbd "M-RET") 'notmuch-tree-from-search-thread)
     (define-key map "Z" 'notmuch-tree-from-search-current-query)
+    (define-key map "U" 'notmuch-unthreaded-from-search-current-query)
     map)
   "Keymap for \"notmuch search\" buffers.")
 (fset 'notmuch-search-mode-map notmuch-search-mode-map)
@@ -523,6 +524,11 @@ thread."
   (interactive)
   (notmuch-tree notmuch-search-query-string))
 
+(defun notmuch-unthreaded-from-search-current-query ()
+  "Call notmuch tree with the current query"
+  (interactive)
+  (notmuch-unthreaded notmuch-search-query-string))
+
 (defun notmuch-tree-from-search-thread ()
   "Show the selected thread with notmuch-tree"
   (interactive)
--
2.11.0

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Mark Walters Mark Walters
Reply | Threaded
Open this post in threaded view
|

[PATCH 6/6] notmuch-hello/jump: allow saved searches to specify unthreaded mode

In reply to this post by Mark Walters
Saved searches in notmuch-hello and notmuch-jump can specify whether
to use search mode or tree mode. This adds an option for them to
specify unthreaded mode.
---
 emacs/notmuch-hello.el | 29 +++++++++++++++++++----------
 emacs/notmuch-jump.el  | 10 +++++++---
 2 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 858446df..ab6ee798 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -32,6 +32,9 @@
 (declare-function notmuch-poll "notmuch" ())
 (declare-function notmuch-tree "notmuch-tree"
   (&optional query query-context target buffer-name open-target unthreaded))
+(declare-function notmuch-unthreaded
+  (&optional query query-context target buffer-name open-target))
+
 
 (defun notmuch-saved-search-get (saved-search field)
   "Get FIELD from SAVED-SEARCH.
@@ -99,7 +102,8 @@ searches so they still work in customize."
      (group :format "%v" :inline t (const :format "" :search-type)
     (choice :tag " Search Type"
     (const :tag "Search mode" nil)
-    (const :tag "Tree mode" tree))))))
+    (const :tag "Tree mode" tree)
+    (const :tag "Unthreaded mode" unthreaded))))))
 
 (defcustom notmuch-saved-searches
   `((:name "inbox" :query "tag:inbox" :key ,(kbd "i"))
@@ -122,10 +126,10 @@ a plist. Supported properties are
   :sort-order      Specify the sort order to be used for the search.
                    Possible values are 'oldest-first 'newest-first or
                    nil. Nil means use the default sort order.
-  :search-type     Specify whether to run the search in search-mode
-                   or tree mode. Set to 'tree to specify tree
-                   mode, set to nil (or anything except tree) to
-                   specify search mode.
+  :search-type     Specify whether to run the search in search-mode,
+                   tree mode or unthreaded mode. Set to 'tree to specify tree
+                   mode, 'unthreaded to specify unthreaded mode, and set to nil
+                   (or anything except tree and unthreaded) to specify search mode.
 
 Other accepted forms are a cons cell of the form (NAME . QUERY)
 or a list of the form (NAME QUERY COUNT-QUERY)."
@@ -437,13 +441,18 @@ diagonal."
   append (notmuch-hello-reflect-generate-row ncols nrows row list))))
 
 (defun notmuch-hello-widget-search (widget &rest ignore)
-  (if (widget-get widget :notmuch-search-type)
-      (notmuch-tree (widget-get widget
- :notmuch-search-terms))
+  (cond
+   ((eq (widget-get widget :notmuch-search-type) 'tree)
+    (notmuch-tree (widget-get widget
+      :notmuch-search-terms)))
+   ((eq (widget-get widget :notmuch-search-type) 'unthreaded)
+    (notmuch-unthreaded (widget-get widget
+    :notmuch-search-terms)))
+   (t
     (notmuch-search (widget-get widget
  :notmuch-search-terms)
     (widget-get widget
- :notmuch-search-oldest-first))))
+ :notmuch-search-oldest-first)))))
 
 (defun notmuch-saved-search-count (search)
   (car (process-lines notmuch-command "count" search)))
@@ -579,7 +588,7 @@ with `notmuch-hello-query-counts'."
      (newest-first nil)
      (oldest-first t)
      (otherwise notmuch-search-oldest-first)))
-     (search-type (eq (plist-get elem :search-type) 'tree))
+     (search-type (plist-get elem :search-type))
      (msg-count (plist-get elem :count)))
  (widget-insert (format "%8s "
        (notmuch-hello-nice-number msg-count)))
diff --git a/emacs/notmuch-jump.el b/emacs/notmuch-jump.el
index 3e20b8c7..1cdf5b50 100644
--- a/emacs/notmuch-jump.el
+++ b/emacs/notmuch-jump.el
@@ -56,9 +56,13 @@ fast way to jump to a saved search from anywhere in Notmuch."
    (oldest-first t)
    (otherwise (default-value 'notmuch-search-oldest-first)))))
     (push (list key name
- (if (eq (plist-get saved-search :search-type) 'tree)
-    `(lambda () (notmuch-tree ',query))
-  `(lambda () (notmuch-search ',query ',oldest-first))))
+ (cond
+ ((eq (plist-get saved-search :search-type) 'tree)
+  `(lambda () (notmuch-tree ',query)))
+ ((eq (plist-get saved-search :search-type) 'unthreaded)
+  `(lambda () (notmuch-unthreaded ',query)))
+ (t
+  `(lambda () (notmuch-search ',query ',oldest-first)))))
   action-map)))))
     (setq action-map (nreverse action-map))
 
--
2.11.0

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Tomi Ollila-2 Tomi Ollila-2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 1/6] notmuch-show.c: add an option for messages to be returned unthreaded

In reply to this post by Mark Walters
On Thu, Feb 27 2020, Mark Walters wrote:

> This adds a --unthreaded option to notmuch show to tell it to return
> the matching messages in an unthreaded order (so just by date).
>
> To make it easier for users, in particular for notmuch-tree.el, we
> output each message with the same "nesting" as if it were an entire
> thread in its own right.

Some spacing in this commit, but LGTM =D

Tomi

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Tomi Ollila-2 Tomi Ollila-2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 2/6] Introduce unthreaded mode

In reply to this post by Mark Walters
On Thu, Feb 27 2020, Mark Walters wrote:

> This commit introduces a new 'unthreaded' search mode where each
> matching message is shown on a separate line. It shares almost all of
> its code with tree view. Subsequent commits will allow it to diverge
> slightly in appearance.

Could have just written, "Introdude a new 'unthreaded' ..." but LGTM =D

(at least there is no 'seperate' here >;)

Tomi

> ---
>  emacs/notmuch-hello.el |  2 +-
>  emacs/notmuch-lib.el   |  1 +
>  emacs/notmuch-show.el  |  2 +-
>  emacs/notmuch-tree.el  | 28 +++++++++++++++++++++-------
>  4 files changed, 24 insertions(+), 9 deletions(-)
>
> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
> index aff8beb5..858446df 100644
> --- a/emacs/notmuch-hello.el
> +++ b/emacs/notmuch-hello.el
> @@ -31,7 +31,7 @@
>  (declare-function notmuch-search "notmuch" (&optional query oldest-first target-thread target-line continuation))
>  (declare-function notmuch-poll "notmuch" ())
>  (declare-function notmuch-tree "notmuch-tree"
> -                  (&optional query query-context target buffer-name open-target))
> +  (&optional query query-context target buffer-name open-target unthreaded))
>  
>  (defun notmuch-saved-search-get (saved-search field)
>    "Get FIELD from SAVED-SEARCH.
> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
> index 8acad267..73b165e4 100644
> --- a/emacs/notmuch-lib.el
> +++ b/emacs/notmuch-lib.el
> @@ -154,6 +154,7 @@ For example, if you wanted to remove an \"inbox\" tag and add an
>      (define-key map "q" 'notmuch-bury-or-kill-this-buffer)
>      (define-key map "s" 'notmuch-search)
>      (define-key map "z" 'notmuch-tree)
> +    (define-key map "u" 'notmuch-unthreaded)
>      (define-key map "m" 'notmuch-mua-new-mail)
>      (define-key map "g" 'notmuch-refresh-this-buffer)
>      (define-key map "=" 'notmuch-refresh-this-buffer)
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index ef2bf1e0..d4a1389b 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -48,7 +48,7 @@
>  (declare-function notmuch-count-attachments "notmuch" (mm-handle))
>  (declare-function notmuch-save-attachments "notmuch" (mm-handle &optional queryp))
>  (declare-function notmuch-tree "notmuch-tree"
> -  (&optional query query-context target buffer-name open-target))
> +  (&optional query query-context target buffer-name open-target unthreaded))
>  (declare-function notmuch-tree-get-message-properties "notmuch-tree" nil)
>  (declare-function notmuch-read-query "notmuch" (prompt))
>  (declare-function notmuch-draft-resume "notmuch-draft" (id))
> diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
> index c00315e8..80b830dd 100644
> --- a/emacs/notmuch-tree.el
> +++ b/emacs/notmuch-tree.el
> @@ -42,6 +42,11 @@
>  ;; the following variable is defined in notmuch.el
>  (defvar notmuch-search-query-string)
>  
> +;; this variable distinguishes the unthreaded display from the normal tree display
> +(defvar notmuch-tree-unthreaded nil
> +  "A buffer local copy of argument unthreaded to the function notmuch-tree")
> +(make-variable-buffer-local 'notmuch-tree-unthreaded)
> +
>  (defgroup notmuch-tree nil
>    "Showing message and thread structure."
>    :group 'notmuch)
> @@ -890,7 +895,7 @@ Complete list of currently available key bindings:
>   (notmuch-sexp-parse-partial-list 'notmuch-tree-insert-forest-thread
>   results-buf)))))
>  
> -(defun notmuch-tree-worker (basic-query &optional query-context target open-target)
> +(defun notmuch-tree-worker (basic-query &optional query-context target open-target unthreaded)
>    "Insert the tree view of the search in the current buffer.
>  
>  This is is a helper function for notmuch-tree. The arguments are
> @@ -898,6 +903,7 @@ the same as for the function notmuch-tree."
>    (interactive)
>    (notmuch-tree-mode)
>    (add-hook 'post-command-hook #'notmuch-tree-command-hook t t)
> +  (setq notmuch-tree-unthreaded unthreaded)
>    (setq notmuch-tree-basic-query basic-query)
>    (setq notmuch-tree-query-context (if (or (string= query-context "")
>     (string= query-context "*"))
> @@ -915,7 +921,7 @@ the same as for the function notmuch-tree."
>    (let* ((search-args (concat basic-query
>         (if query-context (concat " and (" query-context ")"))
>         ))
> - (message-arg "--entire-thread"))
> + (message-arg (if unthreaded "--unthreaded" "--entire-thread")))
>      (if (equal (car (process-lines notmuch-command "count" search-args)) "0")
>   (setq search-args basic-query))
>      (notmuch-tag-clear-cache)
> @@ -940,7 +946,7 @@ the same as for the function notmuch-tree."
>        ")")
>      notmuch-tree-basic-query))
>  
> -(defun notmuch-tree (&optional query query-context target buffer-name open-target)
> +(defun notmuch-tree (&optional query query-context target buffer-name open-target unthreaded)
>    "Display threads matching QUERY in Tree View.
>  
>  The arguments are:
> @@ -953,23 +959,31 @@ The arguments are:
>        current if it appears in the tree view results.
>    BUFFER-NAME: the name of the buffer to display the tree view. If
>        it is nil \"*notmuch-tree\" followed by QUERY is used.
> -  OPEN-TARGET: If TRUE open the target message in the message pane."
> +  OPEN-TARGET: If TRUE open the target message in the message pane.
> +  UNTHREADED: If TRUE only show matching messages in an unthreaded view."
>    (interactive)
>    (if (null query)
> -      (setq query (notmuch-read-query "Notmuch tree view search: ")))
> +      (setq query (notmuch-read-query (concat "Notmuch "
> +      (if unthreaded "unthreaded " "tree ")
> +      "view search: "))))
>    (let ((buffer (get-buffer-create (generate-new-buffer-name
>      (or buffer-name
> - (concat "*notmuch-tree-" query "*")))))
> + (concat "*notmuch-"
> + (if unthreaded "unthreaded-" "tree-")
> + query "*")))))
>   (inhibit-read-only t))
>  
>      (switch-to-buffer buffer))
>    ;; Don't track undo information for this buffer
>    (set 'buffer-undo-list t)
>  
> -  (notmuch-tree-worker query query-context target open-target)
> +  (notmuch-tree-worker query query-context target open-target unthreaded)
>  
>    (setq truncate-lines t))
>  
> +(defun notmuch-unthreaded (&optional query query-context target buffer-name open-target)
> +  (interactive)
> +  (notmuch-tree query query-context target buffer-name open-target t))
>  
>  ;;
>  
> --
> 2.11.0
>
> _______________________________________________
> notmuch mailing list
> [hidden email]
> https://notmuchmail.org/mailman/listinfo/notmuch
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Tomi Ollila-2 Tomi Ollila-2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 3/6] Unthreaded mode: allow different result format

In reply to this post by Mark Walters
On Thu, Feb 27 2020, Mark Walters wrote:

> It is likely that the user will want a different line format for
> unthreaded mode from tree mode; in particular the thread structure
> graphics are unnecessary in unthreaded mode.
>
> Add a new customisable variable and set it to something sensible.

Looks good to me (I trust Mark the result format is good)

Tomi

> ---
>  emacs/notmuch-tree.el | 27 ++++++++++++++++++++++++++-
>  1 file changed, 26 insertions(+), 1 deletion(-)
>
> diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
> index 80b830dd..760eaaec 100644
> --- a/emacs/notmuch-tree.el
> +++ b/emacs/notmuch-tree.el
> @@ -76,6 +76,31 @@ Note the author string should not contain
>    :type '(alist :key-type (string) :value-type (string))
>    :group 'notmuch-tree)
>  
> +(defcustom notmuch-unthreaded-result-format
> +  `(("date" . "%12s  ")
> +    ("authors" . "%-20s")
> +    ((("subject" . "%s")) ." %-54s ")
> +    ("tags" . "(%s)"))
> +  "Result formatting for unthreaded Tree view. Supported fields are: date,
> +        authors, subject, tree, tags.  Tree means the thread tree
> +        box graphics. The field may also be a list in which case
> +        the formatting rules are applied recursively and then the
> +        output of all the fields in the list is inserted
> +        according to format-string.
> +
> +Note the author string should not contain
> +        whitespace (put it in the neighbouring fields instead).
> +        For example:
> +        (setq notmuch-tree-result-format \(\(\"authors\" . \"%-40s\"\)
> +                                             \(\"subject\" . \"%s\"\)\)\)"
> +  :type '(alist :key-type (string) :value-type (string))
> +  :group 'notmuch-tree)
> +
> +(defun notmuch-tree-result-format ()
> +  (if notmuch-tree-unthreaded
> +      notmuch-unthreaded-result-format
> +    notmuch-tree-result-format))
> +
>  ;; Faces for messages that match the query.
>  (defface notmuch-tree-match-face
>    '((t :inherit default))
> @@ -759,7 +784,7 @@ unchanged ADDRESS if parsing fails."
>    ;; We need to save the previous subject as it will get overwritten
>    ;; by the insert-field calls.
>    (let ((previous-subject notmuch-tree-previous-subject))
> -    (insert (notmuch-tree-format-field-list notmuch-tree-result-format msg))
> +    (insert (notmuch-tree-format-field-list (notmuch-tree-result-format) msg))
>      (notmuch-tree-set-message-properties msg)
>      (notmuch-tree-set-prop :previous-subject previous-subject)
>      (insert "\n")))
> --
> 2.11.0
>
> _______________________________________________
> notmuch mailing list
> [hidden email]
> https://notmuchmail.org/mailman/listinfo/notmuch
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Tomi Ollila-2 Tomi Ollila-2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 4/6] Unthreaded mode: allow user to choose different `show out' than tree

In reply to this post by Mark Walters
On Thu, Feb 27 2020, Mark Walters wrote:

> Tree mode allows the user to choose whether to use the split screen
> displaying just the current message or a full screen displaying the
> entire thread. As unthreaded mode is quite different in use the user
> may want a different customisation for this mode.

LGTM.

Tomi


> ---
>  emacs/notmuch-tree.el | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
> index 760eaaec..895c05f4 100644
> --- a/emacs/notmuch-tree.el
> +++ b/emacs/notmuch-tree.el
> @@ -56,6 +56,16 @@
>    :type 'boolean
>    :group 'notmuch-tree)
>  
> +(defcustom notmuch-unthreaded-show-out t
> +  "View selected messages in new window rather than split-pane."
> +  :type 'boolean
> +  :group 'notmuch-tree)
> +
> +(defun notmuch-tree-show-out ()
> +  (if notmuch-tree-unthreaded
> +      notmuch-unthreaded-show-out
> +    notmuch-tree-show-out))
> +
>  (defcustom notmuch-tree-result-format
>    `(("date" . "%12s  ")
>      ("authors" . "%-20s")
> @@ -531,8 +541,8 @@ NOT change the database."
>  Shows in split pane or whole window according to value of
>  `notmuch-tree-show-out'. A prefix argument reverses the choice."
>    (interactive "P")
> -  (if (or (and notmuch-tree-show-out  (not arg))
> -  (and (not notmuch-tree-show-out) arg))
> +  (if (or (and (notmuch-tree-show-out) (not arg))
> +  (and (not (notmuch-tree-show-out)) arg))
>        (notmuch-tree-show-message-out)
>      (notmuch-tree-show-message-in)))
>  
> --
> 2.11.0
>
> _______________________________________________
> notmuch mailing list
> [hidden email]
> https://notmuchmail.org/mailman/listinfo/notmuch
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Tomi Ollila-2 Tomi Ollila-2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 5/6] Add a U binding to switch to unthreaded from other views

In reply to this post by Mark Walters
On Thu, Feb 27 2020, Mark Walters wrote:

> We have shortcuts S and Z to let the user switch to Search view and
> Tree view with the current search. Add U to let the user switch to
> unthreaded view from the current search, and ensure that S and Z
> switch from unthreaded to search and tree veiew respectively.

LGTM.

Tomi

> ---
>  emacs/notmuch-show.el | 10 ++++++++++
>  emacs/notmuch-tree.el | 23 +++++++++++++++++++++--
>  emacs/notmuch.el      |  6 ++++++
>  3 files changed, 37 insertions(+), 2 deletions(-)
>
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
Tomi Ollila-2 Tomi Ollila-2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 6/6] notmuch-hello/jump: allow saved searches to specify unthreaded mode

In reply to this post by Mark Walters
On Thu, Feb 27 2020, Mark Walters wrote:

> Saved searches in notmuch-hello and notmuch-jump can specify whether
> to use search mode or tree mode. This adds an option for them to
> specify unthreaded mode.

LGTM.

Tomi

> ---
>  emacs/notmuch-hello.el | 29 +++++++++++++++++++----------
>  emacs/notmuch-jump.el  | 10 +++++++---
>  2 files changed, 26 insertions(+), 13 deletions(-)
>
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 0/6] Add an unthreaded mode

In reply to this post by Mark Walters
Mark Walters <[hidden email]> writes:

> This series adds an unthreaded mode. In this mode all messages
> matching the query are shown, one per line, in unthreaded (reverse)
> date order. For some discussion of such a mode see
> id:[hidden email] and subsequent thread.

Hah, didn't even recognize my own feature request until I checked.

Pushed.

d
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch