I have a function that creates a buffer, with a default file name, and would like the first user action for that buffer be a prompt to write the buffer to a file, allowing the user to change the default, but offering the default in the minibuffer prompt.
The best result of all the options I have tried so far does properly associate the desired filename and path with a buffer, and does prompt the user, but does not offer the default name as a default.
Here is one of the best versions of the test function:
(defun my-write-test () (interactive) (let* ((name "foo.txt") (path "/home/me/foo.txt") (buf (create-file-buffer name))) (pop-to-buffer buf) (insert "random text\n") (set-visited-file-name path) (call-interactively 'write-file (vector path))))
My guess is that I am somehow not properly defining the vector argument to function
call-interactively, but I could be wrong; Maybe I'm just using the wrong elisp function?