I am successfully using mathematica.el in Emacs with Mathematica 10. However, I have some kind of issue with character encoding whereby when I call mathematica-execute on a Mathematica expression the result prints lots of ^M characters to the output (I am running all processes on OS X Mavericks). I initially made sure that the $CharacterEncoding in Mathematica matched the file and process encoding of Emacs for the buffers being used as best I could: utf-8. There could still be an issue there, but that route didn't yield a solution. Next I thought, why not just create my own function that calls mathematica-execute and then removes the ^M characters from the resulting output. Here is the relevant code:
(defun delete-to-out () (next-line) (set-mark-command nil) (search-forward "]=") (previous-line) (delete-region (region-beginning) (region-end))) (defun remove-^M () "Get rid of ^M characters" (interactive) (message "remove-^M called!") (save-excursion (goto-char (point-min)) (while (re-search-forward "\r" nil t) (replace-match "")))) (defun my-mathematica-execute (arg) "Call mathematica-execute and then clean out the ^M characters it inserts by calling remove-^M" (interactive "P") (save-excursion (mathematica-execute arg) (remove-^M) ;; (delete-to-out) )) ;;; Define some mathematica mode keyboard bindings (if mathematica-mode-map (progn (define-key mathematica-mode-map [remap mathematica-execute] 'my-mathematica-execute) (define-key mathematica-mode-map (kbd "C-c m") 'remove-^M)))
Calling my-mathematica-execute works, but isn't successful at removing the ^M characters. Calling remove-^M or delete-to-out work fine in isolation subsequently. It must be a synchronization issue or timing issue? Any help would be appreciated. Alternative solutions are certainly welcome.