3

I have a folder hardcoded in variable:

(defvar folder-start-mine "/path/to/start/folder/") 

Then I want to interactively define new non-existing subfolder name:

(defun my-new-defun (sel-subdir) (interactive "GNew folder: " folder-start-mine) (mkdir sel-subdir) ... do some stuff with sel-subdir ... ) 

The file navigator in minibuffer starts in home folder and I want it to start in folder-start-mine.

2
  • Do you intend for folder-start-mine to be the default value for sel-subdir, or do you want the value of sel-subdir to be a directory located inside/relative to folder-start-mine? You mention "It starts in the home folder", but I don't know what you're referring to? Commented Jul 6, 2018 at 15:15
  • The file navigator in minibuffer starts in ~/. I want it to start in /path/to/start/folder/. I want for sel-subdir to be a path to the new subfolder (this works). Commented Jul 6, 2018 at 16:28

1 Answer 1

2

The built-in support for prompting a user for a directory name, via the G flag as you have used, does not support setting the default directory. You can do this explicitly with a lisp expression instead of the usual interactive codes.

(defvar folder-start-mine "/path/to/start/folder/") (defun my-new-defun (sel-subdir) (interactive (list (read-directory-name "New Folder: " folder-start-mine))) (mkdir sel-subdir)) 

This will prompt the user for a directory name, starting from the value of folder-start-mine, and then use that as the value of the variable sel-subdir.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.