As a starting point, this:
(defvar myfoo "~/org/test-file-1.org" "myfoo") ; C-x C-e
(defun mybar()
(newline-and-indent)
(insert-file-contents myfoo)) ; C-x C-e
(mybar) ; C-x C-e
Iure repudiandae non alias.
Rerum quia dicta sunt.
Omnis veniam velit nemo saepe in.
I'm trying to modify mybar
such that, instead of using myfoo
,
the user is presented with a predefined list of files (say those matching ~/org/test-file-*.org
), and is expected to choose the one to be processed. How would I do that?
UPDATE:
Based on the answer,
(setq completions '("~/org/test-file-1.org" "~/org/test-file-2.org")) ; C-x C-e
(defun mybar()
(newline-and-indent)
(insert-file-contents (completing-read "Type something, use TAB for completion: " completions nil t))) ; C-x C-e
(mybar) ; C-x C-e
prompts "Type something, use TAB for completion: ". Followed by TAB
, "Type something, use TAB for completion: ~/org/test-file-", and then TAB
opens a buffer showing the candidate files: