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 68DEF431FB6 for ; Mon, 23 Sep 2013 12:53:21 -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 ne7fBCma2b-0 for ; Mon, 23 Sep 2013 12:53:13 -0700 (PDT) Received: from mail-wg0-f51.google.com (mail-wg0-f51.google.com [74.125.82.51]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 830A5431FBD for ; Mon, 23 Sep 2013 12:53:08 -0700 (PDT) Received: by mail-wg0-f51.google.com with SMTP id c11so3491517wgh.18 for ; Mon, 23 Sep 2013 12:53:06 -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:in-reply-to:references; bh=HgxN6x1qQdjHI6qc8bjwEmxrPk7c6RCeqYp/D2R8M7k=; b=QpVd0/5XMROzgkUBpGhUa9W5sTO4KmZz7a3fPy0rcbMEho164R5QnYSHIVzvSQisXK oSfqyah0znrr2deNiX+3G0WNT87V6LurZ4mVmaJfkZcGk8bVaaGar8A1qD/2NeUbD+0X 7mThx1dGirDLmiSITxA/bdNZgI1yHnD/koZ1DSvdVu9IHBY2uAaP/BWvyIZ1hnE8rhlg LRy6UruC3Cb3Y8iduE/Z7E7FAAoA2siEVcznXz2OKnn3Av3nsEcx07VLou3vT5wSv7Ea B4JHc4mHYRWMJAwVA2yhp5IGHpnh/8GKJ29rVU8oX6bXxCL7KNAL99d+18g5v38t/HEA LbWQ== X-Received: by 10.180.76.171 with SMTP id l11mr14907596wiw.39.1379965985973; Mon, 23 Sep 2013 12:53:05 -0700 (PDT) Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) by mx.google.com with ESMTPSA id d11sm722825wic.4.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 23 Sep 2013 12:53:05 -0700 (PDT) From: Mark Walters To: notmuch@notmuchmail.org Subject: [PATCH 1/2] contrib: pick: move M-RET to prefix-arg RET Date: Mon, 23 Sep 2013 20:52:58 +0100 Message-Id: <1379965979-14752-2-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <1379965979-14752-1-git-send-email-markwalters1009@gmail.com> References: <1379965979-14752-1-git-send-email-markwalters1009@gmail.com> 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, 23 Sep 2013 19:53:21 -0000 In pick the user has the option of showing the selected message in a subpane (the message pane) or in the full frame. This is customisable using the variable notmuch-pick-show-out. At the moment RET is bound to the default option and M-RET the other option. This is messy and involves tricks to make sure the keymap is setup at the right time. This changes this to prefix-arg RET for the other option which simplifies the code and makes things cleaner. --- contrib/notmuch-pick/notmuch-pick.el | 51 +++++++++++++-------------------- 1 files changed, 20 insertions(+), 31 deletions(-) diff --git a/contrib/notmuch-pick/notmuch-pick.el b/contrib/notmuch-pick/notmuch-pick.el index 054762b..3afdea4 100644 --- a/contrib/notmuch-pick/notmuch-pick.el +++ b/contrib/notmuch-pick/notmuch-pick.el @@ -50,17 +50,10 @@ "Showing message and thread structure." :group 'notmuch) -;; This is ugly. We can't run setup-show-out until it has been defined -;; which needs the keymap to be defined. So we defer setting up to -;; notmuch-pick-init. (defcustom notmuch-pick-show-out nil "View selected messages in new window rather than split-pane." :type 'boolean - :group 'notmuch-pick - :set (lambda (symbol value) - (set-default symbol value) - (when (fboundp 'notmuch-pick-setup-show-out) - (notmuch-pick-setup-show-out)))) + :group 'notmuch-pick) (defcustom notmuch-pick-result-format `(("date" . "%12s ") @@ -241,7 +234,6 @@ FUNC." ;; Override because we want to close message pane first. (define-key map "m" (notmuch-pick-close-message-pane-and #'notmuch-mua-new-mail)) - (define-key map [mouse-1] 'notmuch-pick-show-message) ;; these use notmuch-show functions directly (define-key map "|" 'notmuch-show-pipe-message) (define-key map "w" 'notmuch-show-save-attachments) @@ -261,6 +253,8 @@ FUNC." (define-key map "V" (notmuch-pick-close-message-pane-and #'notmuch-show-view-raw-message)) ;; The main pick bindings + (define-key map (kbd "RET") 'notmuch-pick-show-message) + (define-key map [mouse-1] 'notmuch-pick-show-message) (define-key map "x" 'notmuch-pick-quit) (define-key map "A" 'notmuch-pick-archive-thread) (define-key map "a" 'notmuch-pick-archive-message-then-next) @@ -280,21 +274,6 @@ FUNC." map)) (fset 'notmuch-pick-mode-map notmuch-pick-mode-map) -(defun notmuch-pick-setup-show-out () - "Set up the keymap for showing a thread - -This uses the value of the defcustom notmuch-pick-show-out to -decide whether to show a message in the message pane or in the -whole window." - (let ((map notmuch-pick-mode-map)) - (if notmuch-pick-show-out - (progn - (define-key map (kbd "M-RET") 'notmuch-pick-show-message) - (define-key map (kbd "RET") 'notmuch-pick-show-message-out)) - (progn - (define-key map (kbd "RET") 'notmuch-pick-show-message) - (define-key map (kbd "M-RET") 'notmuch-pick-show-message-out))))) - (defun notmuch-pick-get-message-properties () "Return the properties of the current message as a plist. @@ -466,7 +445,7 @@ Does NOT change the database." (ignore-errors (delete-window notmuch-pick-message-window))))) -(defun notmuch-pick-show-message () +(defun notmuch-pick-show-message-in () "Show the current message (in split-pane)." (interactive) (let ((id (notmuch-pick-get-message-id)) @@ -503,6 +482,17 @@ Does NOT change the database." (notmuch-pick-close-message-window) (notmuch-show id nil nil nil)))) +(defun notmuch-pick-show-message (arg) + "Show the current message. + +Shows in split pane or whole window according to value of +`notmuch-pick-show-out'. A prefix argument reverses the choice." + (interactive "P") + (if (or (and notmuch-pick-show-out (not arg)) + (and (not notmuch-pick-show-out) arg)) + (notmuch-pick-show-message-out) + (notmuch-pick-show-message-in))) + (defun notmuch-pick-scroll-message-window () "Scroll the message window (if it exists)" (interactive) @@ -566,14 +556,14 @@ message will be \"unarchived\", i.e. the tag changes in (interactive) (forward-line) (when (window-live-p notmuch-pick-message-window) - (notmuch-pick-show-message))) + (notmuch-pick-show-message-in))) (defun notmuch-pick-prev-message () "Move to previous message." (interactive) (forward-line -1) (when (window-live-p notmuch-pick-message-window) - (notmuch-pick-show-message))) + (notmuch-pick-show-message-in))) (defun notmuch-pick-prev-matching-message () "Move to previous matching message." @@ -582,7 +572,7 @@ message will be \"unarchived\", i.e. the tag changes in (while (and (not (bobp)) (not (notmuch-pick-get-match))) (forward-line -1)) (when (window-live-p notmuch-pick-message-window) - (notmuch-pick-show-message))) + (notmuch-pick-show-message-in))) (defun notmuch-pick-next-matching-message () "Move to next matching message." @@ -591,7 +581,7 @@ message will be \"unarchived\", i.e. the tag changes in (while (and (not (eobp)) (not (notmuch-pick-get-match))) (forward-line)) (when (window-live-p notmuch-pick-message-window) - (notmuch-pick-show-message))) + (notmuch-pick-show-message-in))) (defun notmuch-pick-refresh-view () "Refresh view." @@ -763,7 +753,7 @@ unchanged ADDRESS if parsing fails." (goto-char (point-max)) (forward-line -1) (when notmuch-pick-open-target - (notmuch-pick-show-message))))) + (notmuch-pick-show-message-in))))) (defun notmuch-pick-insert-tree (tree depth tree-status first last) "Insert the message tree TREE at depth DEPTH in the current thread. @@ -952,7 +942,6 @@ The arguments are: (define-key notmuch-search-mode-map "Z" 'notmuch-pick-from-search-current-query) (define-key notmuch-search-mode-map (kbd "M-RET") 'notmuch-pick-from-search-thread) (define-key notmuch-show-mode-map "Z" 'notmuch-pick-from-show-current-query) -(notmuch-pick-setup-show-out) (message "Initialised notmuch-pick") (provide 'notmuch-pick) -- 1.7.9.1