X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=emacs%2Fnotmuch-tree.el;h=760eaaec6bdc24ffd0788a34660246c74231e48c;hp=220395e712bdf0bcdce56d38f78e91ece88f0970;hb=a82fb6e67042d402166104e803376f6f68613ba9;hpb=cb5253578d983471e5b55604581d390fcdda38f4 diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el index 220395e7..760eaaec 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) @@ -71,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)) @@ -598,6 +628,8 @@ message will be \"unarchived\", i.e. the tag changes in (defun notmuch-tree-refresh-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) (query-context notmuch-tree-query-context) @@ -752,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"))) @@ -888,7 +920,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 @@ -896,6 +928,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 "*")) @@ -913,7 +946,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) @@ -938,7 +971,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: @@ -951,23 +984,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)) ;;