The following function replaces filenames and places the result in a list. Although the list gets filled, I do not want to add the filename when there is no match. How can I avoid sending non-matching situations from being added to the list?
(defvar my-list-for-later-access '())
(defun mash-homedir (username)
"Substitute USERNAME into the pathname at point."
(interactive "MUsername: ")
(add-to-list
'my-list-for-later-access
(s-replace-regexp
"/home/[^/]+/"
(format "/home/%s/" username)
(thing-at-point 'filename :no-properties))))