Emacs:默认目录(交互式"f")

Mis*_*iev 3 emacs elisp

我正在编写一个简单的hacky解决方案,在DesktopAid之上切换«projects»(缓冲区和框架组(X窗口)).我做了一个编写项目文件的程序:

(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)
 )
Run Code Online (Sandbox Code Playgroud)

但每次导航到包含项目文件的目录都很烦人.有没有办法在(interactive)不改变全局变量的情况下设置默认目录?

更新:这是我的(有点傻)代码,如果有人有兴趣→ http://paste.lisp.org/display/129116

phi*_*ils 7

您可以interactive通过传递一个表单来轻松地滚动您自己的功能,该表单的计算结果为您的函数的参数列表.

在这种情况下,read-file-name如果你想避免创建一个新变量,你可以直接使用硬编码的默认目录参数调用(虽然它看起来像你使用变量的那种东西).

例如:

(interactive
  (list (read-file-name "Project file to write: " "~/")))
Run Code Online (Sandbox Code Playgroud)