branch: elpa/git-commit commit d6da088dadb036fbbded9f53b4d80fd2f441590f Author: Jonas Bernoulli <jo...@bernoul.li> Commit: Jonas Bernoulli <jo...@bernoul.li>
magit-version: Also add versions to kill ring --- lisp/magit.el | 54 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/lisp/magit.el b/lisp/magit.el index 049ec3a717..4e2eed4a10 100644 --- a/lisp/magit.el +++ b/lisp/magit.el @@ -565,13 +565,16 @@ is run in the top-level directory of the current working tree." Use the function by the same name instead of this variable.") ;;;###autoload -(defun magit-version (&optional print-dest) +(defun magit-version (&optional print-dest interactive) "Return the version of Magit currently in use. -If optional argument PRINT-DEST is non-nil, output -stream (interactively, the echo area, or the current buffer with -a prefix argument), also print the used versions of Magit, Git, -and Emacs to it." - (interactive (list (if current-prefix-arg (current-buffer) t))) + +If optional argument PRINT-DEST is non-nil, also print the used +versions of Magit, Git and Emacs to the output stream +selected by that argument. Interactively use the echo area, or +with a prefix argument use the current buffer. Additionally put +the output in the kill ring. +\n(fn &optional PRINT-DEST)" + (interactive (list (if current-prefix-arg (current-buffer) t) t)) (let ((magit-git-global-arguments nil) (toplib (or load-file-name buffer-file-name)) debug) @@ -639,24 +642,27 @@ and Emacs to it." (magit-git-string "rev-parse" "HEAD")))))))) (if (stringp magit-version) (when print-dest - (princ (format "Magit %s%s, Git %s, Emacs %s, %s" - (or magit-version "(unknown)") - (or (and (ignore-errors - (magit--version>= magit-version "2008")) - (ignore-errors - (require 'lisp-mnt) - (and (fboundp 'lm-header) - (format - " [>= %s]" - (with-temp-buffer - (insert-file-contents - (locate-library "magit.el" t)) - (lm-header "Package-Version")))))) - "") - (magit--safe-git-version) - emacs-version - system-type) - print-dest)) + (let ((str (format + "Magit %s%s, Git %s, Emacs %s, %s" + (or magit-version "(unknown)") + (or (and (ignore-errors + (magit--version>= magit-version "2008")) + (ignore-errors + (require 'lisp-mnt) + (and (fboundp 'lm-header) + (format + " [>= %s]" + (with-temp-buffer + (insert-file-contents + (locate-library "magit.el" t)) + (lm-header "Package-Version")))))) + "") + (magit--safe-git-version) + emacs-version + system-type))) + (when interactive + (kill-new str)) + (princ str print-dest))) (setq debug (reverse debug)) (setq magit-version 'error) (when magit-version