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

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

Fri 18 Jun 2021 09:42:53 AM UTC, comment #5: 


> "^M^K^[[4~^M^U^K^[[A^K^[[A^U^[[A^[[A^K^U^U^[[A^^^[[4~^\^[r.{1}^M
> ^Ma^K^[[3~^\^\s+#^M^U#^Ma^[^[j^[9^[[A^[[4~^^^[[B^K^W^[r^C^C"


If you will allow me the comment: this is crazy.  :)  But wonderful.

Coming back to the original request: I don't like to add a menu where one can set fill,guidestripe (in the x comma y format) because the two things are not really related -- not like line,column are.  And adding two separate menus, one for fill and one for guidestripe, would be over the top.  Also, allowing to set fill and guidestripe trough a menu wouldn't solve my use case: it would still be too much typing, hardly any better than exiting from nano and adjusting the command line.  So... won't fix.

(I will install an improved version of file #51550 as a local patch and see whether I will actually start to use it.)

(file #51582)

Benno Schulenberg <bens>
Group administrator
Thu 17 Jun 2021 11:01:49 PM UTC, comment #4: 

Hah, I know. I spotted the missing quote right after I posted. It will haunt me forever :p

Also good to know about abbreviated longoptions ... I was not aware of that. Thanks!

Anyway, we are now far removed from the original intent of the ticket, but in case you're interested, your proposed macro didn't work for me, since it assumes you know how many times you want to 'indent' ... which is fine when doing the keystrokes 'live', but not for binding to a predefined macro. I did like your first steps though! I decided to persevere with the macro and solved it like so:

bind M-J "^M^K^[[4~^M^U^K^[[A^K^[[A^U^[[A^[[A^K^U^U^[[A^^^[[4~^\^[r.{1}^M ^Ma^K^[[3~^\^\s+#^M^U#^Ma^[^[j^[9^[[A^[[4~^^^[[B^K^W^[r^C^C" main

In other words, I start the same as you to get the initial alignment, but then rely on a trick of replacing a duplicate of the first line stub with spaces, which gives me the 'desired indent'. Then I search/replace the 'existing indent' for the 'desired indent' in the comment block, justify at the new indent, and then shift everything back in place.

:)

Thanks again for taking my ramblings seriously, hahah! Please feel free to close the ticket.

Tasos Papastylianou <tpapastylianou>
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>
Group 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>
Group 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>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

 

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
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-08-20 bens Open/ClosedOpen Closed
    2021-06-18 bens Attached File- Added 0001-possible-new-feature-key-bindings-to-adjust-fill-wid.patch, #51582
        StatusNone Wont Fix
    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.13-758e.
    Corresponding source code