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.

  • 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? – Tyler Jul 6 '18 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). – Jure Sencar Jul 6 '18 at 16:28

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)  
   (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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.