Page 1 sur 1

mupacs

Publié : dim. févr. 11, 2018 10:43 pm
par belanger
Is anyone using mupacs to run Giac in Emacs?
I gave it a shot without any luck.

(Note that I just wanted to see how Giac runs with its various interfaces and won't be using mupacs beyond that. So I don't want anyone to go through any trouble to get it running, I'm just wondering if it's still usable.)

Jay

Re: mupacs

Publié : lun. févr. 12, 2018 9:16 am
par frederic han
Not me.
I am using the following small code in my .emacs
It is basic but I often put small giac code in comments of my latex files so it is convienient to be able to send it directly to giac. (% at the beginning of a line are removed before sending to giac)

Code : Tout sélectionner

;;; Giac send line or region
(global-set-key (kbd "<f11>") 'giac-sendcommand)
;

(defun giac ()
  "Run Giac in a buffer."
  (interactive)
  (switch-to-buffer (apply 'make-comint "giac" "giac" nil))
  )
; 
(defconst giac-commentpattern "//.*$"); for giac mode
;(defconst giac-commentpattern "#.*$"); for maple mode

(defun giac-send-line-or-region (&optional step)
  (interactive ())
  (let ((proc (get-process "giac"))
        pbuf min max command)
    (unless proc
      (let ((currbuff (current-buffer)))
        (giac)
        (switch-to-buffer currbuff)
        (setq proc (get-process "giac"))
	(display-buffer (process-buffer proc) t)
	))
    (setq pbuff (process-buffer proc))
    (if (use-region-p)
        (setq min (region-beginning)
              max (region-end))
      (setq min (point-at-bol)
            max (point-at-eol)))
    (setq command (buffer-substring min max) )
    (while (string-match giac-commentpattern command);remove the inline giac comments
         (setq command (replace-match "" t t command)))
    (while (string-match "^%" command);removes starting % useful in latex
         (setq command (replace-match "" t t command)))
    (while (string-match "\n" command)
         (setq command (replace-match "" t t command)))
    (setq command (concat command "\n"))
    (with-current-buffer pbuff
      (goto-char (process-mark proc))
      (insert command)
      (move-marker (process-mark proc) (point))
      )
    (process-send-string  proc command)
    ;(display-buffer (process-buffer proc) t)
    (when step 
      (next-line))
    ))


(defun giac-sendcommand ()
  (interactive)
  (giac-send-line-or-region t))
(defun giac-switch-to-process-buffer ()
  (interactive)
  (pop-to-buffer (process-buffer (get-process "giac")) t))
;;;Fin Giac

Re: mupacs

Publié : lun. févr. 12, 2018 9:42 am
par parisse
I used mupacs a long time ago, but never tried recently. It's probably not too hard to make it work, but unless somebody is really interested in that, I won't try myself:-)

Re: mupacs

Publié : mer. févr. 14, 2018 3:19 am
par belanger
Installing mupacs expects MuPAD to be installed, although I'm sure that could be gotten around. Still, it isn't immediate. I was going to mention the various interfaces for Xcas on my web page; perhaps (with his permission) I could mention Frederic Han's code for Emacs users.

Jay

Re: mupacs

Publié : mer. févr. 14, 2018 10:27 am
par frederic han
of course, feel free to use it.