[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.4 and 1.7

version 1.4, 2013/09/21 03:52:05 version 1.7, 2013/09/21 10:51:45
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.3 2013/09/19 19:57:32 ohara Exp $  ;; $OpenXM: OpenXM_contrib2/windows/post-msg-asirgui/asir-mode.el,v 1.6 2013/09/21 06:34:14 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.
   
   (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")
Line 16 
Line 18 
 (defun asir-effective-exec-path ()  (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)))
   
 ;;;; Asir for UNIX  ;;;; Asir for UNIX
 (defvar asir-cmd-buffer-name "*asir-cmd*")  (defvar asir-cmd-buffer-name "*asir-cmd*")
Line 30 
Line 32 
 (defun asir-cmd-load (filename)  (defun asir-cmd-load (filename)
   "Send `load' command to running asir process"    "Send `load' command to running asir process"
   (if (eq system-type 'windows-nt)    (if (eq system-type 'windows-nt)
           (let ((exec-path (asir-effective-exec-path)))        (let ((exec-path (asir-effective-exec-path)))
                 (start-process "asir-proc-cmdasir" nil "cmdasir" filename))          (start-process "asir-proc-cmdasir" nil "cmdasir" filename))
         (save-excursion      (save-excursion
           (if (get-buffer asir-cmd-buffer-name)        (if (get-buffer asir-cmd-buffer-name)
                   (progn            (progn
                         (set-buffer asir-cmd-buffer-name)              (set-buffer asir-cmd-buffer-name)
                         (goto-char (point-max))              (goto-char (point-max))
                         (insert (format "load(\"%s\");" filename))              (insert (format "load(\"%s\");" filename))
                         (comint-send-input))))))              (comint-send-input))))))
   
 (defun asir-start ()  (defun asir-start ()
   "Start asir process"    "Start asir process"
   (interactive)    (interactive)
   (if (eq system-type 'windows-nt)    (if (eq system-type 'windows-nt)
     ;; for Windows      ;; for Windows
           (let ((exec-path (asir-effective-exec-path)))        (let ((exec-path (asir-effective-exec-path)))
                 (start-process "asir-proc-asirgui" nil "asirgui"))          (start-process "asir-proc-asirgui" nil "asirgui"))
     ;; for UNIX      ;; for UNIX
         (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))
                         (sleep-for 1)                    (shell (get-buffer-create asir-cmd-buffer-name)) ;; Switch to new buffer automatically
                         (goto-char (point-max))                    (delete-other-windows))
                         (insert "asir")                (if (>= emacs-major-version 24)
                         (comint-send-input)                    (progn
                         (select-frame current-frame))))))                      (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 ()  (defun asir-terminate ()
   "Terminate asir process"    "Terminate asir process"
   (interactive)    (interactive)
   (if (eq system-type 'windows-nt)    (if (eq system-type 'windows-nt)
     ;; for Windows      ;; for Windows
           (let ((exec-path (asir-effective-exec-path)))        (let ((exec-path (asir-effective-exec-path)))
                 (start-process "asir-proc-cmdasir" nil "cmdasir" "--quit"))          (start-process "asir-proc-cmdasir" nil "cmdasir" "--quit"))
     ;; for UNIX      ;; for UNIX
         (if (get-buffer asir-cmd-buffer-name)      (if (get-buffer asir-cmd-buffer-name)
                 (if (not window-system)          (if (not window-system)
                         (let ((asir-cmd-window (get-buffer-window asir-cmd-buffer-name)))              (let ((asir-cmd-window (get-buffer-window asir-cmd-buffer-name)))
                           (and (kill-buffer asir-cmd-buffer-name)                (and (kill-buffer asir-cmd-buffer-name)
                                    (or (not asir-cmd-window) (delete-window asir-cmd-window))))                     (or (not asir-cmd-window) (delete-window asir-cmd-window))))
                   (let ((asir-cmd-frame (window-frame (get-buffer-window asir-cmd-buffer-name 0))))            (let ((asir-cmd-frame (window-frame (get-buffer-window asir-cmd-buffer-name 0))))
                         (and (kill-buffer asir-cmd-buffer-name)              (and (kill-buffer asir-cmd-buffer-name)
                                  (delete-frame asir-cmd-frame)))))))                   (delete-frame asir-cmd-frame)))))))
   
 (defun asir-execute-current-buffer ()  (defun asir-execute-current-buffer ()
   "Execute 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)))
         (asir-cmd-load (buffer-file-name))))      (asir-cmd-load (buffer-file-name))))
   
 (defun asir-execute-region ()  (defun asir-execute-region ()
   "Execute region on asir"    "Execute region on asir"
   (interactive)    (interactive)
   (save-excursion    (if mark-active
         (if mark-active        (save-excursion
                 (let ((temp-file (make-temp-file (format "%s/cmdasir-" (or (getenv "TEMP") "/var/tmp"))))          (let ((temp-file (make-temp-file (format "%s/cmdasir-" (or (getenv "TEMP") "/var/tmp"))))
                           (temp-buffer (generate-new-buffer " *asir-temp*")))                (temp-buffer (generate-new-buffer " *asir-temp*")))
                   (write-region (region-beginning) (region-end) temp-file)            (write-region (region-beginning) (region-end) temp-file)
                   (set-buffer temp-buffer)            (set-buffer temp-buffer)
                   (insert " end$")            (insert " end$")
                   (write-region (point-min) (point-max) temp-file t) ;; append            (write-region (point-min) (point-max) temp-file t) ;; append
                   (kill-buffer temp-buffer)            (kill-buffer temp-buffer)
                   (asir-cmd-load temp-file)))))            (asir-cmd-load temp-file)))))
   
 (defun asir-paste-region ()  (defun asir-paste-region ()
   "Paste region to asir"    "Paste region to asir"
   (interactive)    (interactive)
   (if mark-active    (if mark-active
       (save-excursion        (if (eq system-type 'windows-nt)
         (let ((buffer (current-buffer))            (let ((temp-file (make-temp-file (format "%s/cmdasir-" (getenv "TEMP"))))
               (start (region-beginning))                  (exec-path (asir-effective-exec-path)))
               (end (region-end)))              (write-region (region-beginning) (region-end) temp-file)
           (set-buffer asir-cmd-buffer-name)              (start-process "asir-proc-cmdasir" nil "cmdasir" "--paste-contents" temp-file))
           (goto-char (point-max))          (save-excursion
           (insert-buffer-substring buffer start end)            (let ((buffer (current-buffer))
           (comint-send-input)))))                  (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.  ;;;; Extension for CC-mode.
   

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.7

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