xyzzyでActionScript3を書く人へ
エディタってころころ変えられないものだと思うんですよね。ActionScriptのためにxyzzyを選択する人はまずいないと思うんですが、xyzzy慣れてるからこれでActionScriptも書きたいなって思う人はいるんじゃないすかね。俺はその口です。同じこと考えているひとがいたら、このエントリ、ちょっと読んでやってください。ActionScript用のメジャーモードの紹介とあと自分で書いた少々のコードです。
actionscript-mode
ActionScript2のためのモードです。まずはメジャーモードがないと話になりませんからね。キーワードとかActionScript3で追加されたものは色づけされないんですが概ねあってるんで俺は気にせず使わせてもらっています。
http://shield.jp/~dseg/xyzzy/actionscript-mode/
あと自分で書いたもの
fcshをバッファ内で起動して、コンパイルのコマンドを送りつける関数です。
- (exec-fcsh)
- バッファ内でfcshを起動
- (compile-flex command)
- 指定したコマンドをfcshに送る
(defvar *fcsh-path* "fcsh.exe") (defvar *fcsh-process* nil) (defvar *fcsh-buffer* nil) (defvar *fcsh-compile-id* nil) ; fcsh起動 (defun exec-fcsh () (interactive) (unless *fcsh-buffer* (progn (setq *fcsh-buffer* (execute-subprocess *fcsh-path* "" "*fcsh*")) (setq *fcsh-process* (buffer-process *fcsh-buffer*)) (with-set-buffer (save-excursion (set-buffer *fcsh-buffer*) (set-buffer-colors #(#xffffff #x000000)) (enable-post-buffer-modified-hook t)))))) (defun fcsh-buffer-modified-hook (buffer operation from to undo-p) (if (eq buffer *fcsh-buffer*) (with-set-buffer (save-excursion (set-buffer *fcsh-buffer*) ;(end-of-buffer) (if (string-match "ID として \\([0-9]+\\) が" (buffer-substring from to)) (setq *fcsh-compile-id* (parse-integer (match-string 1)))))))) (add-hook 'post-buffer-modified-hook 'fcsh-buffer-modified-hook) ; fcsh終了 (defun exit-fcsh () (interactive) (if *fcsh-buffer* (progn (kill-process *fcsh-process*) (sleep-for 1) (delete-buffer *fcsh-buffer*) (setq *fcsh-process* nil) (setq *fcsh-buffer* nil) (setq *fcsh-compile-id* nil)))) ; コンパイル ; 二回目以降は履歴をもとに実行できる (defun compile-flex (&optional command) (interactive) (exec-fcsh) (erase-buffer *fcsh-buffer*) (process-send-string *fcsh-process* (if *fcsh-compile-id* (format nil "compile ~D\n" *fcsh-compile-id*) (concat (or command (read-string "fcsh : " :default "mxmlc ")) "\n"))))
たとえば以下のようにキーに登録しておくと、ボタンひとつでコンパイルできます。
(setf *project-root* "...") (setf *flex-project-main-file* "...") (defun compile-project () (interactive) (save-all-buffers) (cd *project-root*) (compile-flex (concat "mxmlc " *flex-project-main-file*))) (define-key *actionscript-mode-map* #\F5 'compile-project)
こういう断片みたいなコードでも、誰かが拾って再利用してくれればいいんすけどね。いじょ。