最近一直在为xul写
yasnippet的snippet,包括javascript的和XUL的,区区从来不抱怨XULrunner程序开发没有IDE,因为emacs已经够快了(调试功能还是想要D~)。
有个问题以前就很想解决。那就是改进emacs的compile。
举例来说吧,如果目录树如下:
顶层目录ext
代码目录ext/src
文档目录ext/doc
你正在编写的代码文件是ext/src/main.js
那如果用M-x compile的话,emacs会尝试找寻ext/src/Makefile,因为当前目录是ext/src
可是一般的Makefile都在顶层目录,这样就会常常出错。。
以前区区处理的方法是时刻开着Makefile的buffer,要编译时选切换buffer,由于有ido-mode加入区区emacs很熟练,这个操作并不是很耗时。。。。
有个ede的emacs扩展也有类似的功能,所以刚区区考察了一下ede的info文档,结论是不太合适~
目录区区的目标是尽可能优化自己XUL的编写的效率,所以有了下面的改写版compile,改进工作还会继续:
(defun jr--compile-get-proper-dir (dir)
(let ((newdir dir)
(found nil))
(while (and (not found)
(> (length newdir) 1))
(if (file-exists-p (concat newdir "Makefile"))
(setq found t)
(if (string-match "^[a-zA-Z]:[///]$" newdir)
(setq newdir "")
(setq newdir (file-name-as-directory (expand-file-name ".." newdir)))
)))
(if found newdir dir)))
(defun jr-compile (command &optional comint)
"Joyer alter the //[compile] command, automatic search upward dirs to find
a Makefile"
(interactive
(list
(let ((command (eval compile-command)))
(if (or compilation-read-command current-prefix-arg)
(read-from-minibuffer "Jr-Compile command: "
command nil nil
(if (equal (car compile-history) command)
'(compile-history . 1)
'compile-history))
command))
(consp current-prefix-arg)))
(unless (equal command (eval compile-command))
(setq compile-command command))
(save-some-buffers (not compilation-ask-about-save) nil)
(setq compilation-directory (jr--compile-get-proper-dir default-directory))
(let ((default-directory compilation-directory))
(compilation-start command comint)))
(global-set-key [f7] 'jr-compile)
有个问题以前就很想解决。那就是改进emacs的compile。
举例来说吧,如果目录树如下:
顶层目录ext
代码目录ext/src
文档目录ext/doc
你正在编写的代码文件是ext/src/main.js
那如果用M-x compile的话,emacs会尝试找寻ext/src/Makefile,因为当前目录是ext/src
可是一般的Makefile都在顶层目录,这样就会常常出错。。
以前区区处理的方法是时刻开着Makefile的buffer,要编译时选切换buffer,由于有ido-mode加入区区emacs很熟练,这个操作并不是很耗时。。。。
有个ede的emacs扩展也有类似的功能,所以刚区区考察了一下ede的info文档,结论是不太合适~
目录区区的目标是尽可能优化自己XUL的编写的效率,所以有了下面的改写版compile,改进工作还会继续:
(defun jr--compile-get-proper-dir (dir)
(let ((newdir dir)
(found nil))
(while (and (not found)
(> (length newdir) 1))
(if (file-exists-p (concat newdir "Makefile"))
(setq found t)
(if (string-match "^[a-zA-Z]:[///]$" newdir)
(setq newdir "")
(setq newdir (file-name-as-directory (expand-file-name ".." newdir)))
)))
(if found newdir dir)))
(defun jr-compile (command &optional comint)
"Joyer alter the //[compile] command, automatic search upward dirs to find
a Makefile"
(interactive
(list
(let ((command (eval compile-command)))
(if (or compilation-read-command current-prefix-arg)
(read-from-minibuffer "Jr-Compile command: "
command nil nil
(if (equal (car compile-history) command)
'(compile-history . 1)
'compile-history))
command))
(consp current-prefix-arg)))
(unless (equal command (eval compile-command))
(setq compile-command command))
(save-some-buffers (not compilation-ask-about-save) nil)
(setq compilation-directory (jr--compile-get-proper-dir default-directory))
(let ((default-directory compilation-directory))
(compilation-start command comint)))
(global-set-key [f7] 'jr-compile)