=================================================================== RCS file: /home/cvs/OpenXM_contrib2/windows/post-msg-asirgui/asir-mode.el,v retrieving revision 1.5 retrieving revision 1.8 diff -u -p -r1.5 -r1.8 --- OpenXM_contrib2/windows/post-msg-asirgui/asir-mode.el 2013/09/21 06:16:05 1.5 +++ OpenXM_contrib2/windows/post-msg-asirgui/asir-mode.el 2013/11/16 06:54:12 1.8 @@ -2,13 +2,41 @@ ;; ;; asir-mode.el -- asir mode ;; -;; $OpenXM: OpenXM_contrib2/windows/post-msg-asirgui/asir-mode.el,v 1.4 2013/09/21 03:52:05 ohara Exp $ +;; $OpenXM: OpenXM_contrib2/windows/post-msg-asirgui/asir-mode.el,v 1.7 2013/09/21 10:51:45 ohara Exp $ ;; This program is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. +;; 1. Install +;; +;; **(for Windows) Write the following configuration to your .emacs file. +;; +;; (setq load-path (append load-path '((concat (getenv "ASIR_ROOTDIR") "/share/editor")))) +;; (setq auto-mode-alist (cons '("\\.rr$" . asir-mode) auto-mode-alist)) +;; (autoload 'asir-mode "asir-mode" "Asir mode" t) +;; +;; **(for unix) Copy this file to your emacs site-lisp folder and +;; write the following configuration to your .emacs file. +;; +;; (setq auto-mode-alist (cons '("\\.rr$" . asir-mode) auto-mode-alist)) +;; (autoload 'asir-mode "asir-mode" "Asir mode" t) +;; +;; Please run byte-compile for speed up. +;; +;; 2. Use +;; +;; If you open Risa/Asir source file (*.rr) by emacs, then asir-mode starts up automatically. +;; The following key binding can be used: +;; C-c s Asir starts up in another window. +;; C-c t Asir terminates. +;; C-c l The current buffer is loaded to Asir as a file. +;; C-c r Selected region is loaded to Asir as a file. +;; C-c p Selected region is pasted to Asir. + +(require 'shell) + ;;;; AsirGUI for Windows (defvar asir-exec-path '("~/Desktop/asir/bin" "c:/Program Files/asir/bin" "c:/Program Files (x64)/asir/bin" "c:/asir/bin") "Default search path for asir binary in Windows") @@ -51,9 +79,16 @@ (save-excursion (if (not (get-buffer asir-cmd-buffer-name)) (let ((current-frame (selected-frame))) - (or (not window-system) - (select-frame (make-frame))) - (shell (get-buffer-create asir-cmd-buffer-name)) ;; Switch to new buffer automatically + (if window-system + (progn + (select-frame (make-frame)) + (shell (get-buffer-create asir-cmd-buffer-name)) ;; Switch to new buffer automatically + (delete-other-windows)) + (if (>= emacs-major-version 24) + (progn + (split-window) + (other-window -1))) + (shell (get-buffer-create asir-cmd-buffer-name))) (sleep-for 1) (goto-char (point-max)) (insert "asir") @@ -101,14 +136,19 @@ "Paste region to asir" (interactive) (if mark-active - (save-excursion - (let ((buffer (current-buffer)) - (start (region-beginning)) - (end (region-end))) - (set-buffer asir-cmd-buffer-name) - (goto-char (point-max)) - (insert-buffer-substring buffer start end) - (comint-send-input))))) + (if (eq system-type 'windows-nt) + (let ((temp-file (make-temp-file (format "%s/cmdasir-" (getenv "TEMP")))) + (exec-path (asir-effective-exec-path))) + (write-region (region-beginning) (region-end) temp-file) + (start-process "asir-proc-cmdasir" nil "cmdasir" "--paste-contents" temp-file)) + (save-excursion + (let ((buffer (current-buffer)) + (start (region-beginning)) + (end (region-end))) + (set-buffer asir-cmd-buffer-name) + (goto-char (point-max)) + (insert-buffer-substring buffer start end) + (comint-send-input)))))) ;;;; Extension for CC-mode.