mupacs

Messages in english

Modérateur : xcasadmin

belanger
Messages : 59
Inscription : jeu. juil. 27, 2017 3:26 pm

mupacs

Message par belanger » dim. févr. 11, 2018 10:43 pm

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

frederic han
Messages : 1137
Inscription : dim. mai 20, 2007 7:09 am
Localisation : Paris
Contact :

Re: mupacs

Message par frederic han » lun. févr. 12, 2018 9:16 am

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

parisse
Messages : 5739
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: mupacs

Message par parisse » lun. févr. 12, 2018 9:42 am

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:-)

belanger
Messages : 59
Inscription : jeu. juil. 27, 2017 3:26 pm

Re: mupacs

Message par belanger » mer. févr. 14, 2018 3:19 am

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

frederic han
Messages : 1137
Inscription : dim. mai 20, 2007 7:09 am
Localisation : Paris
Contact :

Re: mupacs

Message par frederic han » mer. févr. 14, 2018 10:27 am

of course, feel free to use it.

Répondre