Ticket #3861 (closed defect: fixed)
The %f macro for mcedit is incorrect
Reported by: | graywolf | Owned by: | andrew_b |
---|---|---|---|
Priority: | major | Milestone: | 4.8.20 |
Component: | mc-core | Version: | master |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Branch state: | merged | Votes for changeset: | committed-master |
Description
$ mc --version
GNU Midnight Commander 4.8.19
System: Fedora 24
The %f macro in mcedit is not correct. It contains the current file name that is selected in the panel but not the actual file name that is opened in mcedit.
I created the mcedit item to run C++ program:
+= f \.cpp$
r Run
clear
app_path=/tmp/$(uuidgen)
if g++ -o $app_path "%f"; then
$app_path
rm $app_path
fi
echo 'Press any key to exit.'
read -s -n 1
Imagine that I opened the file a.cpp in mcedit.
Then I pressed alt+` and switched to panel.
Then I selected (or even opened in mcedit) the file b.cpp.
Then I pressed alt+` and switched back to mcedit with a.cpp.
Then I executed my item "Run" from user menu.
And... The b.cpp will be compiled and run. This is wrong. Why b.cpp? I executed "Run" from a.cpp.
I propose you to do the new macros for mcedit.
%opened_file
- the file name that is opened in current instance of mcedit.
%opened_file_full_path
- as %opened_file but full path to that file.
I think that %opened_file may be not safe because the current directory may be changed in mc panel. So it is better to use %opened_file_full_path.
%opened_file_dir
- full path to directory where %opened_file is.
%save
- save opened file before executing the menu commands. May be useful in some cases. For example I don't want to press F2 every time before run changed code.
Change History
comment:2 follow-up: ↓ 6 Changed 7 years ago by graywolf
Do for the example:
%n - the file name that is opened in current instance of mcedit.
%o - the full path to file that is opened in current instance of mcedit.
%g - the full path to directory of the file that is opened in current
instance of mcedit.
%v - save opened file before executing the menu item commands.
Or reassign some existed macro for mcedit. Give them the other
appointment. For example %f must be as %n mentioned above because
"name of selected file in the panel" is useless for mcedit.
comment:3 Changed 7 years ago by andrew_b
- Owner set to andrew_b
- Status changed from new to accepted
- Component changed from mcedit to mc-core
- Branch state changed from no branch to on review
- Milestone changed from Future Releases to 4.8.20
Let split this ticket to two:
- Th fix of %f macro in mcedit
Please test
Branch: 3961_mcedit_f_macro
Initial changeset:2b38c3328807e16c2c9fbdc638a0665e8f787f66
- Add new macros to mcedit.
This can be appended to #3867 or new ticket can be created.
comment:4 Changed 7 years ago by andrew_b
- Votes for changeset set to andrew_b
- Branch state changed from on review to approved
comment:5 Changed 7 years ago by andrew_b
- Status changed from accepted to testing
- Votes for changeset changed from andrew_b to committed-master
- Resolution set to fixed
- Branch state changed from approved to merged
Merged to master: [931ac2b1ff800d3f445e318490840e3e7848228f].
git log --pretty=oneline b47f233..931ac2b
comment:6 in reply to: ↑ 2 Changed 7 years ago by andrew_b
- Status changed from testing to closed
Replying to graywolf:
Do for the example:
%n - the file name that is opened in current instance of mcedit.
%o - the full path to file that is opened in current instance of mcedit.
%g - the full path to directory of the file that is opened in current
instance of mcedit.
%v - save opened file before executing the menu item commands.
I agree that editor must use the name of opened file not current file in the panel.
The implemented macro parser supports one-symbol names only. Long names like "opened_file_full_path" can't be handled.