-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy patherrorDocCallback.m
83 lines (76 loc) · 3.08 KB
/
errorDocCallback.m
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
function errorDocCallback(topic, fileName, lineNumber)
% --------------------------------------------------------------------------------
% --- Determining whether we should use the original function or the tweaked one
% --------------------------------------------------------------------------------
bTweak=false;
mlr=matlabroot; % matlab install path
if length(fileName)<length(mlr)
% most likely this is a user file
bTweak=true;
else
if isequal(fileName(1:length(mlr)),mlr)
bTweak=false;
else
bTweak=true;
end
end
if bTweak
% --------------------------------------------------------------------------------
% --- TWEAKED DOC CALLBACK to call editor
% --------------------------------------------------------------------------------
editor = system_dependent('getpref', 'EditorOtherEditor');
editor = editor(2:end);
file=fileName;
if nargin==3
linecol = sprintf('+%d',lineNumber); % tehre is something about -c "normal column|" but it didn't work
else
linecol = '';
end
if ispc
% On Windows, we need to wrap the editor command in double quotes
% in case it contains spaces
command=['"' editor '" "' linecol '" "' file '"&'];
else
% On UNIX, we don't want to use quotes in case the user's editor
% command contains arguments (like "xterm -e vi")
% disp('proiu');
command=[editor ' "' linecol '" "' file '" &'];
end
disp('This is the tweaked version errorDocCallBack.')
system(command);
else
if ~isempty(help(topic))
helpPopup(topic);
else
functionName = topic;
split = regexp(functionName, filemarker, 'split', 'once');
hasFileMarker = numel(split) > 1;
if hasFileMarker
functionName = split{1};
if ~isempty(help(functionName))
helpPopup(functionName);
return;
end
end
className = regexp(functionName, '.*?(?=/[\w.]*$|\.\w+$)', 'match', 'once');
if ~isempty(meta.class.fromName(className)) && ~isempty(help(className))
helpPopup(className);
else
editTopic = topic;
if ~hasFileMarker && isempty(className)
editTopic = [topic, filemarker, topic];
end
if ~edit(editTopic)
if nargin == 3 && ~isempty(fileName)
opentoline(fileName, lineNumber, 0);
else
helpdlg(getString(message('MATLAB:helpUtils:errorDocCallback:Undocumented', topic)), getString(message('MATLAB:helpUtils:errorDocCallback:UndocumentedTitle')));
end
end
end
end
end
%
% % Copyright 2010 The MathWorks, Inc.
% % $Revision: 1.1.6.5 $ $Date: 2011/10/22 22:03:55 $
end