Re: patch for new feature: placeholders in execute command
Benno Schulenberg <[email protected]> Tue, 11 Nov 2025 09:10:23 +0100
| Newsgroups | gmane.editors.nano.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello Luca,
Op 10-11-2025 om 12:11 schreef Luca Coraggio:
> I think this feature unlocks an highway of possibilities for using nano
> in advanced text editing contexts.
Grandiose words. :) But... I can't think of anything I would want to
use this feature for. And second: nano is a simple editor, it is not
meant for doing advanced stuff.
> At the expense of few new lines of code,
A few lines of code? Five is a few, maybe ten at most. But a hundred
lines... is a sizeable chunk of code.
> For example, one could build a shell command that,
> according to the filetype, invokes the appropriate documentation program in
> an external terminal (e.g. pydoc for python or R's help in R).
But... why would one want to insert the documentation for some Python
module into a Python file itself? It doesn't make sense to me. You
will have to give a more concrete example of something that is likely
to be useful to a fair number of nano users. (Also, nano doesn't have
a syntax for R, so mentioning that as an example is a bit strange.)
> Another example: we may want to create a shell program that
> asks autocompletion to AI,
Oh no... I have no interest in making it easier for nano to interact
with "artificial intelligence".
> \CWD and
> \FNAME enables the user to easily locate and use the file content externally
Well, \CWD is $(pwd) (in bash; other shells will have something similar),
and \FNAME you can get with "{writeout}{copy}{cancel}", like in:
bind Sh-M-M "{writeout}{copy}{cancel}{execute} echo $(pwd)/{paste}" main
Replace 'echo' with any command you like. But... what should this command
do? Changing the file is of no use, because nano is editing it and will
overwrite any changes. Or should the command produce some meta info about
the file that is to be inserted into the file itself? I don't see the
point. Please provide a concrete and actually useful example.
So, \CWD and \FNAME are not needed. That just leaves \FTYPE. But if nano
is able to determine the filetype (from just the filename extension or the
first line), then any external script can do the same -- if that should be
needed. But I fail to see how this would be useful. Again, please provide
a concrete example that would do something useful for a bunch of filetypes
that nano recognizes.
(One remark about the implementation: why two passes when one pass will do?
It will require a few re-allocations of the target string, but that hardly
matters: they will seldom happen.)
Benno
OpenPGP_signature.asc
(application/pgp-signature, 840 B)
-----BEGIN PGP SIGNATURE----- wsF5BAABCAAjFiEEFo5vQpe/16ea/USWUUu+Lrjhlh8FAmkS728FAwAAAAAACgkQUUu+Lrjhlh96 SRAA2H4satM0hao8NqRN1DaHQ0YdocbOv6jdi0Hqt11RMVJQOXnmqwWo1JsREkg0Payl2tVqaTSp 04PltqGaLWYVTAFxykzI4Cd9uaNlcEvkBz2Zfj3FiWq5AuZW/TB/YDpvS9of7YruCR3OXZbVsmAR gruNw9PpXEd9QIvcQruO9CuI66KjiHYr9AmbpGLUQLsEDY2ZHP3s9bMGAwxLZOJNPZRuSHulVO4w 9VpEBmTRko5jUdkgfdxaXO13asan9XEuNYz7RfKMqr7+U0Bf46J7x2vTj8ROAmaOtp7dk4e7obXF vwH7TiOU6Cdu3IrgsrAIAutxI0wcqAJ9LV5K1BonWah+WdFZi6rIoJmqAQtzVPJz+3bzieFFqwZJ eeKEIpNHvIRDApxLBuD3OinBPk7gfVY7e7R9cUYA4V1s42oiQ5/NwCR6WflguOk07urWga4EpP2X DtOZqIPvw9RNp5heYWqk89dB05QixIdJ7pZs0Cf0wblsKdAYsYoun63fmP1chPHKwTMGEaO1KnJb BMQzKTY4iVNjTcfkRAwpClLbBHO200xtnLwCW2C+cYs2++f3JPoWgQ9FABj300TC5E4T4FHCNJw5 Pgy57tbrQwaONZxHHXAUdbqThsVWN7wu0P1RDanbN04vND7mCJt1SuvawGCjXLo7nJP3wXtr8ARU 2MA= =S3SJ -----END PGP SIGNATURE-----