Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 8EE83431FAF for ; Wed, 5 Jun 2013 00:48:49 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0.201 X-Spam-Level: X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0n2f46Jq49C7 for ; Wed, 5 Jun 2013 00:48:41 -0700 (PDT) Received: from mail-wi0-f171.google.com (mail-wi0-f171.google.com [209.85.212.171]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id AB6F6431FAE for ; Wed, 5 Jun 2013 00:48:41 -0700 (PDT) Received: by mail-wi0-f171.google.com with SMTP id hm9so1529668wib.4 for ; Wed, 05 Jun 2013 00:48:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=6Opny4hGdBbTAkssxN5thYSmIpZms6znsDWWw4rd258=; b=cvdTjL7ZISU2exEPrNKkfGuOnFHwCDnWJNeYLFF+QIWGk+6hQ9AXGNbFlwR656MQGr +pJLMJGVeOTUr42Smsf9ZVYfTy7yHl6acVg9qhu4Q/jck1YGNr0vO9FiPJuxmIwo8nv2 hLGyRIXX7Li6i+5Oxcmv1AmXWdWPI9yeoKLlAraLUQi/QmSGNHzAA58dLhOCv3ITfmj7 trnS5nhPE7eT+4kPJbs35S0XXU4H1I4hoFZ3jxOTRk7A/yssHSzPrMPC8ghRtMGQokPF oO11wYPqUdsYtShwN+MvQMgEvOBqX2Zm/St+IzNk7mtn+6Vg+Gp5y0o8PXHSDbozlw6M etOg== X-Received: by 10.180.210.225 with SMTP id mx1mr5286095wic.15.1370418519312; Wed, 05 Jun 2013 00:48:39 -0700 (PDT) Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) by mx.google.com with ESMTPSA id h8sm8463137wiz.9.2013.06.05.00.48.37 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 05 Jun 2013 00:48:38 -0700 (PDT) From: Mark Walters To: notmuch@notmuchmail.org, Jani Nikula Subject: [WIP PATCH] emacs: search: toggle multiline Date: Wed, 5 Jun 2013 08:48:35 +0100 Message-Id: <1370418515-9845-1-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 1.7.9.1 X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2013 07:48:50 -0000 --- 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