(defun arrayify (start end quote)
"Turn strings on newlines into a QUOTEd, comma-separated one-liner."
(interactive "r\nMQuote: ")
(let ((insertion
(mapconcat
(lambda (x) (format "%s%s%s" quote x quote))
(split-string (buffer-substring start end)) ", ")))
(delete-region start end)
(insert insertion)))
What it does: Given a list of strings separated by newlines (commonly, something copy-pasted from a table) like: josh
sam
jed
C.J.
toby
You select the text, and run "arrayify". You can optionally provide a quote character and, in about half a second, get to: "josh", "jed", "sam", "C.J.", "toby"
This is incredibly useful for taking lists of IDs, or email addresses, or whatever, and transforming them for pasting into documents, or emails, or "in" clauses in SQL, etc.It is unbelievably useful.