From 8a4ee827d99e644f5f52a8c49c804ec380f402bf Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Sun, 2 Dec 2012 21:29:04 +0000 Subject: [PATCH] [RFC PATCH] emacs: show: make show-get-message-prop usable from pick --- 97/4e168a31ae68fc1da60fe98a8bcea541823f70 | 114 ++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 97/4e168a31ae68fc1da60fe98a8bcea541823f70 diff --git a/97/4e168a31ae68fc1da60fe98a8bcea541823f70 b/97/4e168a31ae68fc1da60fe98a8bcea541823f70 new file mode 100644 index 000000000..4f233a82f --- /dev/null +++ b/97/4e168a31ae68fc1da60fe98a8bcea541823f70 @@ -0,0 +1,114 @@ +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 0014F431FB6 + for ; Sun, 2 Dec 2012 13:29:09 -0800 (PST) +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 GJ7fFLtFveeB for ; + Sun, 2 Dec 2012 13:29:09 -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 60BA6431FAE + for ; Sun, 2 Dec 2012 13:29:09 -0800 (PST) +Received: by mail-we0-f181.google.com with SMTP id t11so1042712wey.26 + for ; Sun, 02 Dec 2012 13:29:08 -0800 (PST) +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=30BgykevuL32lyltuVomXx+LXtjE+eMSXP5aHfvR0PA=; + b=dOg57CoBpSSP+D9SMRQKHkvHEv7hRwouipFv1r5mMIYcJMOTLpWz17ikhtCjAQe82/ + R54Lm9YUXx0oFj/gW1TzMQEDTGq+rFA8YF5TJle0ZP2JR8YidmuxsIHdAjTJi/VMMguJ + J4MVZ7loKeHWaQN1P9UY4Zd8LtVGXlZRB/4q3s6HPMosOY7GiOueZGbKPGVFqH4DarCE + NddpOL8B5Zut7kZ2xAwy7vbuN/a7TC09LOIkzIA/HRutY4wP3cyrnSUcbcED6KopwP0S + PSNbPF4bsrbzUldUfii1ZMorONJNUeHoRKLKD9WoN4gD8FQSKWVFJ/AmbP+UG2c51r1t + 9Ijw== +Received: by 10.216.24.212 with SMTP id x62mr2440921wex.204.1354483747864; + Sun, 02 Dec 2012 13:29:07 -0800 (PST) +Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) + by mx.google.com with ESMTPS id w5sm9677863wiz.10.2012.12.02.13.29.06 + (version=TLSv1/SSLv3 cipher=OTHER); + Sun, 02 Dec 2012 13:29:06 -0800 (PST) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [RFC PATCH] emacs: show: make show-get-message-prop usable from pick +Date: Sun, 2 Dec 2012 21:29:04 +0000 +Message-Id: <1354483744-27541-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: Sun, 02 Dec 2012 21:29:10 -0000 + +Make notmuch-show-get-prop choose the get-message-properties routine +based on the major mode. This make it usable from notmuch-pick and +thus a large number of functions are usable directly from +notmuch-show.el and do not need to be reimplemented in pick. +--- + +With this change (and a corresponding very small change in pick) I can +use a large number of functions straight from show in pick-mode. The +only change they need is that when they get a message property (most +commonly the message-id) they use the correct routine. This makes the +choice of the routine based on the major-mode. + +It seems to work and could save quite a lot of code being essentially +duplicated. Would something like this be acceptable? Would it be way +too slow? Is there some much better way? Any comments (including "Just +don't do that") gratefully received. + +Best wishes + +Mark + + + + emacs/notmuch-show.el | 7 ++++++- + 1 files changed, 6 insertions(+), 1 deletions(-) + +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index 4d6c014..3e68871 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -1378,6 +1378,10 @@ Some useful entries are: + (notmuch-show-move-to-message-top) + (get-text-property (point) :notmuch-message-properties))) + ++(defun notmuch-show-mode-get-message-properties () ++ "Wrapper for notmuch-show-get-message-properties" ++ (notmuch-show-get-message-properties)) ++ + (defun notmuch-show-set-prop (prop val &optional props) + (let ((inhibit-read-only t) + (props (or props +@@ -1387,7 +1391,8 @@ Some useful entries are: + + (defun notmuch-show-get-prop (prop &optional props) + (let ((props (or props +- (notmuch-show-get-message-properties)))) ++ (funcall (intern (concat (symbol-name major-mode) ++ "-get-message-properties")))))) + (plist-get props prop))) + + (defun notmuch-show-get-message-id (&optional bare) +-- +1.7.9.1 + -- 2.26.2