bugGNU nano - Bugs: bug #53661, [Request] support for per-syntax...

 
 

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

bug #53661: [Request] support for per-syntax tabbing behavior

Submitted by:  Andrew Pennebaker <mcandre>
Submitted on:  Sun 15 Apr 2018 04:27:35 PM UTC  
 
Severity:  1 - Wish Status:  Ready For Test
Assigned to:  Benno Schulenberg <bens> Open/Closed:  Open

( Jump to the original submission)

Mon 23 Sep 2019 09:40:18 AM UTC, comment #9: 

Benno - thanks for the new patches (file #47560, file #47561). I've checked out master at commit 4d44b03, applied both patches, then built with "--enable-utf8".

In my python.nanorc file, I have added:

tabgives "  "

If I edit a python file, the "Tab" button adds in the two spaces from the quotes. M+{ and M+} decrease/increase the indent by two spaces (expected behaviour).

If I add tabsize, tabstospaces in my .nanorc:

set tabsize 4
set tabstospaces

The behaviour earlier is unchanged and "Tab" button adds in the two spaces. tabgives seems to override the "tabsize" option set earlier and is the behaviour I would expect.

In my makefile.nanorc I added:

tabgives "TAB"

where "TAB" is a tab character (^I). When I edit a Makefile and increase the indentation, it adds a tab character as expected.

Changing tabgives to "\t" doesn't interpret "\t" as the escape sequence and inserts the string "\t" instead of the tab character. This feature would be nice to have, but "tabgives" offers the core functionality I was after.

Russell Currie <th3f1tz>
Sun 22 Sep 2019 06:03:00 PM UTC, comment #8: 

Updated patch and documentation patch are attached.  If you have time, please test and then report what you think.

(file #47560, file #47561)

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Mon 07 Jan 2019 10:44:17 AM UTC, comment #7: 

Benno - thanks for pointing out the tabstospaces/tab behaviour. The "tab" command does achieve what I want it to, and if I am aware of the behaviour, I can work with that. It does strike me that the difference may catch out some users though. "tab" also adds an extra command alongside "tabsize" and "tabstospaces" to achieve something very similar for the end user. Is this making things unnecessarily complex for the end user? - An alternative option may be to let users set "tabsize" and "tabstospaces" in included .nanorc files? (Not sure how much work, or how achievable that is.)

As for "tabkey" or "tabgives" - my vote would be for "tabgives". Without context "tabkey" sounds like something to do with rebinding the tab key.

I'm happy to keep testing!

Russell Currie <th3f1tz>
Thu 20 Dec 2018 03:53:51 PM UTC, comment #6: 

Thanks for testing.  Butbe aware that there is a difference between using tabstospaces and the 'tab' command.  When using tabstospaces (with the default tabsize of 8), and you type three spaces into an empty buffer and then <Tab>, this <Tab> will add five spaces -- to reach the next "tab stop", so to speak.  But when using the 'tab' command followed by a string of eight spaces, typing three spaces into an empty buffer followed by <Tab>, this <Tab> will add eight spaces -- the <Tab> key is no longer aware of "tab stops".

Yes, it would be nice to be able to use \t in the tab command string (and in any of the regex strings too).

Don't know if 'indent' is a better name than 'tab'...  Maybe 'tabkey' or 'tabgives'?

Yes, the string after the 'tab' command can contain anything, spacing and non-spacing characters.  It would be more work to verify that the string contains only spaces and/or tabs, so I have left that out.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Tue 18 Dec 2018 02:32:05 PM UTC, comment #5: 

Benno - thanks for the quick reply on this one, I hadn't expected one so soon. I'm using the nano 3.2 compiled from source obtained from nano-editor.org (nano-3.2.tar.xz) with your patch applied.

So, in my .nanorc file I have:

set tabsize 4
set tabstospaces

In my python.nanorc file, I have added:

tab "  "

If I edit a python file, the "Tab" button adds in the two spaces from the quotes. M+{ and M+} decrease/increase the indent by two spaces. The tab value seems to override the "tabsize" option set earlier and is the behaviour I expect.

In my makefile.nanorc I have added:

tab "TAB"

where "TAB" is a tab character (^I). When I edit a Makefile and increase the indentation, it adds a tab character as expected. M+{ and M+} decrease/increase the indent by a tab character, again as expected.

The "tab" option does do what I am trying to achieve makes editing different source files easier. A couple of comments:

It may make .nanorc files a bit easier to read if escape characters could be supported for that option e.g:

tab "\t"

I wonder if "indent" or something similar may make a better option name? (I'm not the best at naming things though!)

I notice I can have non-spacing characters e.g.:

tab "FOO"

which then adds/removes "FOO" to the start of the line as I increase/decrease the indent. I am not sure if this is expected behaviour.

Thanks again for the work and quick reply.

Russell Currie <th3f1tz>
Tue 18 Dec 2018 01:04:51 PM UTC, comment #4: 

Please see the attached patch, and test whether it achieves all that you want.

(file #45688)

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Tue 18 Dec 2018 12:44:01 PM UTC, comment #3: 

I'd like to chime in and say that this is also something I'm after.

It would be great to set/unset "tabstospaces" and have different values for "tabsize" for different syntax files. (Like the way you can set a different linter for python, tex, etc.). Ideally the "tabsize/tabtospaces" options specified globally in the .nanorc file could be overridden by the same option in the syntax sections.

Russell Currie <th3f1tz>
Mon 01 Oct 2018 11:25:18 AM UTC, comment #2: 

This is exactly what i want.. I can't use nano for my python files right now, because I use it mainly for PHP files on my system, which caused me to set nano to use 4 spaces instead of tabs.

Henry van Megen <hvanmegen>
Mon 16 Apr 2018 07:09:28 PM UTC, comment #1: 

Hmmm...  What would be needed is a 'tab' command in the relevant nanorc file, specifying what to do for the <Tab> key -- just like the 'comment' command defines what characters to insert in order to comment a line.

But should this 'tab' command override the --tabstospaces option?

By the way, what is a soft tab?

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Sun 15 Apr 2018 04:27:35 PM UTC, original submission:  

Now that many programming languages support conflicting indentation styles (hard tabs for make and Go, soft tabs for F#), it would be helpful if nano supported the ability to adjust style options on a per-programming language basis. nano should be able to “do the right thing” when the Tab keyboard key is pressed. We’re not asking for autoindenting or introspection, just a way to customize nano to insert either a hard tab literal, or else a configurable number of soaces, when the tab key is pressed, soecifically depending on the file ending / minetype / shebang.

Andrew Pennebaker <mcandre>

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by th3f1tz (Posted a comment)
  • -email is unavailable- added by th3f1tz
  • -email is unavailable- added by djc
  • -email is unavailable- added by hvanmegen (Posted a comment)
  • -email is unavailable- added by bens (Posted a comment)
  • -email is unavailable- added by mcandre (Submitted the item)
  •  

    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 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-09-22 bens Attached File- => Added 0001-new-feature-a-tabgives-command-to-define-what-the-Ta.patch, #47560
        Attached File- => Added 0002-docs-describe-the-new-tabgives-syntax-file-command.patch, #47561
        StatusNone => Ready For Test
        Assigned toNone => bens
    2018-12-31 bens Summary[Request] support per-programming language style defaults => [Request] support for per-syntax tabbing behavior
    2018-12-18 bens Attached File- => Added 0001-possible-new-feature-a-tab-command-to-define-what-th.patch, #45688
    2018-12-18 th3f1tz Carbon-Copy- => Added th3f1tz
    2018-10-03 djc Carbon-Copy- => Added djc
    2018-04-17 bens Severity3 - Normal => 1 - Wish
        Summarysupport per-programming language style defaults => [Request] support per-programming language style defaults

    Back to the top


    Powered by Savane 3.5