From: David Edmondson Date: Mon, 6 Feb 2012 15:39:05 +0000 (+0000) Subject: [PATCH v2] emacs: Add more processing of displayed headers. X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=6a44a7196c44a79857586588fd457dc2f89850b9;p=notmuch-archives.git [PATCH v2] emacs: Add more processing of displayed headers. --- diff --git a/b1/acb102531f933b4346214f1927eb12ba2c0165 b/b1/acb102531f933b4346214f1927eb12ba2c0165 new file mode 100644 index 000000000..9ac260c0d --- /dev/null +++ b/b1/acb102531f933b4346214f1927eb12ba2c0165 @@ -0,0 +1,159 @@ +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 9573C431FC2 + for ; Mon, 6 Feb 2012 07:39:18 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[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 NwsnQOGx2q3b for ; + Mon, 6 Feb 2012 07:39:17 -0800 (PST) +Received: from mail-we0-f181.google.com (mail-we0-f181.google.com + [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 964FD431FBC + for ; Mon, 6 Feb 2012 07:39:16 -0800 (PST) +Received: by werb10 with SMTP id b10so5266654wer.26 + for ; Mon, 06 Feb 2012 07:39:14 -0800 (PST) +Received: by 10.216.138.8 with SMTP id z8mr7076894wei.20.1328542754496; + Mon, 06 Feb 2012 07:39:14 -0800 (PST) +Received: from hotblack-desiato.hh.sledj.net + (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25]) + by mx.google.com with ESMTPS id j16sm47483467wie.4.2012.02.06.07.39.10 + (version=TLSv1/SSLv3 cipher=OTHER); + Mon, 06 Feb 2012 07:39:11 -0800 (PST) +Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000) + id 4D825A05C6; Mon, 6 Feb 2012 15:39:09 +0000 (GMT) +From: David Edmondson +To: notmuch@notmuchmail.org +Subject: [PATCH v2] emacs: Add more processing of displayed headers. +Date: Mon, 6 Feb 2012 15:39:05 +0000 +Message-Id: <1328542748-19530-2-git-send-email-dme@dme.org> +X-Mailer: git-send-email 1.7.8.3 +In-Reply-To: <1328542748-19530-1-git-send-email-dme@dme.org> +References: <1327052612-1040-1-git-send-email-dme@dme.org> + <1328542748-19530-1-git-send-email-dme@dme.org> +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: Mon, 06 Feb 2012 15:39:19 -0000 + +Wrap headers to the width of the window and indent continuations. +--- + emacs/notmuch-show.el | 43 ++++++++++++++++++++++++++++++++++++------- + 1 files changed, 36 insertions(+), 7 deletions(-) + +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index 7469e2e..a589d37 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -68,9 +68,16 @@ any given message." + :type 'boolean + :group 'notmuch-show) + +-(defvar notmuch-show-markup-headers-hook '(notmuch-show-colour-headers) ++(defcustom notmuch-show-markup-headers-hook '(notmuch-show-colour-headers ++ notmuch-show-fill-headers ++ notmuch-show-indent-continuations) + "A list of functions called to decorate the headers listed in +-`notmuch-message-headers'.") ++`notmuch-message-headers'." ++ :type 'hook ++ :options '(notmuch-show-colour-headers ++ notmuch-show-fill-headers ++ notmuch-show-indent-continuations) ++ :group 'notmuch-show) + + (defcustom notmuch-show-hook '(notmuch-show-turn-on-visual-line-mode) + "Functions called after populating a `notmuch-show' buffer." +@@ -269,13 +276,35 @@ operation on the contents of the current buffer." + (overlay-put (make-overlay (point) (re-search-forward ".*$")) + 'face face))) + +-(defun notmuch-show-colour-headers () ++(defun notmuch-show-colour-headers (depth) + "Apply some colouring to the current headers." + (goto-char (point-min)) + (while (looking-at "^[A-Za-z][-A-Za-z0-9]*:") + (notmuch-show-fontify-header) + (forward-line))) + ++(defun notmuch-show-fill-headers (depth) ++ "Wrap the text of the current headers." ++ ++ ;; '-5' to allow for the indentation code. ++ (let ((fill-column (- (window-width) depth 5))) ++ (goto-char (point-min)) ++ (while (not (eobp)) ++ (let ((start (point))) ++ (end-of-line) ++ ;; We're left at the start of the next line, so there's no need ++ ;; to move forward after filling. ++ (fill-region-as-paragraph start (point)))))) ++ ++(defun notmuch-show-indent-continuations (depth) ++ "Indent any continuation lines." ++ (goto-char (point-min)) ++ (while (not (eobp)) ++ (if (not (looking-at "^[A-Za-z][-A-Za-z0-9]*:")) ++ ;; Four spaces tends to work well with 'To' and 'Cc' headers. ++ (insert " ")) ++ (forward-line))) ++ + (defun notmuch-show-spaces-n (n) + "Return a string comprised of `n' spaces." + (make-string n ? )) +@@ -366,7 +395,7 @@ message at DEPTH in the current thread." + "Insert a single header." + (insert header ": " header-value "\n")) + +-(defun notmuch-show-insert-headers (headers) ++(defun notmuch-show-insert-headers (headers depth) + "Insert the headers of the current message." + (let ((start (point))) + (mapc (lambda (header) +@@ -379,7 +408,7 @@ message at DEPTH in the current thread." + (save-excursion + (save-restriction + (narrow-to-region start (point-max)) +- (run-hooks 'notmuch-show-markup-headers-hook))))) ++ (run-hook-with-args 'notmuch-show-markup-headers-hook depth))))) + + (define-button-type 'notmuch-show-part-button-type + 'action 'notmuch-show-part-button-default +@@ -671,7 +700,7 @@ current buffer, if possible." + ;; Override `notmuch-message-headers' to force `From' to be + ;; displayed. + (let ((notmuch-message-headers '("From" "Subject" "To" "Cc" "Date"))) +- (notmuch-show-insert-headers (plist-get message :headers))) ++ (notmuch-show-insert-headers (plist-get message :headers) 0)) + + ;; Blank line after headers to be compatible with the normal + ;; message display. +@@ -864,7 +893,7 @@ current buffer, if possible." + ;; Set `headers-start' to point after the 'Subject:' header to be + ;; compatible with the existing implementation. This just sets it + ;; to after the first header. +- (notmuch-show-insert-headers headers) ++ (notmuch-show-insert-headers headers depth) + (save-excursion + (goto-char content-start) + ;; If the subject of this message is the same as that of the +-- +1.7.8.3 +