Emacs: default dir for (interactive "f")

I am writing a simple hacker solution to switch between "projects" (sets of buffers and frames (X-windows)) on top of DesktopAid. I made a procedure to write a project file:

(defun project-save-as (project-filename) "Save the current session to a new project session file." (interactive "FProject file to write: ") (copy-file project-default project-filename t) ; New project is the new current project. (write-cur-project-file project-filename) (set-variable 'cur-project-filename project-filename) (copy-file cur-project-filename project-default t) ) 

But it is annoying to go to the directory with the project files each time. Is there a way to set the default directory for (interactive) without changing global variables?

Update : here is my (somewhat stupid) code, if anyone is interested → → paste.lisp.org/display/129116 p>

+2
source share
1 answer

You can easily collapse your own interactive functionality by passing it a form that evaluates the argument list for your function.

In this case, you can call read-file-name directly with the hard-coded default directory argument if you want to avoid creating a new variable (although this is similar to what you would use for the variable).

eg:.

 (interactive (list (read-file-name "Project file to write: " "~/"))) 
+6
source

All Articles