I create short text files in a folder c:/Dropbox/daily/
and insert them in various documents using shortcut C-x i
. I would like to define a shortcut so that I don't have to type the path of folder again and again while allowing me to choose the file in the folder interactively.
1 Answer
You can simply use read-file-name
for that:
(defun my-insert-daily (file)
(interactive (list (read-file-name "Select file: " "c:/Dropbox/daily/")))
(insert-file-contents-literally file))
(global-set-key (kbd "C-x i") #'my-insert-daily)