Is there a command to display and automatically copy to clipboard both the current version of Emacs and the current version of org-mode?
I suggest you take a look at the doc string for function
C-h f format (
M-x describe-function). It is similar to the C language
printf, if you know that. The doc string for message includes:
(message FORMAT-STRING &rest ARGS)
Display a message at the bottom of the screen. The message also goes into the ‘Messages’ buffer, if ‘message-log-max’ is non-nil. (In keyboard macros, that’s all it does.) Return the message.
Also, the docstring for
clipboard-kill-ring-save shows you don't call it with the proper arguments, and in fact is to be used when copying some text from a buffer, not from a string.
Searching for "kill-ring" in the index of the info elisp manual can bring to the section Low-Level Kill Ring where the function
kill-new is described. Since
message returns the displayed string, we can feed it directly to
(defun display-and-copy-version-info () "Echo the current version of Spacemacs, Emacs, and org-mode, and copy it." (interactive) (kill-new (message "Spacemacs v.%s Emacs %s org-mode %s" spacemacs-version emacs-version org-version)))