How to pass commandline arguments to external text editor?
Show older comments
I want to use emacsclient to edit .m files opened through matlab. The Preferences > Editor/Debugger section has an option to configure an external text editor. Using
C:\Program Files\Emacs\x86_64\bin\runemacs.exe
works as expected. However, starting emacsclient requires commandline arguments:
C:\Program Files\Emacs\x86_64\bin\emacsclientw.exe -n -c -a ""
Adding this (or even just the required bare minimum -c flag) as the external editor and opening a .m file opens a cmd window showing the error:
'"C:\Program Files\Emacs\x86_64\bin\emacsclientw.exe -c"' is not recognized as an internal or external command,
operable program or batch file.
Is there an option to include commandline arguments?
1 Comment
Nishant Elkunchwar
on 11 Feb 2022
Accepted Answer
More Answers (2)
Fangjun Jiang
on 11 Feb 2022
0 votes
You need to run system("C:\Program Files\Emacs\x86_64\bin\emacsclientw.exe -n -c -a")
or add this line to your own edit.m file
2 Comments
Nishant Elkunchwar
on 11 Feb 2022
Fangjun Jiang
on 11 Feb 2022
I meant if exeternal .exe file requries arguments, then you can run the system() in Command Window, or make your own edit.m file to include the system() line. Then you can run "edit" in Comand Window to bring up your own Editor.
Image Analyst
on 11 Feb 2022
Here is an example of how I pass two filenames to my calibration chart editor program:
% Now run the Calibration Chart editor program.
% First construct the command line for the system() function.
% Enclose all filenames in double quotes because we may have spaces in the filenames.
editorFullFileName = 'C:\Program Files (x86)\CalibrationChartEditor\CalibrationChartEditor.exe';
arguments = sprintf('-chartfile "%s" -chartimage "%s"', fullRefChartDataFileName, fullRefChartImageFileName);
commandLine = sprintf('"%s" %s', editorFullFileName, arguments);
fprintf('\n%s\n', commandLine);
%----------------------------------------------------------
% Now launch the Calibration Chart editor program using the "system()" function.
% msgboxw(commandLine);
system(commandLine);
Note, if you're passing in strings that have spaces in them, they must be enclosed in double quotes, like I did.
Categories
Find more on File Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!