unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Mark Walters <markwalters1009@gmail.com>
To: Tomi Ollila <tomi.ollila@iki.fi>, notmuch@notmuchmail.org
Cc: tomi.ollila@iki.fi
Subject: Re: [PATCH v2] emacs: prefer notmuch-emacs-version in User-Agent: header
Date: Sun, 05 Apr 2015 17:14:10 +0100	[thread overview]
Message-ID: <87lhi61rjh.fsf@qmul.ac.uk> (raw)
In-Reply-To: <1426932955-23174-1-git-send-email-tomi.ollila@iki.fi>


On Sat, 21 Mar 2015, Tomi Ollila <tomi.ollila@iki.fi> 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

      reply	other threads:[~2015-04-05 16:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-21 10:15 [PATCH v2] emacs: prefer notmuch-emacs-version in User-Agent: header Tomi Ollila
2015-04-05 16:14 ` Mark Walters [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lhi61rjh.fsf@qmul.ac.uk \
    --to=markwalters1009@gmail.com \
    --cc=notmuch@notmuchmail.org \
    --cc=tomi.ollila@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).