version 1.6, 2013/09/21 06:34:14 |
version 1.13, 2013/11/27 17:18:07 |
|
|
;; |
;; |
;; asir-mode.el -- asir mode |
;; asir-mode.el -- asir mode |
;; |
;; |
;; $OpenXM: OpenXM_contrib2/windows/post-msg-asirgui/asir-mode.el,v 1.5 2013/09/21 06:16:05 ohara Exp $ |
;; $OpenXM: OpenXM_contrib2/windows/post-msg-asirgui/asir-mode.el,v 1.12 2013/11/27 13:39:08 ohara Exp $ |
|
|
;; This program is free software: you can redistribute it and/or modify |
;; 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 |
;; it under the terms of the GNU General Public License as published by |
;; the Free Software Foundation, either version 3 of the License, or |
;; the Free Software Foundation, either version 3 of the License, or |
;; (at your option) any later version. |
;; (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 a Abort current calculation. |
|
;; 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 |
;;;; AsirGUI for Windows |
(defvar asir-exec-path '("~/Desktop/asir/bin" "c:/Program Files/asir/bin" "c:/Program Files (x64)/asir/bin" "c:/asir/bin") |
(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") |
"Default search path for asir binary in Windows") |
|
|
(save-excursion |
(save-excursion |
(if (not (get-buffer asir-cmd-buffer-name)) |
(if (not (get-buffer asir-cmd-buffer-name)) |
(let ((current-frame (selected-frame))) |
(let ((current-frame (selected-frame))) |
(or (not window-system) |
(if window-system |
(select-frame (make-frame))) |
(progn |
(shell (get-buffer-create asir-cmd-buffer-name)) ;; Switch to new buffer automatically |
(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) |
(sleep-for 1) |
(goto-char (point-max)) |
(goto-char (point-max)) |
(insert "asir") |
(insert "asir") |
|
|
(insert-buffer-substring buffer start end) |
(insert-buffer-substring buffer start end) |
(comint-send-input)))))) |
(comint-send-input)))))) |
|
|
|
(defun asir-abort () |
|
"Abort calculation on asir" |
|
(interactive) |
|
(if (eq system-type 'windows-nt) |
|
;; for Windows |
|
(let ((exec-path (asir-effective-exec-path))) |
|
(start-process "asir-proc-cmdasir" nil "cmdasir" "--abort")) |
|
;; for UNIX |
|
(save-excursion |
|
(if (get-buffer asir-cmd-buffer-name) |
|
(progn |
|
(set-buffer asir-cmd-buffer-name) |
|
(comint-kill-input) |
|
(comint-interrupt-subjob) |
|
(goto-char (point-max)) |
|
(insert "t\ny") |
|
(comint-send-input) |
|
))))) |
|
|
;;;; Extension for CC-mode. |
;;;; Extension for CC-mode. |
|
|
(require 'cc-mode) |
(require 'cc-mode) |
|
|
'("----" |
'("----" |
["Start Asir" asir-start t] |
["Start Asir" asir-start t] |
["Terminate Asir" asir-terminate t] |
["Terminate Asir" asir-terminate t] |
|
["Abort calcuration on Asir" asir-abort t] |
["Execute Current Buffer on Asir" asir-execute-current-buffer (buffer-file-name)] |
["Execute Current Buffer on Asir" asir-execute-current-buffer (buffer-file-name)] |
["Execute Region on Asir" asir-execute-region mark-active] |
["Execute Region on Asir" asir-execute-region mark-active] |
["Paste Region to Asir" asir-paste-region mark-active] |
["Paste Region to Asir" asir-paste-region mark-active] |
Line 191 Each list item should be a regexp matching a single id |
|
Line 247 Each list item should be a regexp matching a single id |
|
;; Key binding for asir-mode |
;; Key binding for asir-mode |
(define-key asir-mode-map (kbd "C-c s") 'asir-start) |
(define-key asir-mode-map (kbd "C-c s") 'asir-start) |
(define-key asir-mode-map (kbd "C-c t") 'asir-terminate) |
(define-key asir-mode-map (kbd "C-c t") 'asir-terminate) |
|
(define-key asir-mode-map (kbd "C-c a") 'asir-abort) |
(define-key asir-mode-map (kbd "C-c l") 'asir-execute-current-buffer) |
(define-key asir-mode-map (kbd "C-c l") 'asir-execute-current-buffer) |
(define-key asir-mode-map (kbd "C-c r") 'asir-execute-region) |
(define-key asir-mode-map (kbd "C-c r") 'asir-execute-region) |
(define-key asir-mode-map (kbd "C-c p") 'asir-paste-region) |
(define-key asir-mode-map (kbd "C-c p") 'asir-paste-region) |