Join/Login

Business Software

Open Source Software

For Vendors

Blog

About

More

Articles

Create

SourceForge Podcast

Site Documentation

Subscribe to our Newsletter

Support Request

For Vendors Help Create Join Login

Business Software

Open Source Software

SourceForge Podcast

Resources

Articles

Case Studies

Blog

Menu

Help

Create

Join

Login

Nidsh Narayanaa Balaji MATLAB in Emacs - matlab-emacs git

Profile

Activity

MATLAB in Emacs - matlab-emacs git

Menu ▾ ▴

Browse Commits

Fork

Merge Requests 0

Clone of

matlab-emacs / src

Branches

master

copyright

documentation

fill-fix

fontlockhang

hairyblocks

mac_init

modernize

org-mode

shellcomplete

More Branches

[c58249]: / toolbox / emacsrunregion.m  Maximize  Restore  History

Download this file

31 lines (25 with data), 971 Bytes

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

function emacsrunregion(file, startchar, endchar)

% Run code from FILE between STARTCHAR and ENDCHAR.

% Command sent by Emacs for run-cell & run-region functionality.

% Filter out emacs tramp file path prefix

trampMatch = regexp(file, {'/*:',':/'});

if (~isempty(trampMatch{1}))

file = file((trampMatch{2}+1):end);

end

if ~exist(file,'file')

error('You must save your region into a file accessible by MATLAB process.');

end

% Now figure out if shortFileName is on the path.

[ fullFilePath, shortFileName ] = fileparts(file);

onpath = ~isempty(which(shortFileName));

% If not on the path, temporarilly switch to that directory so it and an files it references are

% accessible

if ~onpath

oldpath = pwd;

cd(fullFilePath);

cleanup = onCleanup(@()cd(oldpath));

end

txt = fileread(file);

evalTxt = txt(startchar:min(endchar,length(txt)));

evalin('base',evalTxt);

end

SourceForge

Create a Project

Open Source Software

Business Software

Top Downloaded Projects

Company

About

Team

SourceForge Headquarters
225 Broadway Suite 1600
San Diego, CA 92101
+1 (858) 422-6466

Resources

Support

Site Documentation

Site Status

SourceForge Reviews

© 2025 Slashdot Media. All Rights Reserved.

Terms Privacy Opt Out Advertise

×
Want the latest updates on software, tech news, and AI?

Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.

Submit