bugGNU nano - Bugs: bug #60773, [Wish] make it possible to adjust...


You are not allowed to post comments on this tracker with your current authentication level.

bug #60773: [Wish] make it possible to adjust fill / guidestripe position from within editor

Submitted by:  Tasos Papastylianou <tpapastylianou>
Submitted on:  Fri 11 Jun 2021 11:47:07 AM UTC  
Severity:  1 - Wish Status:  None
Assigned to:  None Open/Closed:  Open

Mon 14 Jun 2021 09:40:59 AM UTC, comment #3: 

For your example scenario, I would restart nano with the following:

    nano --tabsize=1 --tabstospaces --autoindent

Then, with the cursor on the first hash, I would type:
^M ^K ^E ^M ^U ^K ^P ^K ^P ^U ^P <Shift+Ctrl+Down>
^I ^I ^I ^I ^I ^J <Ctrl+Up> ^E <Shift+Down> ^K

A group of lines can be easily aligned when selecting them and using <Tab>/<Shift+Tab> to move them right/left (when tabsize is 1 and --tabstospaces is used).

[About the --guide option: long options can be abbreviated, as long as the abbreviation identifies one option uniquely.  (This is a feature of getopt; abbreviating doesn't work for git options, for example.)  This is why, for new options, I choose names where the first word by itself already makes sense: --guide, --mini, --raw, --state, and similar.  So in your example scenario, I would start nano with: -T1 --tabsto --auto, as I remember that --tabsize is -T, but do not know the other short options.]

By the way, a closing " is missing in your example.  :)

Benno Schulenberg <bens>
Project Administrator
Sun 13 Jun 2021 08:43:38 PM UTC, comment #2: 

Hi Benno, thanks for the reply and the patch!

To be honest, I don't have a single use-case; this is just something that I kept coming across for a number of reasons, and my latest use-case prompted me to post the wish :)

However, since you ask, my latest use case which prompted this request was that I was trying to create a 'macro' in my .nanorc, to handle the following scenario. Say you have a file like this:

HolyHandGrenade = 3   # And the Lord spake, saying, "First shalt thou take out
                      # the Holy Pin. Then, shalt thou count to three. No more.
                      # No less. Three shalt be the number thou shalt count, and
                      # the number of the counting shall be three. Four shalt
                      # thou not count, nor either count thou two, excepting
                      # that thou then proceed to three. Five is right out. Once
                      # the number three, being the third number, be reached,
                      # then, lobbest thou thy Holy Hand Grenade of Antioch
                      # towards thy foe, who, being naughty in My sight, shall
                      # snuff it.

and you suddenly realise, the variable should be HolyHandGrenadeCount instead. This leads to the first comment shifting to the right by five character positions (i.e. past the current fill).

In order to rectify the justification of the comments, you need to take the following steps: 1) move the first comment down, 2) align it to the rest of the comments, 3) re-align everything to the new position as a group, 4) re-justify everything in the new position for the current fill, and then 5) manually bring the first comment back up to its place next to the code.

Upon playing a bit to create such a macro, I realised that steps 3-4 would have been very easily solved if I could, during the macro, change the fill to a practically infinite number (say, 10,000), justify, align this single infinite line where i want it, change the fill back to its previous value, and re-justify. Without this, it becomes a much harder problem, as you need to know in advance the number of lines that you need to re-align to the new position before you justify, or be able to save a variable and use it somehow.

(PS. purely for interest, the much simpler scenario of something changing in the comments themselves, such that no re-alignment is needed, only re-justification, while still non-trivial, can however be solved with a similar macro, which I already have, but no fill changes are necessary there).

So as you can see, the approach in your patch would not cover this scenario, since it would not help me in terms of creating a fill change in-session for the sake of a macro. The only thing that would work here is something like a menu coming up, asking me to type the new value and press enter. (e.g. like the 'search' menu, which I use successfully in a lot of my macros). As for how often I'd use this, well, I re-align comment blocks daily several times. Therefore, rather than use the 'fill' strategy, I simply do the whole thing manually instead, since it would take roughly the same amount of time / keystrokes.

In any case, like I said, this is a very specific example, but not the only scenario I've come across where I would have wished for this functionality (and obviously if I'm dedicated enough I may find another way to macro this, or another workaround altogether). I admit that the patch is very nice in itself, even if it doesn't cover the particular case above! Thanks for your time and for having a look at this!

PS. FYI, I note that the --guide option does not appear in the man page, even though it does have the effect you describe! (only --guidestripe appears in the man page)

Tasos Papastylianou <tpapastylianou>
Sat 12 Jun 2021 09:44:38 AM UTC, comment #1: 

Hello Tasos,

There is no need to modify your .nanorc if you want a different fill width or stripe column: you can also use --fill=... or --guide=... on the command line.  That is what I do when I want a different fill width or wish to have a guiding stripe during some session.

May I ask what your use case is?  In which circumstances do you want to adjust the fill width or stripe column?  And how often would you be likely to change it?

Anyway... sometimes I want to rejustify a piece of text and I have long wished that I could quickly try different widths, instead of having to exit, change the --fill parameter, restart nano, and type ^P ^J.  Inspired by your request, I have now finally implemented this, also for --guidestripe.  It was surprisingly easy.  See attached patch.  (This is just a proof-of-concept; there is no promise that this will become part of nano.)  What do you think?

(file #51550)

Benno Schulenberg <bens>
Project Administrator
Fri 11 Jun 2021 11:47:07 AM UTC, original submission:  

At the moment, the only way to change the 'fill' variable (i.e. the point where hard-wrapping occurs) is via the .nanorc configuration file; there is no simple way to change this dynamically, short of changing the relevant value at the .nanorc file and restarting the editor.

Similarly with the guidestripe variable.

It would be very useful if it were possible for me to, say, rebind a key (say Ctrl+F), such that when pressing this shortcut an in-editor menu comes up asking me to set a new fill value (and similarly a guidestripe value -- this could be part of the same menu, via x,y syntax).

Apologies if this kind of "changing nano variables/flags dynamically from within the editor" is possible already; if so, please let me know here. I hadn't seen anything in the "nanorc" manual to suggest that it is...

Tasos Papastylianou <tpapastylianou>


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by bens (Updated the item)
  • -email is unavailable- added by tpapastylianou (Submitted the item)
  • -email is unavailable- added by tpapastylianou

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-06-12 bens Attached File- => Added 0001-possible-new-feature-key-bindings-to-adjust-fill-wid.patch, #51550
        Severity3 - Normal => 1 - Wish
        SummaryRequest - make it possible to adjust fill / guidestripe position from within editor => [Wish] make it possible to adjust fill / guidestripe position from within editor
    2021-06-11 tpapastylianou Carbon-Copy- => Added tpapastylianou

    Back to the top

    Powered by Savane 3.6