To install EmacsLink:
Register EmacsLink with MATLAB.
Configure MATLAB to use EmacsLink.
See Configuring MATLAB.
Configure Emacs to use EmacsLink.
See Configuring Emacs.
This section describes two procedures for registering EmacsLink:
for use by all users of a shared (network license) copy of MATLAB
for personal use by a user of a shared (network-licensed) copy of MATLAB
You can use either procedure if you own an individually licensed copy of MATLAB.
To register EmacsLink for use by all users of a network-licensed copy of MATLAB
or for use by the owner of a personal copy of MATLAB, you need only
change the name of a single file in the MATLAB installation
directory. This file is named info.xml.sample
and resides
in the java/extern/EmacsLink
subdirectory of the MATLAB
installation directory. Rename this file to info.xml
to
register EmacsLink for all users of this copy of MATLAB.
Note. This procedure assumes that you have write-access to the installation directory of the network copy of MATLAB.
Registering EmacsLink for your use entails updating the directory
that stores your MATLAB preference. If your system is a Unix or Linux
system, this directory resides at $HOME/matlab
where
$HOME
is the path to your home directory. If your system
is a Microsoft Windows system, your MATLAB preferences directory
resides in the system's user profile directory (e.g.,
c:/WINNT/Profiles/your_user_name/Application
Data/Mathworks/MATLAB
).
To register EmacsLink for personal use:
Create a subdirectory named EmacsLink in your MATLAB preferences directory.
Copy the file named info.xml.sample
in the
java/extern/EmacsLink
subdirectory of
the MATLAB installation directory file to the newly created EmacsLink
directory in your MATLAB preferences directory.
Change the name of the copy to info.xml
.
To configure MATLAB to use EmacsLink:
Start MATLAB.
Select Preferences from the MATLAB File menu
The MATLAB Preferences dialog box appears.
Select Editor/Debugger in the lefthand pane.
The Editor/Debugger Preferences pane appears.
Select the Integrated text editor option from the Editor preferences group.
Note. This option appears only if you have registered EmacsLink with MATLAB. If it does not appear, you have either not registered EmacsLink with MATLAB or have not done so correctly. See Registering EmacsLink for more information.
Select EmacsLink
from the adjacent editor
list.
MATLAB enables the adjacent Options button. This button displays a dialog box that allows you to set various EmacsLink installation options (see following steps and EmacsLink Options).
You need to perform the next three steps only if you want to use XEmacs with EmacsLink or if Emacs is not in the command path on your system.
Select the Options button next to the editor list.
The EmacsLink Options dialog box appears.
Set the Emacs path option on the dialog box to the path of Emacs or XEmacs on your system.
Click OK to dismiss the options dialog box.
Click OK to dismiss the MATLAB Preferences dialog box.
The EmacsLink Options dialog box allows you to set any of the following installation options:
Port The port number of the socket used by EmacsLink to connect MATLAB with Emacs. Change this setting only if your system already uses the default setting for another purpose.
Timeout The length of time in seconds that EmacsLink waits for Emacs to respond when attempting to connect with Emacs. If Emacs takes longer than the default setting to start, increase the setting.
Emacs path The path of the version of Emacs (or XEmacs) that
you want to use with EmacsLink. If the Emacs/XEmacs executable is
in your system's command path, you need enter only the name of the
executable. Note that the name of the executable of the native Windows version
of Emacs is runemacs.exe
.
To configure Emacs (or XEmacs) to use EmacsLink:
Start Emacs.
Open your .emacs
file.
Copy and paste the following code into your .emacs
file.
;; Edit the path in the following line to reflect the ;; actual location of the MATLAB root directory on your system. (add-to-list 'load-path "c:/matlab/java/extern/EmacsLink/lisp") (autoload 'matlab-eei-connect "matlab-eei" "Connects Emacs to MATLAB's external editor interface.") (autoload 'matlab-mode "matlab" "Enter Matlab mode." t) (setq auto-mode-alist (cons '("\\.m\\'" . matlab-mode) auto-mode-alist)) (autoload 'matlab-shell "matlab" "Interactive Matlab mode." t) (setq matlab-indent-function t) ; if you want function bodies indented (setq matlab-verify-on-save-flag nil) ; turn off auto-verify on save (defun my-matlab-mode-hook () (setq fill-column 76) (imenu-add-to-menubar "Find")) ; where auto-fill should wrap (add-hook 'matlab-mode-hook 'my-matlab-mode-hook)
If necessary, edit the load-path in the pasted code to reflect the actual location of the MATLAB root directory on your system.
Save the .emacs
file.
Close Emacs.