feat(emacs/lean-project.el): ask 'project type' in lean-project-create
close #999
This commit is contained in:
parent
b047c9c037
commit
ca1901bb2c
1 changed files with 21 additions and 14 deletions
|
@ -16,25 +16,32 @@
|
||||||
(defun lean-project-inside-p ()
|
(defun lean-project-inside-p ()
|
||||||
(if (lean-project-find-root) t nil))
|
(if (lean-project-find-root) t nil))
|
||||||
|
|
||||||
(defun lean-project-create (directory)
|
(defun lean-project-create (directory type)
|
||||||
(interactive
|
(interactive
|
||||||
(list (read-directory-name "Specify the project root directory: ")))
|
(list (read-directory-name "Specify the project root directory: ")
|
||||||
|
(intern (completing-read "Project type:: " '(standard hott)))))
|
||||||
(let ((project-file (concat (file-name-as-directory directory)
|
(let ((project-file (concat (file-name-as-directory directory)
|
||||||
lean-project-file-name)))
|
lean-project-file-name))
|
||||||
|
(ext (pcase type
|
||||||
|
(`standard "lean")
|
||||||
|
(`hott "hlean")))
|
||||||
|
(default-contents
|
||||||
|
(s-join "\n"
|
||||||
|
;; EXT is a placeholder.
|
||||||
|
'("# Lean project file"
|
||||||
|
""
|
||||||
|
"# Include all .EXT files under this directory"
|
||||||
|
"+ *.EXT"
|
||||||
|
""
|
||||||
|
"# Exclude flycheck generated temp files"
|
||||||
|
"- flycheck*.EXT"
|
||||||
|
""
|
||||||
|
"# Exclude emacs temp files"
|
||||||
|
"- .#*.EXT"))))
|
||||||
(if (file-exists-p project-file)
|
(if (file-exists-p project-file)
|
||||||
(user-error "project-file %s already exists" project-file))
|
(user-error "project-file %s already exists" project-file))
|
||||||
(find-file project-file)
|
(find-file project-file)
|
||||||
(insert (s-join "\n"
|
(insert (s-replace "EXT" ext default-contents))
|
||||||
'("# Lean project file"
|
|
||||||
""
|
|
||||||
"# Include all .lean files under this directory"
|
|
||||||
"+ *.lean"
|
|
||||||
""
|
|
||||||
"# Exclude flycheck generated temp files"
|
|
||||||
"- flycheck*.lean"
|
|
||||||
""
|
|
||||||
"# Exclude emacs temp files"
|
|
||||||
"- .#*.lean")))
|
|
||||||
(save-buffer)))
|
(save-buffer)))
|
||||||
|
|
||||||
(provide 'lean-project)
|
(provide 'lean-project)
|
||||||
|
|
Loading…
Reference in a new issue