From: Mark Walters Date: Sun, 5 Apr 2015 16:14:10 +0000 (+0100) Subject: Re: [PATCH v2] emacs: prefer notmuch-emacs-version in User-Agent: header X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=95b4f124fcd14ad261548e207526ffd7a8ac98d9;p=notmuch-archives.git Re: [PATCH v2] emacs: prefer notmuch-emacs-version in User-Agent: header --- diff --git a/b1/61afec9d295aaa215d984916046f69e1aac2de b/b1/61afec9d295aaa215d984916046f69e1aac2de new file mode 100644 index 000000000..6e447b7df --- /dev/null +++ b/b1/61afec9d295aaa215d984916046f69e1aac2de @@ -0,0 +1,239 @@ +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 5835E6DE0AA2 + for ; Sun, 5 Apr 2015 09:14:24 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -1.648 +X-Spam-Level: +X-Spam-Status: No, score=-1.648 tagged_above=-999 required=5 + tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, + NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3, + RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, + RP_MATCHES_RCVD=-0.55, T_FREEMAIL_FORGED_FROMDOMAIN=0.01, + 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 PJFknf8HkZ2f for ; + Sun, 5 Apr 2015 09:14:21 -0700 (PDT) +X-Greylist: delayed 1545 seconds by postgrey-1.35 at arlo; + Sun, 05 Apr 2015 09:14:20 PDT +Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) + by arlo.cworth.org (Postfix) with ESMTPS id C2DCB6DE1A2F + for ; Sun, 5 Apr 2015 09:14:20 -0700 (PDT) +Received: from smtp.qmul.ac.uk ([138.37.6.40]) + by mail2.qmul.ac.uk with esmtp (Exim 4.71) + (envelope-from ) + id 1YenBh-0002fJ-N9; Sun, 05 Apr 2015 17:14:18 +0100 +Received: from 94.197.113.50.threembb.co.uk ([94.197.113.50] helo=localhost) + by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71) + (envelope-from ) + id 1YenBf-0004RY-Hk; Sun, 05 Apr 2015 17:14:17 +0100 +From: Mark Walters +To: Tomi Ollila , notmuch@notmuchmail.org +Subject: Re: [PATCH v2] emacs: prefer notmuch-emacs-version in User-Agent: + header +In-Reply-To: <1426932955-23174-1-git-send-email-tomi.ollila@iki.fi> +References: <1426932955-23174-1-git-send-email-tomi.ollila@iki.fi> +User-Agent: Notmuch/0.18.1+86~gef5e66a (http://notmuchmail.org) Emacs/23.4.1 + (x86_64-pc-linux-gnu) +Date: Sun, 05 Apr 2015 17:14:10 +0100 +Message-ID: <87lhi61rjh.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Sender-Host-Address: 94.197.113.50 +X-QM-Geographic: According to ripencc, + this message was delivered by a machine in Britain (UK) (GB). +X-QM-SPAM-Info: Sender has good ham record. :) +X-QM-Body-MD5: b1be2c50947868a80d7ad463ba283e8b (of first 20000 bytes) +X-SpamAssassin-Score: -0.1 +X-SpamAssassin-SpamBar: / +X-SpamAssassin-Report: The QM spam filters have analysed this message to + determine if it is + spam. We require at least 5.0 points to mark a message as spam. + This message scored -0.1 points. + Summary of the scoring: + * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider + * (markwalters1009[at]gmail.com) + * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay + * domain + * -0.1 AWL AWL: Adjusted score from AWL reputation of From: address +X-QM-Scan-Virus: ClamAV says the message is clean +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, 05 Apr 2015 16:14:24 -0000 + + +On Sat, 21 Mar 2015, Tomi Ollila wrote: +> 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) -- the function to do that was +> renamed from `notmuch-version' to `notmuch-cli-version' to make this +> clearer and more consistent. +> +> The hub of getting version information is new `notmuch-versions' +> function. It normally returns cons pair +> (notmuch-emacs-version . notmuch-cli-version). +> This function takes optional argument which makes the cdr of the return +> value work differently; if `notmuch-emacs-version' is "unknown", return +> pair as if the option were not given; otherwise return +> (notmuch-emacs-version . notmuch-emacs-version). +> This special case is useful to simplify setting User-Agent: header +> -- just use the cdr of the returned value. + +Hi + +At the moment I am not seeing the advantages of this approach over that +Michal suggested in id:87oau1un7g.fsf@steelpick.2x.cz (with a +notmuch-guess-emacs-version) which looks a little simpler; could you +explain? + +(Just in case its not clear: I like the renaming of notmuch-version to +notmuch-cli-version but I feel putting the guessing logic in +notmuch-versions with an optional argument is overloading that function, +and I am not sure what the advantage of having that function is) + + +Many thanks + +Mark + + + +> --- +> +> This is v2 of id:1407496781-17458-1-git-send-email-tomi.ollila@iki.fi +> +> (NEWS dropped from this one (for now) -- will arrive later) +> +> emacs/notmuch-hello.el | 13 +++++-------- +> emacs/notmuch-lib.el | 20 +++++++++++++++++++- +> emacs/notmuch-mua.el | 2 +- +> emacs/notmuch.el | 4 ---- +> 4 files changed, 25 insertions(+), 14 deletions(-) +> +> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el +> index 65d0627..62345fe 100644 +> --- a/emacs/notmuch-hello.el +> +++ b/emacs/notmuch-hello.el +> @@ -622,18 +622,15 @@ (defun notmuch-hello-window-configuration-change () +> (remove-hook 'window-configuration-change-hook +> #'notmuch-hello-window-configuration-change)))) +> +> -;; the following variable is defined as being defconst in notmuch-version.el +> -(defvar notmuch-emacs-version) +> - +> (defun notmuch-hello-versions () +> "Display the notmuch version(s)" +> (interactive) +> - (let ((notmuch-cli-version (notmuch-version))) +> + (let ((notmuch-versions (notmuch-versions))) +> (message "notmuch version %s" +> - (if (string= notmuch-emacs-version notmuch-cli-version) +> - notmuch-cli-version +> - (concat notmuch-cli-version +> - " (emacs mua version " notmuch-emacs-version ")"))))) +> + (if (string= (car notmuch-versions) (cdr notmuch-versions)) +> + (car notmuch-versions) +> + (concat (cdr notmuch-versions) +> + " (emacs mua version " (car notmuch-versions) ")"))))) +> +> (defvar notmuch-hello-mode-map +> (let ((map (if (fboundp 'make-composed-keymap) +> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el +> index f8e5165..370b648 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) +> +> @@ -192,7 +196,7 @@ (defun notmuch-assert-cli-sane () +> "Perhaps you haven't run \"notmuch setup\" yet? Try running this +> on the command line, and then retry your notmuch command"))) +> +> -(defun notmuch-version () +> +(defun notmuch-cli-version () +> "Return a string with the notmuch version number." +> (let ((long-string +> ;; Trim off the trailing newline. +> @@ -202,6 +206,20 @@ (defun notmuch-version () +> (match-string 2 long-string) +> "unknown"))) +> +> +(defun notmuch-versions (&optional cdr-as-emacs-version-unless-unknown) +> + "Returns cons pair (notmuch-emacs-version . (`notmuch-cli-version')) +> +If optional argument CDR-AS-EMACS-VERSION-UNLESS-UNKNOWN is non-nil +> +and `notmuch-emacs-version' is not \"unknown\" return cons pair +> +(notmuch-emacs-version . notmuch-emacs-version). +> +`notmuch-mua-user-agent-notmuch' utilizes this option, and uses the cdr +> +of this cons pair in User-Agent: header" +> + (interactive) +> + (cons notmuch-emacs-version +> + (if (or (not cdr-as-emacs-version-unless-unknown) +> + (string= notmuch-emacs-version "unknown")) +> + (notmuch-cli-version) +> + notmuch-emacs-version))) +> + +> (defun notmuch-config-get (item) +> "Return a value from the notmuch configuration." +> (let* ((val (notmuch-command-to-string "config" "get" item)) +> diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el +> index 33f1399..ac067f2 100644 +> --- a/emacs/notmuch-mua.el +> +++ b/emacs/notmuch-mua.el +> @@ -118,7 +118,7 @@ (defun notmuch-mua-user-agent-full () +> +> (defun notmuch-mua-user-agent-notmuch () +> "Generate a `User-Agent:' string suitable for notmuch." +> - (concat "Notmuch/" (notmuch-version) " (http://notmuchmail.org)")) +> + (concat "Notmuch/" (cdr (notmuch-versions t)) " (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 ab00454..0cae117 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 ") +> -- +> 2.1.0 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch