1

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.

NickD
  • 29,717
  • 3
  • 27
  • 44
Vaibhav
  • 583
  • 3
  • 16

1 Answers1

1

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)

dalanicolai
  • 7,795
  • 8
  • 24