Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add bar checks "|" automatically #437

Open
fedelibre opened this issue May 15, 2014 · 12 comments
Open

add bar checks "|" automatically #437

fedelibre opened this issue May 15, 2014 · 12 comments
Labels

Comments

@fedelibre
Copy link
Member

There's been a discussion previously on this topic:
https://groups.google.com/forum/#!searchin/frescobaldi/bar$20check/frescobaldi/DqkAvFMyW88/llnTbXB9k1oJ

I know that the status bar can display the "progress of a bar".
What I'd like is Frescobaldi adding all the "|" for me, either while I'm typing and most importantly on an entire document already written without bar checks.

It would be useful to fix for example this kind of files:
https://github.com/chrissawer/The-Mutopia-Project/pull/389/files

I was going to suggest to use Frescobaldi to:

  1. remove the | at beginning of line
  2. re-format the code messed up by point 1
  3. add bar checks automagically at the end of line

3rd point is the missing feature.

@PeterBjuhr
Copy link
Collaborator

As I understand it this is well prepared but the actual functionality is not yet in place. I've been thinking about how this should be implemented. I don't have every detail clear yet but this is a sketch:

  • When the document is parsed in ly.music the bar length could optionally be calculated and a node in the document tree be inserted where the barcheck/barline should be.
  • This node could be used to add the "|" in the document on user command. But it could also give useful information in other circumstances without actually changing the document. My main interest is giving this information to the export functionality.

@PeterBjuhr
Copy link
Collaborator

I also would like to comment that in your example @fedelibre, given that all bar check is there but in the wrong place I think there're other solutions...

@fedelibre
Copy link
Member Author

actually it was made on purpose, for visibility:
MutopiaProject/MutopiaProject#389 (comment)

@PeterBjuhr
Copy link
Collaborator

@fedelibre I meant 'the wrong place' from your perspective. :)

I couldn't help taking a look at this. I made a Frescobaldi snippet which places all existing barchecks at the end of the line. Maybe this can be useful while waiting for the real thing.
https://github.com/PeterBjuhr/frescobaldi-snippets/blob/master/move-barchecks.xml
I have only tried it on a smaller example and not on the file you refer to.

@Stemby
Copy link
Contributor

Stemby commented Apr 21, 2015

This issue seems to be related to #86.

@sincere-music
Copy link

I’d support a rather low-level implementation of this as an entry to Tools/Rhythm:
Take all the music and insert a bar check before every line break. It’s even considerable to not allow any configuration options on this and thus gain a means of imposing code style, which would be helpful IMO.
The only problem would be overfull measures with more than 78 characters (plus the two for indentation :-) ). If these are manually broken, as described in #573, such a tool would place a bar check in the middle… so this would require manual editing, or indeed a more sophisticated tool in the first place.
Well, my 2cts.

@fedelibre
Copy link
Member Author

Some people love putting bar checks at the beginning of the bar
because they can count bars much more easily. I don't think that
Frescobaldi should force a code style when entering music (even if I
prefer putting bar checks at the end); code style should be an option
when you decide to click on Tools>Format. Maybe what you suggest can be
added in the format tool? Too much invasive, I guess: some may
appreciate all that format does except this bar check style.

@sincere-music
Copy link

The point is that I hate when I download a file from Mutopia (or
anywhere else) and the author had some very particular personal code
style, which I have to adapt manually before I can sensibly work on the
music. Of course, I also have my own code style, but I’d rather give up
some of that in order to conform to a standard way of writing LilyPond
input code. I think that would be really useful, but ATM Frescobaldi’s
automatic tools are almost the only standards available.
So, take my vote towards more standardisation in code style.

@uliska
Copy link
Collaborator

uliska commented Sep 10, 2015

Actually I think this is a difficult matter.
In "Das trunkne Lied" I have learned the value of shared code style, even if I did have to change my own. However, I'm not so sure if we can enforce them because being able to write anything in a source file is part of the characteristics of the game.

It may be a worthwile effort to work towards a "specification" for accepted coding standards. And it may be a good idea to take Frescobaldi's existing behaviour as a start. But we also have to see that Frescobaldi formats differently than e.g. LilyPond's code base itself (particularly the indentation of Scheme).
So what might be possible is a community-based effort for something like PEP8, but clearly separate from LilyPond itself. Frescobaldi could then provide means to "lint" the code according to such a specification.

For the problem at hand I would strongly oppose against inserting barchecks for every line break. There simply are too many opportunities to write well-formed code that does not have barlines at the end of the code line. I'm sure this would cause too much confusion and require manual post-processing and especially checking.

I think that if Frescobaldi should insert barchecks it must be based on actual music measuring. But I'm not sure if we can come up with an approach that is reliable and versatile enough not to cause more quirks than value.

@PeterBjuhr
Copy link
Collaborator

The plan is to be able to recreate LilyPond source code from the ly.music tree representation. When that is possible I think we should also have the possibility to create templates for the coding style. That would mean in my vision that it should be possible to reflow any LilyPond document according to a personal template. And hence you wouldn't be stuck with the present code style of for example a Mutopia file.

In the meantime I think some customization of the syntax could be done with the help of snippets.

@sincere-music
Copy link

#764

@PeterBjuhr
Copy link
Collaborator

Take all the music and insert a bar check before every line break.

I've uploaded a simple snippet for achieving this: add barchecks snippet

It is not very well tested so please report anything that seems strange.

For the problem at hand I would strongly oppose against inserting barchecks for every line break. There simply are too many opportunities to write well-formed code that does not have barlines at the end of the code line.

Agreed. The script has no concept of timing and only tries to figure out if the linebreak is preceded by music or not. So it is a very blunt instrument and will...

[...] require manual post-processing and especially checking.

But hopefully it can still be useful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants