GNU ELPA - matlab-mode

matlab-mode Atom Feed

Description
Major mode for MATLAB(R) dot-m files
Latest
matlab-mode-7.1.1.tar (.sig), 2025-Oct-01, 11.7 MiB
Maintainer
Eric M. Ludlam <eludlam@mathworks.com>, Uwe Brauer <oub@mat.ucm.es>, John Ciolfi <john.ciolfi.32@gmail.com>
Website
https://github.com/mathworks/Emacs-MATLAB-Mode
Browse ELPA's repository
CGit or Gitweb
Badge

To install this package from Emacs, use package-install or list-packages.

Full description

1. Emacs MATLAB-mode

MathWorks MATLAB® and GNU Emacs integration:

  1. MATLAB mode, matlab-ts-mode or matlab-mode, for editing *.m files.

    • Edit MATLAB code with syntax highlighting and smart indentation.
    • Lint MATLAB code with fix-it's using the MATLAB Code Analyzer.

    The matlab-ts-mode is a more capable, performant, and accurate than matlab-mode.

  2. Code navigation and more
  3. M-x matlab-shell for running and debugging MATLAB within Emacs (Unix only).

    • MATLAB command window errors are hyper-linked and files open in Emacs
    • Debugging support is available from the MATLAB menu.
    • matlab-shell uses company-mode for completions.

    See doc/matlab-shell-for-unix.org

  4. M-x matlab-shell to run remote Unix MATLAB within your local Emacs session.

    +----------------+                 +-----------------+
    | Local Computer |                 | Remote Computer |
    |                |<===============>|                 |
    |     Emacs      |      ssh        |      MATLAB     |
    +----------------+                 +-----------------+
    

    You use Emacs on your local computer to edit files on the remote computer, run and debug remote MATLAB in a matlab-shell in your local Emacs. See doc/remote-matlab-shell.org.

  5. M-x matlab-netshell for running MATLAB code on Microsoft Windows within Emacs using an attached MATLAB.

    +--------------- Emacs ----------------+         +------------  MATLAB  ------------+
    |                                      |         |                                  |
    | (1) M-x matlab-netshell-server-start |         | (2) connect to Emacs             |
    |                                      |<=======>| >> addpath <matlab-mode>/toolbox |
    | (3) Visit script *.m files and use   |         | >> emacsinit                     |
    |     "MATLAB -> Code Sections" menu   |         | >>                               |
    |     or the key bindings              |         |                                  |
    +--------------------------------------+         +----------------------------------+
    
  6. Code sections support for MATLAB script files. See doc/matlab-code-sections.org.
  7. Creation of scientific papers, theses, and documents using MATLAB and http://orgmode.org.
    • Org enables literate programming which directly supports reproducible research by allowing scientists and engineers to write code along with detailed explanations in natural language.
    • You author code plus natural language descriptive text in *.org files. When you evaluate MATLAB or other language code blocks within the *.org files, org inserts the results back into the *.org file.
    • You can combine multiple *.org files into one final document, thus enabling larger scientific documents.
    • See ./examples/matlab-and-org-mode/ to get started. This directory contains a PDF generated from ./examples/matlab-and-org-mode/matlab-and-org-mode.org.
  8. tlc-mode for editing *.tlc files. The Target Language Compiler (TLC) is part of Simulink® Coder™.

2. Installation

  1. Install the MATLAB package via MELPA or ELPA. MELPA contains the latest version. To install from MELPA, add to your ~/.emacs

    (require 'package)
    (add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)
    

    Restart Emacs and then

    M-x package-install RET matlab-mode RET
    

    Note: to all available packages, M-x RET list-packages RET

  2. [Optional] Install the company package which is used for TAB completions.

    M-x package-install RET company RET
    
  3. [Optional] Install MATLAB tree-sitter for matlab-ts-mode, which provides improved editing capabilities and improved performance.

    The MATLAB tree-sitter leverages Tree-sitter to create a parse tree for MATLAB code. The parse tree is updated incrementally and is robust to syntax errors. It is highly performant and achieves this by being implemented in C to create a shared object that is loaded into the Emacs process. matlab-ts-mode leverages the MATLAB tree-sitter to give an improved MATLAB editing experience when compared with matlab-mode.

    See doc/install-matlab-tree-sitter-grammar.org

  4. [Optional] Install lsp-mode and the MATLAB Language Server for an improved editing experience.
  5. [Optional] Check your installation setup.

    If you are using matlab-ts-mode, visit a *.m MATLAB file and select the menu item:

    MATLAB -> Check setup
    

2.1. Install from this repository

If you are contributing to the Emacs MATLAB Mode package, see contributing/install-emacs-matlab-from-git.org

3. MathWorks Products (https://www.mathworks.com)

Emacs MATLAB-mode is designed to be compatible with the last six years of MathWorks products and may support even older versions of MathWorks products.

5. Community Support

6. FAQ

8. Releases

See NEWS.org

Old versions

matlab-mode-7.1.0.tar.lz2025-Sep-291.13 MiB
matlab-mode-6.3.tar.lz2024-Dec-08 160 KiB

News

1. Release 7.1.1 Oct 1, 2025

  1. matlab-ts-mode: fix semantic movement in strings. Now C-M-f, C-M-b, C-M-SPC work when point is within strings.

2. Release 7.1.0 Sep 29, 2025

  1. Improved matlab-ts-mode imenu. The imenu index now creates indices for code sections defined by "%% heading comments". In addition, the menu was updated to have structure:

    • Class
    • Function
    • Section

    Previously, imenu was a flat list without code sections index entries.

3. Release 7.0.1 Sep 13, 2025

4. Release 7.0.0 Sep 12, 2025

  1. New matlab-ts-mode.

    matlab-ts-mode is a tree-sitter, based MATLAB mode using https://github.com/acristoffers/tree-sitter-matlab. This new MATLAB mode is a replacement for the matlab-mode.

    • Improved font-lock (semantic coloring) performance, making editing even more smooth.
      • More accurate fontification, we now identify language elements accurately and use more faces to color them.
      • Fixes edge-case fontification issues when compared with matlab-mode

        Create issue for this:

        x = [1 2; 3 4];
        y = x''               % this is valid double transpose where matlab-mode gets it wrong
        

        Function identification, see https://github.com/mathworks/Emacs-MATLAB-Mode/issues/48

      • In comments, we now highlight FIXME, TODO, and XXX markers.
      • Fixed fontification of "%% section" to require that the be the start of a comment and on their own line.
      • Variable creation/assignment will be semantically colored.
      • Now fontify all MATLAB/Simulink factory builtin provided functions, class methods/properties, enums, etc. Note, if you override a builtin function with a variable, the variable creation/assignment will be colored as a variable, but the use will continue to be a function. To avoid this confusing state, use variable names that collide with builtin items.
    • Improved indent
      • Simplified the semantics for indent. The indent rules are described in matlab-ts-mode.el for completeness.
      • Improved indent performance, making editing very smooth.
      • Fixes various edge-case indent issues, some are
    • There's no longer prompting if you want functions to have end's. This is now computed automatically.
    • Improved fill-paragraph, M-q, which will now fill comments and when not in a comment, indent the current function or statement.
    • Accurate type of m-file detection, which improves matlab-sections-minor-mode.
    • Change Log command now work with MATLAB *.m files.

      Running C-x 4 a (add-change-log-entry-other-window) will now insert the name of the function or classdef for the current point.

    • Added support for M-x outline-minor-mode. Outline headings are function's, classdef's, and "%% heading" comments.
    • On save fix of function/classdef name now handles buffer names that aren't valid MATLAB identifiers. On save fix of function/classdef name handles buffers not associated with files on disk. Also fixed cases where detection of scripts failed.
    • Improved handling of single quotes for M-x electric-pair-mode. These will automatically pair
      • Single quote when used to create a single-quoted string, but not when used elsewhere, e.g. a matrix transpose.
      • Double quotes for a double-quoted string.
      • Parenthesis (), Vectors, [], and Cells {}.
    • We now highlight starting and ending string quote when the point is on the start or end single

… …