[BACK]Return to asir-mode.el CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / windows / post-msg-asirgui

Diff for /OpenXM_contrib2/windows/post-msg-asirgui/asir-mode.el between version 1.9 and 1.15

version 1.9, 2013/11/27 04:23:07 version 1.15, 2021/02/24 23:10:32
Line 2 
Line 2 
 ;;  ;;
 ;; asir-mode.el -- asir mode  ;; asir-mode.el -- asir mode
 ;;  ;;
   ;; $OpenXM: OpenXM_contrib2/windows/post-msg-asirgui/asir-mode.el,v 1.14 2014/12/01 19:27:01 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.
   
 ;;;; AsirGUI for Windows  ;; 1. Install
 (defconst asir-exec-path-default '("~/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")  ;; **(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.
   
 (defvar asir-exec-path asir-exec-path-default  (require 'shell)
   "Search path for asir binary")  (require 'cl)
   
 (defun asir-effective-exec-path ()  ;;;; 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")
   
   (defun asir-effective-exec-path ()
   "Search path for command"    "Search path for command"
   (let* ((dir (getenv "ASIR_ROOTDIR"))    (let* ((dir (getenv "ASIR_ROOTDIR"))
                  (path (append asir-exec-path exec-path)))           (path (append asir-exec-path exec-path)))
         (if dir (cons (concat dir "/bin") path) path)))      (if dir (cons (concat dir "/bin") path) path)))
   
 (defun asir-executable-find (command)  (defun asir-executable-find (command)
   "Search for command"    "Search for command"
   (let* ((exec-path (asir-effective-exec-path)))    (let* ((exec-path (asir-effective-exec-path)))
         (executable-find command)))      (executable-find command)))
   
 (defun asir-start-asirgui ()  ;;;; Asir for UNIX
   "Run asirgui"  (defvar asir-cmd-buffer-name "*asir-cmd*")
   
   (defun asir-cmd-load (filename)
     "Send `load' command to running asir process"
     (if (eq system-type 'windows-nt)
         (let ((exec-path (asir-effective-exec-path)))
           (start-process "asir-proc-cmdasir" nil "cmdasir" filename))
       (save-excursion
         (if (get-buffer asir-cmd-buffer-name)
             (progn
               (set-buffer asir-cmd-buffer-name)
               (goto-char (point-max))
               (insert (format "load(\"%s\");" filename))
               (comint-send-input))))))
   
   (defun asir-start ()
     "Start asir process"
   (interactive)    (interactive)
   (let ((exec-path (asir-effective-exec-path)))    (if (eq system-type 'windows-nt)
         (start-process "asir-proc-asirgui" nil "asirgui")))      ;; for Windows
         (let ((exec-path (asir-effective-exec-path)))
           (start-process "asir-proc-asirgui" nil "asirgui"))
       ;; for UNIX
       (save-excursion
         (if (not (get-buffer asir-cmd-buffer-name))
             (let ((current-frame (selected-frame)))
               (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")
               (comint-send-input)
               (select-frame current-frame))))))
   
 (defun asir-terminate-asirgui ()  (defun asir-terminate ()
   "Execute the current buffer on asir"    "Terminate asir process"
   (interactive)    (interactive)
   (let ((exec-path (asir-effective-exec-path)))    (if (eq system-type 'windows-nt)
         (start-process "asir-proc-cmdasir" nil "cmdasir" "--quit")))      ;; for Windows
         (let ((exec-path (asir-effective-exec-path)))
           (start-process "asir-proc-cmdasir" nil "cmdasir" "--quit"))
       ;; for UNIX
       (if (get-buffer asir-cmd-buffer-name)
           (if (not window-system)
               (let ((asir-cmd-window (get-buffer-window asir-cmd-buffer-name)))
                 (and (kill-buffer asir-cmd-buffer-name)
                      (or (not asir-cmd-window) (delete-window asir-cmd-window))))
             (let ((asir-cmd-frame (window-frame (get-buffer-window asir-cmd-buffer-name 0))))
               (and (kill-buffer asir-cmd-buffer-name)
                    (delete-frame asir-cmd-frame)))))))
   
 (defun asir-execute-current-buffer-on-asir ()  (defun asir-execute-current-buffer ()
   "Execute the current buffer on asir"    "Execute current buffer on asir"
   (interactive)    (interactive)
   (let ((exec-path (asir-effective-exec-path)))    (let ((exec-path (asir-effective-exec-path)))
         (start-process "asir-proc-cmdasir" nil "cmdasir" (buffer-file-name))))      (asir-cmd-load (buffer-file-name))))
   
 (defun asir-execute-region-on-asir ()  (defun asir-execute-region ()
   "Execute the region on asir"    "Execute region on asir"
   (interactive)    (interactive)
   (save-excursion    (if mark-active
         (if mark-active        (save-excursion
                 (let ((exec-path (asir-effective-exec-path))          (let ((temp-file (make-temp-file (format "%s/cmdasir-" (or (getenv "TEMP") "/var/tmp"))))
                           (temp-file (make-temp-file (format "%s/cmdasir-" (getenv "TEMP")))))                (temp-buffer (generate-new-buffer " *asir-temp*")))
                   (write-region (region-beginning) (region-end) temp-file)            (write-region (region-beginning) (region-end) temp-file)
                   (start-process "asir-proc-cmdasir" nil "cmdasir" temp-file)))))            (set-buffer temp-buffer)
             (insert " end$")
             (write-region (point-min) (point-max) temp-file t) ;; append
             (kill-buffer temp-buffer)
             (asir-cmd-load temp-file)))))
   
   (defun asir-paste-region ()
     "Paste region to asir"
     (interactive)
     (if mark-active
         (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))))))
   
   (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)
Line 90 
Line 207 
   asir    asir
   (append (c-lang-const c-mode-menu c)    (append (c-lang-const c-mode-menu c)
                   '("----"                    '("----"
                         ["Start asirgui" asir-start-asirgui (eq system-type 'windows-nt)]                          ["Start Asir" asir-start t]
                         ["Terminate asirgui" asir-terminate-asirgui (eq system-type 'windows-nt)]                          ["Terminate Asir" asir-terminate t]
                         ["Execute the current buffer on asir" asir-execute-current-buffer-on-asir                          ["Abort calcuration on Asir" asir-abort t]
                          (and (eq system-type 'windows-nt) (buffer-file-name))]                          ["Execute Current Buffer on Asir" asir-execute-current-buffer (buffer-file-name)]
                         ["Execute the region on asir" asir-execute-region-on-asir                          ["Execute Region on Asir" asir-execute-region mark-active]
                          (and (eq system-type 'windows-nt) mark-active)]                          ["Paste Region to Asir" asir-paste-region mark-active]
                         )))                          )))
   
 (defvar asir-font-lock-extra-types nil  (defvar asir-font-lock-extra-types nil
Line 128  Each list item should be a regexp matching a single id
Line 245  Each list item should be a regexp matching a single id
                       map)                        map)
   "Keymap used in asir-mode buffers.")    "Keymap used in asir-mode buffers.")
   
   ;; Key binding for asir-mode
   (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 a") 'asir-abort)
   (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 p") 'asir-paste-region)
   
 (easy-menu-define asir-menu asir-mode-map "asir Mode Commands"  (easy-menu-define asir-menu asir-mode-map "asir Mode Commands"
                   ;; Can use `asir' as the language for `c-mode-menu'                    ;; Can use `asir' as the language for `c-mode-menu'
                   ;; since its definition covers any language.  In                    ;; since its definition covers any language.  In
Line 1128  Key bindings:
Line 1253  Key bindings:
            ((and (eq char-after-ip ?{)             ((and (eq char-after-ip ?{)
                  (progn                   (progn
                    (setq placeholder (c-inside-bracelist-p (point)                     (setq placeholder (c-inside-bracelist-p (point)
                                                            paren-state))                                                             paren-state nil))
                    (if placeholder                     (if placeholder
                        (setq tmpsymbol '(brace-list-open . inexpr-class))                         (setq tmpsymbol '(brace-list-open . inexpr-class))
                      (setq tmpsymbol '(block-open . inexpr-statement)                       (setq tmpsymbol '(block-open . inexpr-statement)
Line 1251  Key bindings:
Line 1376  Key bindings:
                               (save-excursion                                (save-excursion
                                 (goto-char containing-sexp)                                  (goto-char containing-sexp)
                                 (c-looking-at-special-brace-list)))                                  (c-looking-at-special-brace-list)))
                          (c-inside-bracelist-p containing-sexp paren-state))))                           (c-inside-bracelist-p containing-sexp paren-state t))))
           (cond            (cond
   
            ;; CASE 9A: In the middle of a special brace list opener.             ;; CASE 9A: In the middle of a special brace list opener.

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.15

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>