How do I install a MATLAB mode in GNU Emacs? - emacs

Is there an Emacs major mode for MATLAB and / or Octave files? For those who don't know, MATLAB files generally have a ".m" file extension.
My primary interest is GNU Emacs but XEmacs tips would also be appreciated.

Have you tried the octave-mode that is part of the standard emacs distribution? I have found that this works well.
If you're finding it doesn't associate the .m extension, add this to your .emacs:
(setq auto-mode-alist
(cons
'("\\.m$" . octave-mode)
auto-mode-alist))

You'll be wanting http://matlab-emacs.sourceforge.net/ , I would imagine? Read the instructions there.
I used an ancestor of this years ago in XEmacs, so it certainly used to have support for it, but I believe the author is an GNUEmacs user. The guy who wrote it (Eric Ludlam) is a Mathworks employee, so it has vague official credentials.

Not built in in GNU Emacs 22. I found a matlab mode on the web (elisp), but it dates from circa 2000, so I don't know what kind of support you have.
To install you must get emacs to load it, then invoke the mode. You can interactively issue a load-file (With M-x load-file) to test it.

There's a matlab.el file from Matthew Wette on The MathWorks File Exchange. The file doesn't appear to have been updated since 1997 (!), and simply says it is "for early versions of Emacs", but hopefully it will still be of use to you.

I recently downloaded a Matlab mode for Emacs from the Matlab Central file exchange. Works just fine. Don't recall exactly where I found it, if you have trouble let me know and I will look harder.

Related

Org-mode as notebook for non-programmers

I'm a non-programmer (except of some Perl and R skills).
I'm starting my Phd this year and considering to have org-mode as a laboratory notebook. However, before I spend time learning it, I have a bunch of questions..
Most importantly, at work I'm working on a different PC than I do at home, but I use both of them for work, so what I need is a seamless connectivity.
So my idea was to store the org file on a cloud, but actually I will have files that are linked in my org-mode file, but those are actually on a server (at work) which I am not allowed to store on my cloud. This means, lets say I've got some data in a spreadsheet and want to link this spreadsheet in my org file. However, on my private PC this file does not exist. How does org-mode deal with that? Is it even possible? I mean, does it complain?
Also, there are folder on my work PC that are locked for me, so installations and stuff is usually done by the IT service. Does emacs than even work? I tried with R and it works, even installing packages from within R, however, Perl does not as executing perl scripts from the terminal requires folders that are locked.
Also, If you can recommend me good sources for getting started I will be pleased :)
Thanks in advance!
I use org-mode for lots of notes. I use different computers also. The most basic thing I do is have the most inexpensive Amazon AWS compute instance (10-15$ a month IIRC). Emacs has this great system called TRAMP mode that allows you to edit remote files as if they are local. So in my .emacs file I have:
(find-file "/ssh:ec2-user#ec2-11-222-3-444.us-west-2.compute.amazonaws.com:~/logs/year/2018/may.org")
so when I startup emacs it grabs this month's org file. I also maintain a separate directory for tasks that span more than one day:
in the may.org file:
** [[../../tasks/something useful.org][something useful]]
then in the directory:
/ssh:ec2-user#ec2-11-222-3-444.us-west-2.compute.amazonaws.com:/home/ec2-user/logs/tasks/something useful.org
This setup seems ok for my basic needs. for your second requirement you might be able to use tramp mode. You can use org-mode's link system and tramp mode together:
[[file+emacs:/ssh:someUser#otherMachine:~/someDir/TextFile.txt][TextFile.txt]]
you will need to have your ssh-keys setup so you don't have to login:
in ~/.bashrc
ssh-add ~/.ssh/my-aws-secret.pem
ultimately to get emacs to do different things on different machines you may have to get down to conditional branching:
from my .emacs file (p is for predicate):
(defun p-is-windows-os ()
(eq system-type 'windows-nt))
(defun p-is-mac-os ()
(eq system-type 'darwin))
(if (p-is-windows-os)
(setq-default ispell-program-name "C:\\Program Files (x86)\\Aspell\\bin\\aspell.exe"))
if its the same OS on both computers, you might be able to do the condition on the network IP or something.
I really like org-mode and emacs in general. But, I am hesitant to recommend them because they are so different/weird from everything else (I'm a programmer, so weird make sense). Whatever you do: backup your data! Let me know if you want more info.
I strongly recommend you look at Dr. John Kitchin materials.
He does computational chemistry, but a lot of his materials are generic enough to be useful (specially those related to paper writing).
http://kitchingroup.cheme.cmu.edu/blog/category/emacs/
he has a very informative youtube channel.
https://www.youtube.com/channel/UCQp2VLAOlvq142YN3JO3y8w
he has also created some packages to improve org. I consider John as the best source of material for a researcher wanting to use org.
I personally use org-mode all the time for my own research.
About using the cloud. Place your org-files in a common directory (e.g. Dropbox) and make sure that you enable
(global-auto-revert-mode t)
This way if a file is changed in one machine, it will be updated automatically in any other emacs running. This will avoid conflicts.
Also, learn to use org-babel. It is absolutely amazing for R. It is the hacker's version of Jupyter Notebook. This is a good tutorial:
https://orgmode.org/worg/org-tutorials/org-R/org-R.html
--dmg

LESS syntax highlighting for emacs

Does anyone know of a syntax file to get LESS working in emacs?
You are probably looking for a less-css emacs mode, which is an elisp file that can be loaded in your emacs environment. Another version is also available in github.

Emacs ECB Alternative

I've been using Emacs as a PHP IDE for quite some time now (with emacs-starter-kit, ECB, & Geben). With each new release for emacs-starter-kit or Emacs 24, ECB introduces new errors & window issues. It doesn't seem well-maintained anymore (last release was 2009).
Wondering if there's a project-manager / IDE emacs plugin that's today's defacto? Something that does file-browsing (like sr-speedbar), method list, possibly even auto ctags?
The answer is that unfortunately no such thing exists. emacs-nav offer a file browser similar to the one in ECB and you can use something like helm to jump to various stuff in your project (like files, tags, imenu entries, etc). Small utils like projectile might also be helpful to you.
All in all using heavyweight tools like ECB is not the Emacs way and I guess this is the reason while its development has stagnated - few Emacs users would use a tool like that given there a smaller more flexible alternatives.
I'm use sr-speedbar to file browser
http://emacswiki.org/emacs/SrSpeedbar
I'm using ecb on emacs-24 with no problems. the only thing I had to add to my .emacs was:
(setq stack-trace-on-error t)
it prevents from throwing errors on ecb startup. What kind of window issues do you experience?

Emacs image support

I have interest in using the image support in Emacs, as described here http://www.gnu.org/software/emacs/elisp/html_node/Images.html
I have Emacs 23.2, but none of the image commands I've tried have been available, including display-images-p. (Or I'm trying to run them wrong; I'm using the typical M-x thing.)
Any idea what I'm missing? If you get me to point I can run create-image I'll be happy.
What's weird is that I DO see the fancy splash screen (with this image http://www.ee.ryerson.ca/~elf/powerbook/images/emacs-aa.png) so it does have some measure of support apparently.
Additional info:
My Emacs was custom-compiled and supposedly configured mostly default. (`./configure --without-sound` basically, plus some stuff for the directory layout here.)
If you hit "up" a couple times from the manual link I gave above, it says that version of the manual is for 23.2, so I think the versions should match.
The Linux distro is RHEL 5.
Only commands -- functions which call (interactive) -- can be run with M-x.
All functions (commands or otherwise) can be evaluated in other ways, however. Mickey posted a handy summary recently at his Mastering Emacs blog, so I'll just point you to that:
http://www.masteringemacs.org/articles/2010/11/29/evaluating-elisp-emacs/
You could also be missing some image libraries, but when you ran ./configure before compiling, it would have told you whether or not those libraries were present. If you're unsure, you could repeat that process.

How to change emacs config in Lisp In A Box

I have been a programmer for a decade now, but I believe this is the first time I've ever asked a question on a forum. I just can't figure this out and can't find the answer already online.
I am trying to turn on CUA mode so that emacs is more bearable for a windows user (normal copy paste functions). I am running Windows 7 and installed emacs through the Lisp In A Box package. I understand that I need to add a line to my .emacs file or init.el file. I'm not sure which, but I can't find either in my Lip In A Box install directory. The emacs package install also did not come with any tutorials or help files, so its really hard to pick this up.
I am stuck, any help is greatly appreciated!
The .emacs can be found by looking at the answers to this similar question.
Regarding documentation and tutorials, it looks like the link you provided for "Lisp in a Box" says:
If you are new to Emacs, it is
recommended that you read the Emacs
Tutorial which you can access from
with Emacs by going to the Help menu,
or by typing Control-h, letting go,
and hitting t. A more extensive manual
is also available from the Help menu,
or on the web at
http://www.gnu.org/software/emacs/manual/.
Which makes it sound like the manual is there, and certainly the tutorial (I made bold the directions to get to the tutorial).
As far as other places to get information, there is a collection of screencasts on the wiki.
Your question doesn't specify whether or not you what to add to your .emacs to activate CUA mode. You can check out the CUA mode documentation on the wiki (which has links to the manual). The minimal installation is just adding this to your .emacs: (cua-mode t).
For GNU/Emacs, you can choose to use any one of the following three file names as the start-up configuration file:
${HOME}/.emacs
${HOME}/.emacs.el
${HOME}/.emacs.d/init.el
It would probably be a good idea to decide on one of the three options and then stick to it - the first one seems to be the most widely used one. In any case, ${HOME} stands for your home directory -- which is likely to be different from the Lisp In A Box install directory!
Coming from a Unix tradition, Emacs understands ~ (tilde) as an abbreviation for your home directory, so you can visit the .emacs file by typing:
C-x C-f ~/.emacs [ENTER]
(Note that the capital C is Emacs standard notation for a combination of the CTRL key and a second key, i.e. here you press CTRL-x CTRL-f which stands for "find-file" and will then ask you for a file name in the bottom part of the Frame (aka mini-buffer).)
If these are your first customizations, you will just see an empty buffer. Enter
;; start CUA mode every time Emacs starts
(cua-mode t)
and save the buffer with C-x C-s.
Next time you start Emacs, CUA mode should be turned on automatically.
What the others have told you is true: Simply adding (cua-mode t) to your dotfile would be sufficient. HOWEVER: Lisp in a box' Emacs doesn't load this file by default.
Therefore, be sure to edit the shortcut so that it does load the dotfile. This is important, because otherwise you would get weird behavior, where you would add the correct line to the dotfile, start emacs, and then not get cua mode. That would suck.
The reason it does this is to ensure that it starts a vanilla emacs everytime, instead of finding, say C:/_emacs and loading that instead, giving you another user's customizations and confusing you.
The flag for not loading an init file is -q or --no-init-file. Also make sure that --no-site-file is not there.
(I realize that this is an old post, but I found this while looking for something related, and I don't want people walking away frustrated over something that doesn't work.)