Ticket #4136 (closed enhancement: wontfix)

Opened 4 years ago

Last modified 4 years ago

Python scripting for MCEdit – does it have a chance of merge?

Reported by: psprint Owned by:
Priority: major Milestone:
Component: mcedit Version: master
Keywords: mcedit, python, scripting, script Cc: mooffie@…
Blocked By: Blocking:
Branch state: no branch Votes for changeset:

Description

Hi,
I'm doing an effort of adding python scripting to MCEdit. I think that the editor is a very good one and with the scripting it could compete with Vim and other editors. However, after the Lua scripting hasn't been merged into the upstream I'm not sure if the Python script will be?

With the python script the editor with will be able to e.g.:
– configure the key bindings with a python snippets / functions run on the key press,
– configure sophisticated actions, like e.g.: multiple ones run on a single key press, to e.g.: run two rows up, and some columns left/right, etc.,
– configure the word completion that MCEdit has and also extend it with an LSP engine,
– etc., only the imagination will be a boundary…

I think that MCEdit is the missing chain in the world of *nix editors – it's not an (irritating…) modal editor though not as heavy and bloated as Emacs. With the python script added with a proper hooks connected to its C engine, it could flourish and shine.

Change History

comment:1 Changed 4 years ago by angel_il

have you patches? I would glad to try.

comment:2 Changed 4 years ago by psprint

  • Component changed from mc-core to mcedit

comment:3 Changed 4 years ago by psprint

Yes, the fork is at: https://github.com/psprint/mc

It's currently only an additional, built-in mc python module with only one class: OpenFiles, which returns the list of currently open files:

from os import *

import mc
olist = mc.OpenFiles()
for i in range(len(olist)):
    system("printf '" + olist[i].filename + "'\\\\n >> log.txt")

To build, a SWIG installation is needed (pip install swig). Then:

./configure CPPFLAGS="-DENABLE_PYTHON -I/usr/include/python3.8 " LDFLAGS="-L/usr/lib/python3.8 -lpython3.8 -rdynamic" && \
    make install
make -f Makefile2_tmp
export PYTHONPATH=/root/.local/lib/python3.8:`pwd`

Then after opening a file with mcedit the file init.py will be run and it contains the above python code and outputs the currently open files to log.txt.

I'm very enthusiastic about SWIG. It allows to very easily export objects from C to python.

comment:4 Changed 4 years ago by psprint

Ugh, swig isn't available as a python egg, you'll have to use a package manager (pacman -S swig works).

comment:5 Changed 4 years ago by ossi

  • Cc mooffie@… added

comment:6 Changed 4 years ago by zaytsev

The Lua stuff was not merged for two reasons: 1) lack of maintainer time to review, integrate and then support merged code 2) lack of interest on the part of mooffie to become a maintainer. Otherwise, it was pretty awesome in terms of design, code quality and documentation. I'm very sad that I for one have to make a living instead of getting it into mc...

I don't like Lua as a language, but it's extremely lightweight and simple, and has several well maintained virtual machines - even router people like OpenWRT use it. I do like Python, but I'm not sure it's equally suitable to become a scripting engine for mc - as an optional bolton for servers and desktops quite probably yes, but embedded people and exotic machine people will likely have to disable it.

Why would that concern me at all? Well, in my opinion C is a pretty terrible language to write a TUI file manager, it's not quite as bad as assembler, but still only a tiny core actually needs the power of C, the rest would be much better implemented in a high-level language, and will be a lot less code, simpler code, much easier to maintain and extend.

So when mc2 appeared, I though wow, this might be an interesting way of solving the problem - one could gradually shift all non-essential functionality into Lua, and you can get a basic C-core that can work without Lua, but most of the bells and whistles will be done in Lua. Only a tiny minority will be forced to use the C-core - even router people will be able to use the full version. Would that be the case for Python? I highly doubt it :-(

Anyways, TLDR; the likelihood is low, not because we are evil though, but mostly due to the lack of time.

comment:7 Changed 4 years ago by andrew_b

  • Status changed from new to closed
  • Resolution set to wontfix
  • Milestone Future Releases deleted
Note: See TracTickets for help on using tickets.