Could you please tell me how I can write a function
which creates and visits a buffer in a particular directory (a default directory name is hard coded, but it would be nice to have an opportunity to change the directory) with some predefined prefix (current date in the format yyyymmdd
) and then offers to finish the title (eg 20170106EMACS_QUESTION.tex
)?
Thus, when the function is called, it would do the following in order:
1) ask for a directory path of the buffer (if nil
, autocomplete with the hard coded default)
2) ask for a file name, with the timestamp yyyymmdd
already filled in at the beginning.
3) create and visit a buffer with the above metadata
completing-read
, read-string
and find-file
seem to be useful.
You can also find the following code helpful, which I do not know how to change to comply with the description:
(defun add-note (d)
(interactive "d")
(let ((default-directory d))
(find-file (format-time-string "%Y%m%d-CUSTOM-TITLE"
(current-time)))))