1

it is my first time asking question here. I am a college sophomore. I am taking a Matlab course this semester and find Octave an alternative so I get that installed through Homebrew in my Mac.

The problem is that Octave doesn't seem to be compatible with emacs (or saying, lots of bugs?). First of all, functions like clc, clean won't work in Emacs (by running M-x run-octave) while it works in the terminal. Also, I was trying to make plotting work but whenever I tried to plot in Emacs, they say "no graphics toolkits are available!," further verified by typing "available_graphics_toolkits" and they shown nothing. The strange thing is that if I run the same line "available_graphics_toolkits" in the terminal, gnuplot does shown up. It seems like I get everything set up but Emacs just somehow doesn't recognize it. I have done research online but still problem not solved. Here are some screenshots: Everything works fine in Terminal Everything is not working in Emacs [My OS version] [need at least 10 reputation :(] OSX El Capitain Version 10.11.3

[Octave settings in ~/.emacs] [need at least 10 reputation :(]

  ;Manipulating the Load Path for Octave
(setq inferior-octave-program "/usr/local/bin/octave")
;Fix the frezze error
(setq inferior-octave-prompt ">> ")
;Fix can't find the program error
(add-to-list 'load-path "/usr/local/bin/gnuplot")
;Octave Settings
;using Octave mode for all .m files you visit
(setq auto-mode-alist
      (cons '("\\.m$" . octave-mode) auto-mode-alist))
;turn on the abbrevs, auto-fill and font-lock features automatically
(add-hook 'octave-mode-hook
          (lambda ()
            (abbrev-mode 1)
            (auto-fill-mode 1)
            (if (eq window-system 'x)
                (font-lock-mode 1))))

Let me know for any further information and feel free to give me advises on how to make my question better. Thank you so much.

UPDATE1: Tried installing the package exec-path-from-shell as Dan suggested, doesn't seem to work.

UPDATE2: UPDATE1 actually work after I put those lines in to ~/.emacs instead of ~/.emacs.d/init.el Now the only thing that is bugging me is the clc command still doesn't work. Any ideas?

  • If you can get Octave to work in the terminal but not in Emacs, it may be a problem with Emacs getting access to your OSX path. See this answer, which suggests installing the exec-path-from-shell package to deal with that problem (which you can do via the Emacs package manager: M-x list-packages). – Dan Jan 27 '16 at 16:29
  • Is Ocrave an X11 application? In that case, you might need to set the DISPLAY environment variable in Emacs. See process-environment. – Lindydancer Jan 27 '16 at 16:45
  • @Dan Just installed the package and have added the line in init.el, doesn't seem to work. – Wilson Jan 27 '16 at 17:49
  • @Lindydancer I think the Gnuplot does use X11 as an environment because when I installed it I type in my terminal "brew install gnuplot --with-x11" in order for the plotting to work in my terminal. Any further link on how to set the DISPLAY environment will be helpful. – Wilson Jan 27 '16 at 17:50
  • When you run an X11 application, the DISPLAY environment variable specifies it should show its window. If you run from the command line, it is typically set. However, when you start Emacs it isn't. First, you need to find its value, try env DISPLAY in a shell. Then you can do add (add-to-list process-environment "DISPLAY=xxx") where xxx is the value of the variable, e.g. 127.0.0.1:0. – Lindydancer Jan 27 '16 at 19:34
1

(Migrated from a comment.)

If you can get Octave to work in the terminal but not in Emacs, it may be a problem with Emacs getting access to your OSX path. See this answer, which suggests installing the exec-path-from-shell package to deal with that problem (which you can do via the Emacs package manager: M-x list-packages).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.