From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id E366C6DE0173 for ; Thu, 3 Nov 2016 04:38:20 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.006 X-Spam-Level: X-Spam-Status: No, score=-0.006 tagged_above=-999 required=5 tests=[AWL=0.005, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id O-HwQ9au29uA for ; Thu, 3 Nov 2016 04:38:20 -0700 (PDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id 5155E6DE00D3 for ; Thu, 3 Nov 2016 04:38:20 -0700 (PDT) Received: from remotemail by fethera.tethera.net with local (Exim 4.84_2) (envelope-from ) id 1c2GLH-0008TN-45; Thu, 03 Nov 2016 07:37:59 -0400 Received: (nullmailer pid 29662 invoked by uid 1000); Thu, 03 Nov 2016 11:38:14 -0000 From: David Bremner To: Mark Walters , David Bremner , notmuch@notmuchmail.org Subject: [PATCH] emacs: add notmuch-address-post-completion-hook Date: Thu, 3 Nov 2016 08:38:13 -0300 Message-Id: <20161103113813.29596-1-david@tethera.net> X-Mailer: git-send-email 2.10.1 In-Reply-To: <878tt09amd.fsf@qmul.ac.uk> References: <878tt09amd.fsf@qmul.ac.uk> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.22 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: Thu, 03 Nov 2016 11:38:21 -0000 This hook can be used to update the message based on the results of address completion. For example using message-templ or gnus-alias to set the From address based on the To address just completed. The post-completion command is added to the notmuch-company backend to ensure that the hook is also called company completion is started without going through notmuch-address-expand-name. See the docstring of `company-backends' for more information. --- emacs/notmuch-address.el | 7 +++++++ emacs/notmuch-company.el | 1 + 2 files changed, 8 insertions(+) diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el index b2e1fba..5324c92 100644 --- a/emacs/notmuch-address.el +++ b/emacs/notmuch-address.el @@ -98,6 +98,12 @@ to know how address selection is made by default." :group 'notmuch-send :group 'notmuch-external) +(defcustom notmuch-address-completion-hook nil + "Functions called after completing address. The completed address is passed as an argument to each" + :type 'hook + :group 'notmuch-address + :group 'notmuch-hooks) + (defun notmuch-address-selection-function (prompt collection initial-input) "Call (`completing-read' PROMPT COLLECTION nil nil INITIAL-INPUT 'notmuch-address-history)" @@ -205,6 +211,7 @@ external commands." (if chosen (progn (push chosen notmuch-address-history) + (run-hook-with-args 'notmuch-address-completion-hook return-value) (delete-region beg end) (insert chosen)) (message "No matches.") diff --git a/emacs/notmuch-company.el b/emacs/notmuch-company.el index 168315f..91c4804 100644 --- a/emacs/notmuch-company.el +++ b/emacs/notmuch-company.el @@ -86,6 +86,7 @@ (match (if (string-match notmuch-company-last-prefix arg) (match-end 0) 0)) + (post-completion (run-hook-with-args 'notmuch-address-completion-hook arg)) (no-cache t)))) -- 2.10.1