how to make maxima-mode start imaxima



On Fri, 30 Mar 2012 16:15:37 +0000, Leo Butler wrote:

> Tamas Papp <tkpapp at gmail.com> writes:
> 
>> Hi,
>>
>> I am trying to figure out how to make maxima-mode start imaxima when
>> something is sent to maxima but there is no maxima buffer yet.  I found
>> this in the archives:
>>
>> http://article.gmane.org/gmane.comp.mathematics.maxima.general/32916
>>
>> but could not get it working (it breaks the interaction with the maxima
>> buffer).  Are there any other possibilities?
> 
> Advising maxima-send-region seems the most sensible way to do this, for
> the reasons explained in that message.
> 
> Could you explain what you mean by 'it breaks the interaction with the
> maxima buffer'? In fact, could you back up and explain what you have
> done to produce what results, please.

Sorry, I should have done that originally.

I can reproduce the bug like this: I open a Maxima source file, type the
equations

eq1: 1+a=2;
eq2: a+b=c;

then start pressing C-c C-c on each.  I get

(%i1) block(load(("/usr/share/emacs-snapshot/site-lisp/maxima/imaxima.lisp")), linenum:0)$
Maxima 5.2;

(%i1) incorrect syntax: 5.2000000000000002 is not an infix operator
MaximaSpace5.2;
         ^
(%i2) .0 http://m;
incorrect syntax: HTTP is not an infix operator
.0Spacehttp:
      ^

in the imaxima buffer.  Otherwise, it is an imaxima buffer that works
correctly when typed into directly.

I have the following maxima-related configuration:

(autoload 'maxima-mode "maxima" "Maxima mode" t)
(autoload 'maxima "maxima" "Maxima interaction" t)
(setq auto-mode-alist (cons '("\\.max" . maxima-mode) auto-mode-alist))
(autoload 'imaxima "imaxima" "Frontend for maxima with Image support" t)
(autoload 'imath-mode "imath" "Imath mode for math formula input" t)
(setq imaxima-use-maxima-mode-flag t
      imaxima-fnt-size "LARGE"
      imaxima-latex-preamble "\\usepackage{concrete}\\usepackage{euler}")

(defadvice maxima-send-region (before maxima-start-imaxima first)
  "Ensures that imaxima is running and the correct flag is set."
  (setq imaxima-use-maxima-mode-flag t)
  (imaxima))

(ad-activate 'maxima-send-region)

(defun customize-maxima-mode ()
  (interactive)
  (setq imaxima-use-maxima-mode-flag t)
  (local-set-key (kbd "C-c C-i") 'maxima-complete))

(add-hook 'maxima-mode-hook 'customize-maxima-mode)

(defun customize-imaxima ()
  (interactive)
  (local-set-key (kbd "TAB") 'maxima-complete))

(add-hook 'imaxima-startup-hook 'customize-imaxima)

Versions:

$ dpkg -l 'maxima*'
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                              Version                           Description
+++-=================================-=================================-==================================================================================
ii  maxima                            5.26.0-3                          Computer algebra system -- base system
ii  maxima-doc                        5.26.0-3                          Computer algebra system -- documentation
ii  maxima-emacs                      5.26.0-3                          Computer algebra system -- emacs interface
ii  maxima-share                      5.26.0-3                          Computer algebra system -- extra code
ii  maxima-src                        5.26.0-3                          Computer algebra system -- source code
$ dpkg -l 'emacs-snapshot*'
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                              Version                           Description
+++-=================================-=================================-==================================================================================
ii  emacs-snapshot                    2:20120326-1                      The GNU Emacs editor (development snapshot)
ii  emacs-snapshot-bin-common         2:20120326-1                      The GNU Emacs editor's shared, architecture dependent files
ii  emacs-snapshot-common             2:20120326-1                      The GNU Emacs editor's common infrastructure
ii  emacs-snapshot-el                 2:20120326-1                      GNU Emacs LISP (.el) files

Best,

Tamas