bugGNU nano - Bugs: bug #54651, removal of formatter makes...

 
 

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

bug #54651: removal of formatter makes per-syntax formatting impossible

Submitter:  Patrick Bogen <pdbogen>
Submitted:  Wed 12 Sep 2018 04:52:14 PM UTC
   
 
Severity:  3 - Normal Status:  Fixed
Assigned to:  None Open/Closed:  Closed

Jump to the original submission

Mon 14 Oct 2019 09:07:34 AM UTC, comment #9: 

An equivalent feature has been added back in master, commit 34170611.

Benno Schulenberg <bens>
Group administrator
Mon 31 Dec 2018 01:22:02 PM UTC, comment #8: 

The return of some kind of per-syntax filtering command has been requested in bug #54889.  Closing this one.

Benno Schulenberg <bens>
Group administrator
Sun 16 Sep 2018 08:36:38 AM UTC, comment #7: 

Attached patch adds an sbind command to syntaxes, for per-syntax key binds. They only work in the main menu (is there a reason they should work elsewhere?), so there is no menu argument, otherwise it is identical to bind. You can have files of different syntaxes open in buffers and your sbinds automatically update when you switch between them.

  sbind <key> <function or string>

In the terraform syntax file:
  sbind ^F "^R^X|terraform fmt^M"
In nanorc:
  extendsyntax go sbind ^F "^R^X|go fmt^M"
  extendsyntax terraform sbind ^F "^R^X|terraform fmt^M"

There are two TODO comments that need to be handled. It also needs syntax highlighting support added to nanorc.syntax. Feel free to finish it and try to get the feature into nano.

(file #45020)

Brand Huntsman <brand>
Thu 13 Sep 2018 09:18:10 PM UTC, comment #6: 

I hope I'm not coming across as argumentative. I've been using nano for a long, long time; and as I lately work in languages (like Go and Terraform) that have strong (and in effect mandatory) formatters, I found the `formatter` functionality extremely useful.

I'm concerned and disappointed that you have removed a feature I use heavily (many, many times a day) and that the recommended replacement does not satisfy my use case.

Can you help me understand if this is a new direction for nano, to offer a reduced/simpler feature set? Or do you have plans to restore the `formatter` functionality in the future in a way that works for various languages without configuring and remembering key bindings for each?

I'm willing to write code to implement the ideas I proposed. I think is is not correct that they're "not a possibility," from my early investigations; though of course you're much more familiar with Nano's codebase than I am, so if there's some architectural limitation that makes these impossible to implement, I might not know about it.

Patrick Bogen <pdbogen>
Thu 13 Sep 2018 06:11:11 PM UTC, comment #5: 

Apparently you do not understand that the linter command is very special and specific: nano interprets the output of that command as a list of file locations to jump to, and gives the user a special menu to jump between those locations.  The formatter command, on the other hand, was basically a per-syntax speller command: it filtered the text through an external command.

Making the linter "more generic" is not a possibility.

Benno Schulenberg <bens>
Group administrator
Wed 12 Sep 2018 06:59:00 PM UTC, comment #4: 

What I'm thinking about with the former is a genericization of "linter".

"Linter" specifies a program associated with a specific action. I'm suggesting making it more generic; instead of specifying "linter", you would specify "program X Y", and there would be something you could bind a keystroke to "run program X", which would execute "Y"

In the same way that linter is per-syntax, the programs would be per-syntax; but the keybindings would be static. You would "run program linter" or "run program formatter", and if they exist for the current syntax, they're run; if they aren't set, they don't.

Patrick Bogen <pdbogen>
Wed 12 Sep 2018 06:49:28 PM UTC, comment #3: 

Per-syntax bindable keys are too complicated to implement.  And I'm unsure what you with program categories.  But, since the formatter command is gone and won't come back, a "program formatter ..." thing will not be possible either.  And the linter is already settable per syntax, so there is no need for "program linter ...".

Benno Schulenberg <bens>
Group administrator
Wed 12 Sep 2018 05:58:36 PM UTC, comment #2: 

I have a few ideas for how to address this that aren't "revert the patch to remove formatter" (which I don't really want, anyway).

Which of these do you think are likely to be more implementable?

  • Generic support for program categories, i.e., per-syntax "program <name> <string>" like "program linter terraform validate" and "program formatter terraform fmt" (and whatever else), plus a bind-able sequence to run a command-by-name rather than by string?


  • Per-syntax keybinds
Patrick Bogen <pdbogen>
Wed 12 Sep 2018 05:31:27 PM UTC, comment #1: 

True, the formatter command is gone and this it is no longer possible to have a per-syntax specific filtering program.  Sorry.  But the command will not come back.

In future, the speller command will become settable per syntax, and of course it will be possible to "abuse"/use that feature to not run a spell checker but a formatter program or whatever.

So... if you want give that feature a push, you could post a [Request] report.

Benno Schulenberg <bens>
Group administrator
Wed 12 Sep 2018 04:52:14 PM UTC, original submission:  

While it's possible I'm using the feature incorrectly; it appears that removing the `formatter` directive means that I can no longer have a specific formatter paired with a file type, i.e., subordinate to a `syntax` statement.

Previously, I had something like this:

```
syntax "terraform" "\.tf$"
formatter terraform fmt
```

The documentation suggests I instead bind something to "^R^X|terraform fmt^M", which works, but the problem is that the bind is true in every file.

I was able to have a formatter per-syntax type before, and I can no longer do so; this is a regression.

Patrick Bogen <pdbogen>

 

(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 brand (Updated the item)
  • -email is unavailable- added by bens (Posted a comment)
  • -email is unavailable- added by pdbogen (Submitted the item)
  •  

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

    Date Changed by Updated Field Previous Value => Replaced by
    2019-10-14 bens StatusWont Fix Fixed
    2018-12-31 bens Open/ClosedOpen Closed
    2018-09-16 brand Attached File- Added 0001-add-sbind-command-for-per-syntax-key-binds.patch, #45020
    2018-09-13 bens Summaryremoval of formatter removes per-language formatters removal of formatter makes per-syntax formatting impossible
    2018-09-12 bens StatusNone Wont Fix

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code