チェンジセット 2544

差分発生行の前後
無視リスト:
コミット日時:
2009/04/29 16:31:41 (11 ヶ月前)
コミッタ:
hidachinoiro
ログメッセージ:

関数の仕様を変更し新版として公開
新版は MIT ライセンス

ファイル:

凡例:

変更無し
追加
削除
更新
コピー
移動
  • lisp/xyzzyfcsh/src/fcsh.l

    r1829 r2544  
    1 (defvar *fcsh-path* "fcsh.exe") 
    2 (defvar *fcsh-process* nil) 
    3 (defvar *fcsh-buffer* nil) 
    4 (defvar *fcsh-compile-id* nil) 
    5  
    6 ; fcsh�N�� 
    7 (defun exec-fcsh () (interactive) 
    8   (unless *fcsh-buffer* (progn 
    9     (setq *fcsh-buffer* (execute-subprocess *fcsh-path* "" "*fcsh*")) 
    10     (setq *fcsh-process* (buffer-process *fcsh-buffer*)) 
    11     (with-set-buffer 
    12       (save-excursion 
    13         (set-buffer *fcsh-buffer*) 
    14         (set-buffer-colors #(#xffffff #x000000)) 
    15         (enable-post-buffer-modified-hook t)))))) 
    16  
    17 (defun fcsh-buffer-modified-hook (buffer operation from to undo-p) 
    18   (if (eq buffer *fcsh-buffer*) 
    19     (with-set-buffer 
    20       (save-excursion 
    21         (set-buffer *fcsh-buffer*) 
    22         ;(end-of-buffer) 
    23         (if (string-match "ID.+\\([0-9]+\\)" (buffer-substring from to)) 
    24           (setq *fcsh-compile-id* (parse-integer (match-string 1)))))))) 
    25  
    26 (add-hook 'post-buffer-modified-hook 'fcsh-buffer-modified-hook) 
    27          
    28 ; fcsh�I�� 
    29 (defun exit-fcsh () (interactive) 
    30   (if *fcsh-buffer* (progn 
    31     (kill-process *fcsh-process*) 
    32     (sleep-for 1) 
    33     (delete-buffer *fcsh-buffer*) 
    34     (setq *fcsh-process* nil) 
    35     (setq *fcsh-buffer* nil) 
    36     (setq *fcsh-compile-id* nil)))) 
    37  
    38 ; �R���p�C�� 
    39 ; ��ڈȍ~�͗�����Ɏ�s�ł���(defun compile-flex (&optional command) (interactive) 
    40   (exec-fcsh) 
    41   (erase-buffer *fcsh-buffer*) 
    42   (process-send-string *fcsh-process* 
    43     (if *fcsh-compile-id* 
    44       (format nil "compile ~D\n" *fcsh-compile-id*) 
    45       (concat (or command (read-string "fcsh : " :default "mxmlc ")) "\n")))) 
     1
     2; xyzzy fcsh #2544 
     3
     4 
     5; [Description] 
     6; xyzzy �Ƃ��� Winodws �p��emacs ���C�N�ȃG�f�B�^�� 
     7; fcsh ����Ɏg�� lisp �X�N���v�g�ł� 
     8 
     9; [Usage] 
     10; http://www.libspark.org/wiki/hidachinoiro/xyzzyfcsh 
     11 
     12; [Changes] 
     13; 2009/04/29 �֐��̎d�l��X���V�łƂ��Č� 
     14;            �V�ł�MIT ���C�Z���X 
     15 
     16; [Licence] 
     17; MIT ���C�Z���X�ł� 
     18
     19; Copyright (c) 2009 Hidachinoiro 
     20
     21; Permission is hereby granted, free of charge, to any person obtaining a copy 
     22; of this software and associated documentation files (the "Software"), to deal 
     23; in the Software without restriction, including without limitation the rights 
     24; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
     25; copies of the Software, and to permit persons to whom the Software is 
     26; furnished to do so, subject to the following conditions: 
     27
     28; The above copyright notice and this permission notice shall be included in 
     29; all copies or substantial portions of the Software. 
     30
     31; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
     32; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
     33; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
     34; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
     35; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
     36; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
     37; THE SOFTWARE. 
     38 
     39; [Author] 
     40; �Ђ����̂���; Blog : http://d.hatena.ne.jp/mugaki/ 
     41; Mail : hidachinoiro@gmail.com 
     42 
     43; �f�t�H���g�ŗ��p����csh �R�}���h�̈ʒu 
     44(defvar *fcsh-command* "fcsh") 
     45; �f�t�H���g�ŗ��p����wf �v���C���[�̈ʒu 
     46(defvar *fcsh-player* "SAFlashPlayer.exe") 
     47; �f�t�H���g�ŗ��p�������[�X���O�t�@�C���̈ʒu 
     48(defvar *fcsh-log* 
     49        (merge-pathnames "Macromedia\\Flash Player\\Logs\\flashlog.txt" 
     50                                                                         (si:getenv "APPDATA"))) 
     51 
     52
     53; private variables 
     54
     55 
     56(defvar *fcsh-last-swf* "") 
     57(defvar *fcsh-last-commnad* "") 
     58(defvar-local fcsh-buffer-p nil) 
     59 
     60 
     61
     62; private macros 
     63
     64; �o�b�t�@�ƂƂ���������(defmacro with-buffer (buffer &rest body) 
     65        `(with-set-buffer 
     66                (save-excursion 
     67                        (set-buffer ,buffer) 
     68                        ,@body))) 
     69 
     70; �o�b�t�@���[�J���ȕϐ��ւ̃C���o�[�W������`����;(defmacro define-buffer-field (name default) 
     71;       `(progn 
     72;               (defvar-local ,name ,default) 
     73;               (defun ,name (buffer) 
     74;                       (setq buffer (or buffer (selected-buffer))) 
     75;                       (if (eq buffer :default) 
     76;                               (default-value ',name) 
     77;                               (buffer-local-value buffer ',name))) 
     78;               (defsetf ,name (buffer) (value) 
     79;                       `(if (eq ,buffer :default) 
     80;                               (setq-default ,',name ,value) 
     81;                               (with-buffer ,buffer (setq ,',name ,value)))))) 
     82 
     83
     84; public field 
     85
     86;(define-buffer-field fcsh-command "fcsh.exe") 
     87;(define-buffer-field fcsh-player  "SAFlashPlayer.exe") 
     88;(define-buffer-field fcsh-log     "flashlog.txt") 
     89 
     90
     91; private field 
     92
     93;(define-buffer-field fcsh-last-compile-command "") 
     94;(define-buffer-field fcsh-last-output-swf      "") 
     95;(define-buffer-field fcsh-buffer-p                             nil) 
     96 
     97 
     98 
     99
     100; public interactive functions 
     101
     102 
     103; fcsh �o�b�t�@�̍쐬 
     104; - directory �R�}���h��s�����B���N�g�� 
     105; - fcsh �g�p����csh �R�}���h�B�ȗ�����*fcsh-command* �̒l��p�B 
     106(defun fcsh-create-buffer (&optional directory fcsh) 
     107        (interactive) 
     108        (with-buffer (create-new-buffer "*fcsh*") 
     109                (if directory (set-default-directory directory)) 
     110                (make-process (map-slash-to-backslash (or fcsh *fcsh-command*))) 
     111                (command-output-mode) 
     112                (set-buffer-colors #(#xffffff #x000000)) 
     113                (set-buffer-fold-type-window) 
     114                (set-local-window-flags (selected-buffer) *window-flag-line-number* nil) 
     115                (setq fcsh-buffer-p t) 
     116                (selected-buffer))) 
     117 
     118; fcsh �o�b�t�@�̍폜 
     119; - buffer �폜�����b�t�@�B�ȗ�����(fcsh-find-buffer) �Ō���defun fcsh-kill-buffer (&optional buffer) 
     120        (interactive) 
     121        (when (setq buffer (or buffer (fcsh-find-buffer))) 
     122                (kill-process (buffer-process buffer)) 
     123                (sleep-for 1) 
     124                (delete-buffer buffer))) 
     125                 
     126; �S fcsh �o�b�t�@���폜 
     127(defun fcsh-kill-all-buffers () 
     128        (interactive) 
     129        (let ((list (remove-if-not 'fcsh-buffer-p (buffer-list)))) 
     130                (dolist (buffer list) (kill-process (buffer-process buffer))) 
     131                (sleep-for 1) 
     132                (dolist (buffer list) (delete-buffer buffer)))) 
     133 
     134; fcsh �o�b�t�@���ǂ������肷��(defun fcsh-buffer-p (buffer) 
     135        (buffer-local-value buffer 'fcsh-buffer-p)) 
     136 
     137; fcsh �o�b�t�@���J�����g�f�B���N�g���� fcsh �o�b�t�@�Ȃ������Ԃ� 
     138; �����łȂ������̃o�b�t�@�̒�����csh �o�b�t�@����ĕԂ� 
     139(defun fcsh-find-buffer () 
     140        (interactive) 
     141        (if (fcsh-buffer-p (selected-buffer)) 
     142                (selected-buffer) 
     143                (find-if #'fcsh-buffer-p (buffer-list)))) 
     144 
     145; fcsh-buffer �ɃR�}���h�𑗂�; - command �������}���h�B�ȗ����̓~�j�o�b�t�@�����́B 
     146; - buffer �R�}���h�𑗂�csh �o�b�t�@�B�ȗ�����(fcsh-find-buffer) �Ō���defun fcsh-send-command 
     147        (&optional (command (read-string "command: " :default *fcsh-last-commnad*)) 
     148                   (buffer (fcsh-find-buffer))) 
     149        (interactive) 
     150        (if (numberp command) 
     151                        (setq command (format nil "~D" command))) 
     152        (if (string-looking-at "[0-9]+" command) 
     153                        (setf command (concat "compile " command))) 
     154        (process-send-string 
     155                (buffer-process buffer) 
     156                (concat command "\n")) 
     157        (setq *fcsh-last-commnad* command)) 
     158 
     159; fcsh-buffer �̃G���[���Ă����ɔ� 
     160; - �����csh �o�b�t�@�B�ȗ�����(fcsh-find-buffer) �Ō���defun fcsh-jump-error (&optional (buffer (fcsh-find-buffer))) 
     161        (interactive) 
     162        (let ((cb (selected-buffer)) filename line b e) 
     163                (set-buffer buffer) 
     164                (if (scan-buffer "^\\(.+\\)(\\([0-9]+\\))" :no-dup t :tail t :regexp t) 
     165                                (progn 
     166                                        (setq filename (match-string 1) 
     167                                              line (parse-integer (match-string 2)) 
     168                                                                b (match-beginning 0) 
     169                                                                e (match-end 0)) 
     170                                        (reverse-region b e) 
     171                                        (goto-char b) 
     172                                        (recenter 0) 
     173                                        (find-file filename) 
     174                                        (goto-line line)) 
     175                                (progn 
     176                                        (reverse-region 0 0) 
     177                                        (set-buffer cb) 
     178                                        (message "�G���[�����‚�������))) 
     179 
     180; swf ��^���h�A���[���v���[���[�ōĐ� 
     181; - swf �N������wf �t�@�C���B�ȗ����̓~�j�o�b�t�@������ 
     182; - player �g�p�������C���[�B�ȗ�����*fcsh-player* ��p 
     183(defun fcsh-play-swf 
     184        (&optional (swf (read-file-name "swf: " :default *fcsh-last-swf*)) 
     185                                                 (player *fcsh-player*)) 
     186        (interactive) 
     187        (call-process (concat (map-slash-to-backslash player) " " swf)) 
     188        (setq *fcsh-last-swf* swf)) 
     189 
     190; �g���[�X���O��[�v�����Ă��̃o�b�t�@��� 
     191; - log �\�����郍�O 
     192(defun fcsh-log-buffer (&optional (log *fcsh-log*)) 
     193        (with-buffer (get-buffer-create log) 
     194                (set-buffer-fileio-encoding *encoding-utf8*) 
     195                (make-local-variable 'verify-visited-file-modtime) 
     196                (setq verify-visited-file-modtime :auto) 
     197                (set-buffer-fold-type-window) 
     198                (set-local-window-flags (selected-buffer) *window-flag-line-number* nil) 
     199                (selected-buffer))) 
     200 
     201; �g�p�T���v���̊֐��B��s���� fcsh �̂��߂̃t���[���������������B 
     202; F5 �ŃR���p�C�� F6 �Ŏ�s F9 �ŃR���p�C���G���[�ɔ�܂��B 
     203; - directory fcsh ��������B���N�g�� 
     204; - command �R���p�C���R�}���h 
     205; - �Đ�����wf 
     206(defun fcsh-my-setup (directory command swf) 
     207        (interactive "Ddir: \nscommand: \nfswf: ") 
     208        ; �t���[���֌W�̃Z�b�g�A�b�v 
     209        (fcsh-kill-all-buffers) 
     210        (setq *fcsh-buffer* (fcsh-create-buffer directory)) 
     211        (let ((b (selected-buffer)) (f (find-pseudo-frame "fcsh layout")) w) 
     212                (if f (delete-pseudo-frame f)) 
     213                (new-pseudo-frame "fcsh layout" nil) 
     214                (setq w (selected-window)) 
     215                (split-window -10) 
     216                (set-buffer *fcsh-buffer*) 
     217                (split-window -40 t) 
     218                (set-buffer (fcsh-log-buffer)) 
     219                (set-window w) 
     220                (set-buffer b)) 
     221        ; �L�[�֌W�̃Z�b�g�A�b�v 
     222        (set-function-bar-label #\F5 "fcsh �R���p�C��") 
     223        (set-function-bar-label #\F6 "swf ��s") 
     224        (set-function-bar-label #\F9 "fcsh ���G���[") 
     225        (global-set-key #\F5 #'(lambda () (interactive) 
     226                (save-all-buffers) 
     227                (erase-buffer *fcsh-buffer*) 
     228                (fcsh-send-command 1 *fcsh-buffer*))) 
     229        (global-set-key #\F6 #'(lambda () (interactive) (fcsh-play-swf swf))) 
     230        (global-set-key #\F9 'fcsh-jump-error) 
     231        ; ��s 
     232        (fcsh-send-command command *fcsh-buffer*))