[WIP PATCH] emacs: search: toggle multiline
Mark Walters
markwalters1009 at gmail.com
Wed Jun 5 00:48:35 PDT 2013
---
Jani and I were chatting on irc and he mentioned it was annoying not
to be able to see the whole subject in the eamcs search view (if the
window is not very wide). Since Austin's search changes sometime ago
allow multiline results and updating results in place we can use this
to give an expanded view. In this preliminary version "e" toggles
between the expanded view and normal view.
It's definitely work in progress but seems to work. There are some
oddities in multiline results which probably need fixin and,
personally, I would like the option of a full date as well as the
brief relative date.
Best wishes
Mark
emacs/notmuch.el | 30 +++++++++++++++++++++++++-----
1 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 6a4052e..3f5ae4a 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -80,6 +80,16 @@ To enter a line break in customize, press \\[quoted-insert] C-j."
:type '(alist :key-type (string) :value-type (string))
:group 'notmuch-search)
+(defcustom notmuch-search-expanded-result-format
+ `(("date" . "%12s ")
+ ("count" . "%-7s\n")
+ ("authors" . " Authors: %-70s")
+ ("subject" . "\n Subject: %s\n")
+ ("tags" . " Tags: (%s)\n"))
+ "format for expanded results"
+ :type '(alist :key-type (string) :value-type (string))
+ :group 'notmuch-search)
+
(defvar notmuch-query-history nil
"Variable to store minibuffer history for notmuch queries")
@@ -230,6 +240,7 @@ For a mouse binding, return nil."
(define-key map "c" 'notmuch-search-stash-map)
(define-key map "=" 'notmuch-search-refresh-view)
(define-key map "G" 'notmuch-search-poll-and-refresh-view)
+ (define-key map "e" 'notmuch-search-toggle-expand-result)
(define-key map "t" 'notmuch-search-filter-by-tag)
(define-key map "f" 'notmuch-search-filter)
(define-key map [mouse-1] 'notmuch-search-show-thread)
@@ -611,7 +622,7 @@ This function advances the next thread when finished."
(notmuch-tag-change-list notmuch-archive-tags unarchive)))
(notmuch-search-next-thread))
-(defun notmuch-search-update-result (result &optional pos)
+(defun notmuch-search-update-result (result &optional pos format)
"Replace the result object of the thread at POS (or point) by
RESULT and redraw it.
@@ -626,7 +637,7 @@ of the result."
;; Delete the current thread
(delete-region start end)
;; Insert the updated thread
- (notmuch-search-show-result result start)
+ (notmuch-search-show-result result start format)
;; If point was inside the old result, make an educated guess
;; about where to place it now. Unfortunately, this won't work
;; with save-excursion (or any other markers that would be nice to
@@ -639,6 +650,14 @@ of the result."
(min init-point (- new-end 1)))))
(goto-char new-point)))))
+(defun notmuch-search-toggle-expand-result (&optional pos)
+ (interactive)
+ (let* ((result (notmuch-search-get-result pos))
+ (expanded (not (plist-get result :expanded)))
+ (new-result (plist-put result :expanded expanded))
+ (format (and expanded notmuch-search-expanded-result-format)))
+ (notmuch-search-update-result new-result pos format)))
+
(defun notmuch-search-process-sentinel (proc msg)
"Add a message to let user know when \"notmuch search\" exits"
(let ((buffer (process-buffer proc))
@@ -801,14 +820,15 @@ non-authors is found, assume that all of the authors match."
(let ((tags (plist-get result :tags)))
(insert (format format-string (notmuch-tag-format-tags tags)))))))
-(defun notmuch-search-show-result (result &optional pos)
+(defun notmuch-search-show-result (result &optional pos format)
"Insert RESULT at POS or the end of the buffer if POS is null."
;; Ignore excluded matches
(unless (= (plist-get result :matched) 0)
- (let ((beg (or pos (point-max))))
+ (let ((beg (or pos (point-max)))
+ (format (or format notmuch-search-result-format)))
(save-excursion
(goto-char beg)
- (dolist (spec notmuch-search-result-format)
+ (dolist (spec format)
(notmuch-search-insert-field (car spec) (cdr spec) result))
(insert "\n")
(notmuch-search-color-line beg (point) (plist-get result :tags))
--
1.7.9.1
More information about the notmuch
mailing list