Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 22FD26DE1413 for ; Sun, 2 Aug 2015 07:48:49 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.307 X-Spam-Level: X-Spam-Status: No, score=0.307 tagged_above=-999 required=5 tests=[AWL=0.847, RP_MATCHES_RCVD=-0.55, T_HEADER_FROM_DIFFERENT_DOMAINS=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 gqeejnsDkrxa for ; Sun, 2 Aug 2015 07:48:45 -0700 (PDT) Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) by arlo.cworth.org (Postfix) with ESMTP id BCB046DE1410 for ; Sun, 2 Aug 2015 07:48:44 -0700 (PDT) Received: by guru.guru-group.fi (Postfix, from userid 501) id B8C881000B3; Sun, 2 Aug 2015 17:48:26 +0300 (EEST) From: Tomi Ollila To: notmuch@notmuchmail.org, markwalters1009@gmail.com, sojkam1@fel.cvut.cz Subject: [PATCH 2/2] emacs: prefer notmuch-emacs-version in User-Agent: header Date: Sun, 2 Aug 2015 17:48:14 +0300 Message-Id: <1438526894-19657-2-git-send-email-tomi.ollila@iki.fi> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1438526894-19657-1-git-send-email-tomi.ollila@iki.fi> References: <1438526894-19657-1-git-send-email-tomi.ollila@iki.fi> Cc: tomi.ollila@iki.fi X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.18 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 Aug 2015 14:48:49 -0000 Now that we have `notmuch-emacs-version' defined in notmuch emacs MUA use that as a part of User-Agent: header to provide more accurate version information when sending emails. In case some incomplete installation of notmuch emacs MUA is used and `notmuch-emacs-version' is defined as "unknown" then fall back to ask version info from cli (as it used to be before this commit). Requiring notmuch-version[.elc] and if that is missing setting "fallback" notmuch-emacs-version (to "unknown") was moved from notmuch.el to notmuch-lib.el as notmuch-mua.el (which provides User-Agent: information) require's the latter. --- Note that I did not create notmuch-guess-emacs-version (or something) function. The idea is good but there is one HARD problem: naming it. Also, I personally suspect that no-one is going to need that function in coming years... emacs/notmuch-lib.el | 4 ++++ emacs/notmuch-mua.el | 5 ++++- emacs/notmuch.el | 4 ---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index e16a1b9..201d7ec 100644 --- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -25,6 +25,10 @@ (require 'mm-decode) (require 'cl) +(unless (require 'notmuch-version nil t) + (defconst notmuch-emacs-version "unknown" + "Placeholder variable when notmuch-version.el[c] is not available.")) + (autoload 'notmuch-jump-search "notmuch-jump" "Jump to a saved search by shortcut key." t) diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index 934f6c9..3e52d5e 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -118,7 +118,10 @@ (defun notmuch-mua-user-agent-full () (defun notmuch-mua-user-agent-notmuch () "Generate a `User-Agent:' string suitable for notmuch." - (concat "Notmuch/" (notmuch-cli-version) " (http://notmuchmail.org)")) + (let ((notmuch-version (if (string= notmuch-emacs-version "unknown") + (notmuch-cli-version) + notmuch-emacs-version))) + (concat "Notmuch/" notmuch-version " (http://notmuchmail.org)"))) (defun notmuch-mua-user-agent-emacs () "Generate a `User-Agent:' string suitable for notmuch." diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 6564816..5284e77 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -61,10 +61,6 @@ (require 'notmuch-message) (require 'notmuch-parser) -(unless (require 'notmuch-version nil t) - (defconst notmuch-emacs-version "unknown" - "Placeholder variable when notmuch-version.el[c] is not available.")) - (defcustom notmuch-search-result-format `(("date" . "%12s ") ("count" . "%-7s ") -- 1.9.3