X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=emacs%2Fnotmuch-tree.el;h=a06afc2d1c0e1ef6d0d42f8e73d333b30895ded5;hb=692acdf9da2ca93d46259ca31780ed632c2975c4;hp=57843e256f437d5f6206ef31e5aab9915d10e49a;hpb=ced341e82e8cb84dc2c90187d208838335511f6e;p=notmuch diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el index 57843e25..a06afc2d 100644 --- a/emacs/notmuch-tree.el +++ b/emacs/notmuch-tree.el @@ -1,4 +1,4 @@ -;;; notmuch-tree.el --- displaying notmuch forests +;;; notmuch-tree.el --- displaying notmuch forests -*- lexical-binding: t -*- ;; ;; Copyright © Carl Worth ;; Copyright © David Edmondson @@ -54,6 +54,8 @@ (defvar-local notmuch-tree-unthreaded nil "A buffer local copy of argument unthreaded to the function notmuch-tree.") +;;; Options + (defgroup notmuch-tree nil "Showing message and thread structure." :group 'notmuch) @@ -118,7 +120,9 @@ For example: notmuch-unthreaded-result-format notmuch-tree-result-format)) -;; Faces for messages that match the query. +;;; Faces +;;;; Faces for messages that match the query + (defface notmuch-tree-match-face '((t :inherit default)) "Default face used in tree mode face for matching messages" @@ -169,7 +173,8 @@ For example: :group 'notmuch-tree :group 'notmuch-faces) -;; Faces for messages that do not match the query. +;;;; Faces for messages that do not match the query + (defface notmuch-tree-no-match-face '((t (:foreground "gray"))) "Default face used in tree mode face for non-matching messages." @@ -206,6 +211,8 @@ For example: :group 'notmuch-tree :group 'notmuch-faces) +;;; Variables + (defvar-local notmuch-tree-previous-subject "The subject of the most recent result shown during the async display.") @@ -238,6 +245,8 @@ This is used to try and make sure we don't close the message pane if the user has loaded a different buffer in that window.") (put 'notmuch-tree-message-buffer 'permanent-local t) +;;; Tree wrapper commands + (defmacro notmuch-tree--define-do-in-message-window (name cmd) "Define NAME as a command that calls CMD interactively in the message window. If the message pane is closed then this command does nothing. @@ -305,6 +314,8 @@ then NAME behaves like CMD." notmuch-tree-view-raw-message notmuch-show-view-raw-message) +;;; Keymap + (defvar notmuch-tree-mode-map (let ((map (make-sparse-keymap))) (set-keymap-parent map notmuch-common-keymap) @@ -363,6 +374,8 @@ then NAME behaves like CMD." map) "Keymap for \"notmuch tree\" buffers.") +;;; Message properties + (defun notmuch-tree-get-message-properties () "Return the properties of the current message as a plist. @@ -414,6 +427,8 @@ Some useful entries are: (interactive) (notmuch-tree-get-prop :match)) +;;; Update display + (defun notmuch-tree-refresh-result () "Redisplay the current message line. @@ -456,6 +471,8 @@ NOT change the database." (when (string= tree-msg-id (notmuch-show-get-message-id)) (notmuch-show-update-tags new-tags))))))) +;;; Commands (and some helper functions used by them) + (defun notmuch-tree-tag (tag-changes) "Change tags for the current message." (interactive @@ -581,8 +598,7 @@ NOT change the database." "Show the current message (in whole window)." (interactive) (let ((id (notmuch-tree-get-message-id)) - (inhibit-read-only t) - buffer) + (inhibit-read-only t)) (when id ;; We close the window to kill off un-needed buffers. (notmuch-tree-close-message-window) @@ -775,8 +791,7 @@ search results instead." (notmuch-tree-from-search-thread)))) (defun notmuch-tree-next-thread (&optional previous) - "Move to the next thread in the current tree or parent search -results + "Move to the next thread in the current tree or parent search results. If PREVIOUS is non-nil, move to the previous thread in the tree or search results instead." @@ -786,14 +801,13 @@ search results instead." (notmuch-tree-next-thread-from-search previous))) (defun notmuch-tree-prev-thread () - "Move to the previous thread in the current tree or parent search -results" + "Move to the previous thread in the current tree or parent search results." (interactive) (notmuch-tree-next-thread t)) (defun notmuch-tree-thread-mapcar (function) - "Iterate through all messages in the current thread - and call FUNCTION for side effects." + "Call FUNCTION for each message in the current thread. +FUNCTION is called for side effects only." (save-excursion (notmuch-tree-thread-top) (cl-loop collect (funcall function) @@ -835,7 +849,7 @@ buffer." (notmuch-tree-tag-thread (notmuch-tag-change-list notmuch-archive-tags unarchive)))) -;; Functions below here display the tree buffer itself. +;;; Functions for displaying the tree buffer itself (defun notmuch-tree-clean-address (address) "Try to clean a single email ADDRESS for display. Return @@ -1016,19 +1030,17 @@ Complete list of currently available key bindings: (setq buffer-read-only t) (setq truncate-lines t)) -(defun notmuch-tree-process-sentinel (proc msg) +(defun notmuch-tree-process-sentinel (proc _msg) "Add a message to let user know when \"notmuch tree\" exits." (let ((buffer (process-buffer proc)) (status (process-status proc)) - (exit-status (process-exit-status proc)) - (never-found-target-thread nil)) + (exit-status (process-exit-status proc))) (when (memq status '(exit signal)) (kill-buffer (process-get proc 'parse-buf)) (when (buffer-live-p buffer) (with-current-buffer buffer (save-excursion - (let ((inhibit-read-only t) - (atbob (bobp))) + (let ((inhibit-read-only t)) (goto-char (point-max)) (when (eq status 'signal) (insert "Incomplete search results (tree view process was killed).\n")) @@ -1042,8 +1054,7 @@ Complete list of currently available key bindings: "Process and filter the output of \"notmuch show\" for tree view." (let ((results-buf (process-buffer proc)) (parse-buf (process-get proc 'parse-buf)) - (inhibit-read-only t) - done) + (inhibit-read-only t)) (if (not (buffer-live-p results-buf)) (delete-process proc) (with-current-buffer parse-buf @@ -1133,7 +1144,7 @@ The arguments are: (inhibit-read-only t)) (pop-to-buffer-same-window buffer)) ;; Don't track undo information for this buffer - (set 'buffer-undo-list t) + (setq buffer-undo-list t) (notmuch-tree-worker query query-context target open-target unthreaded) (setq notmuch-tree-parent-buffer parent-buffer) (setq truncate-lines t)) @@ -1142,7 +1153,7 @@ The arguments are: (interactive) (notmuch-tree query query-context target buffer-name open-target t)) -;; +;;; _ (provide 'notmuch-tree)