Installing EmacsLink

Overview

To install EmacsLink:

  1. Register EmacsLink with MATLAB.

    See Registering EmacsLink.

  2. Configure MATLAB to use EmacsLink.

    See Configuring MATLAB.

  3. Configure Emacs to use EmacsLink.

    See Configuring Emacs.

Registering EmacsLink

This section describes two procedures for registering EmacsLink:

You can use either procedure if you own an individually licensed copy of MATLAB.

Registering EmacsLink for All Users

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 Personal Use

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:

  1. Create a subdirectory named EmacsLink in your MATLAB preferences directory.

  2. 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.

  3. Change the name of the copy to info.xml.

Configuring MATLAB

To configure MATLAB to use EmacsLink:

  1. Start MATLAB.

  2. Select Preferences from the MATLAB File menu

    The MATLAB Preferences dialog box appears.

  3. Select Editor/Debugger in the lefthand pane.

    The Editor/Debugger Preferences pane appears.

  4. 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.

  5. 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.

  6. Select the Options button next to the editor list.

    The EmacsLink Options dialog box appears.

  7. Set the Emacs path option on the dialog box to the path of Emacs or XEmacs on your system.

  8. Click OK to dismiss the options dialog box.

  9. Click OK to dismiss the MATLAB Preferences dialog box.

EmacsLink Options

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.

Configuring Emacs

To configure Emacs (or XEmacs) to use EmacsLink:

  1. Start Emacs.

  2. Open your .emacs file.

  3. 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)
        
  4. If necessary, edit the load-path in the pasted code to reflect the actual location of the MATLAB root directory on your system.

  5. Save the .emacs file.

  6. Close Emacs.


Last modified: Thu Feb 21 14:32:16 Eastern Standard Time 2002