Patches for editor
Pavel Roskin
proski at gnu.org
Thu Jul 5 21:47:56 UTC 2001
Hi, Steef!
Another reply to the same e-mail after looking deeper into the problem.
> Please find a patch against mc-4.5.54 for the editor containing the
> missing ALT-B bracket button and some more. Also, I've fixed and beefed
> up the status line a bit and fixed the bug that randomly ate the right
> bit.
I've applied the part fixing typos in comments :-)
I went even further and eliminated all "begining"s in the source.
Seriously, if you present a patch to the developers it's better to refrain
from unrelated changes - your patch would be easier to read.
> Can someone tell me what's wrong with the user menu?
I think it never worked. It's a result of an incomplete merge with
Colledit.
> Most functions in the distribution version from the menu overwrite the
> file being edited instead of pasting the output into
> ~/.cedit/cooledit.block
> which basically destroys the input file.
The editor in MC uses expand_format() from src/user.c - the same function
as the MC menu. %b is intepreted as described in mc.1: "The current file
name without extension."
So if you are editing "foo.txt" then the output of the menu commands goes
to "foo".
Here's a typical backtrace from a breakpoint on expand_format:
#0 expand_format (c=98 'b', quote=1) at user.c:187
#1 0x0806432a in execute_menu_command (
commands=0x8149e01 "b\n\n+ y unknown & t r\na Author description
header\n unset LANG\n AUTHOR=\"$(cat /etc/passwd |grep ^$(id
-un) |awk -F: '{print($5)}')\"\n cat >>%b <<EOF\n ", '-'
<repeats 19 times>...) at user.c:601
#2 0x080649f3 in user_menu_cmd (edit_widget=0x8124270) at user.c:783
#3 0x080b86de in user_menu (edit=0x8124270) at edit.c:2778
#4 0x080b822b in edit_execute_cmd (edit=0x8124270, command=425,
char_for_insertion=-1)
at edit.c:2605
#5 0x080b73ba in edit_execute_key_command (edit=0x8124270, command=425,
char_for_insertion=-1) at edit.c:2155
#6 0x080bf841 in edit_callback (h=0x810f6a8, e=0x8124270, msg=4,
par=1011)
at editwidget.c:1214
#7 0x0806e03b in dlg_key_event (h=0x810f6a8, d_key=1011) at dlg.c:763
As you can see, user_menu() from the editor source calls user_menu_cmd()
from the main MC source.
user_menu_cmd() in src/user.c is clearly editor-specific - it should be in
edit.c. It calls execute_menu_command() that is preceded by the following
comment:
/* FIXME: recode this routine on version 3.0, it could be cleaner */
We are already at 4.5.44 and it's still there. Anyway, this function
doesn't know whether we are in the editor or not. Neither does
expand_format().
Solution: the editor needs its own expand_format() aware of BLOCK_FILE.
> Is anyone actively working on that functionality?
Nobody, but the fix will be welcome.
--
Regards,
Pavel Roskin
More information about the mc-devel
mailing list