all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to find someone working on a (mixed) major mode for LilyPond?
@ 2015-09-10 16:09 David Kastrup
  2015-09-13 15:21 ` Richard Stallman
  0 siblings, 1 reply; 3+ messages in thread
From: David Kastrup @ 2015-09-10 16:09 UTC (permalink / raw)
  To: emacs-devel


As a few people likely know, I'm one of the most active programmers on
GNU LilyPond, a music typesetting program.  LilyPond has a nice input
language <URL:http://lilypond.org/text-input.html> and there is an Emacs
mode for editing it.

Unfortunately, that mode is woefully inadequate and has not kept up with
the time.

One of the main drawbacks is that LilyPond offers a few one- or
two-character sequences for doing a computation/entry/whatever of a
single sexp in Scheme (namely GNU GUILE).  In a similar manner, inside
of GUILE one can escape back into LilyPond by writing #{ ... #} for one
LilyPond expression.

LilyPond-mode sucks at reliably indenting Scheme expressions.  Its
indentation and highlighting of Scheme expressions is unnecessarily
different from and worse than Emacs' built-in scheme-mode, and quite
often after such an embedded Scheme expression, LilyPond's own
indentation is thrown off really badly permanently (meaning that the bad
indentation is not just the next line but more or less the rest of the
document).

I've written some note input modes using Midi keyboards: that is quite
helpful.  However, the inability of LilyPond-mode to do a reasonably
nice line-wrap/auto-fill/indentation on the results necessitates a whole
lot of manual work afterwards, seriously detracting from the usefulness.

I've been "considering" for several years now rewriting most of the
stuff from scratch using SMIE, syntactic highlighting and whatnot:
backwards or XEmacs compatibility is largely not an issue as people
would just be referred to the old mode for that.

It's rather abundantly clear that I'll not likely find the time and/or
leisure to work myself into those aspects of Emacs sufficiently for
creating actually worthwhile code.

The main "competition" is a standalone editor Frescobaldi
<URL:http://www.frescobaldi.org/index.html> which is actually
embarrassingly good regarding indentation/highlighting (of both Scheme
and LilyPond code) and is mostly written and extended in Python.

Does anybody here have suggestions how to acquire Emacs talent actually
somewhat interested in bootstrapping what amounts to a dual-language
mode with one mode coming from the Lisp family?  As I said: backwards
compatibility should be a non-issue so one can dig in with everything
Emacs offers, if necessary extending Emacs in the process.

-- 
David Kastrup



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to find someone working on a (mixed) major mode for LilyPond?
  2015-09-10 16:09 How to find someone working on a (mixed) major mode for LilyPond? David Kastrup
@ 2015-09-13 15:21 ` Richard Stallman
  2015-09-13 17:06   ` David Kastrup
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Stallman @ 2015-09-13 15:21 UTC (permalink / raw)
  To: David Kastrup; +Cc: emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

I think it would be really good to make progress in dual-language
editing in Emacs, especially if we can improve the general facilities
so as to make such modes easier to write.

I urge people to help you in this project.

-- 
Dr Richard Stallman
President, Free Software Foundation (gnu.org, fsf.org)
Internet Hall-of-Famer (internethalloffame.org)
Skype: No way! See stallman.org/skype.html.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to find someone working on a (mixed) major mode for LilyPond?
  2015-09-13 15:21 ` Richard Stallman
@ 2015-09-13 17:06   ` David Kastrup
  0 siblings, 0 replies; 3+ messages in thread
From: David Kastrup @ 2015-09-13 17:06 UTC (permalink / raw)
  To: Richard Stallman; +Cc: emacs-devel

Richard Stallman <rms@gnu.org> writes:

> [[[ To any NSA and FBI agents reading my email: please consider    ]]]
> [[[ whether defending the US Constitution against all enemies,     ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
>
> I think it would be really good to make progress in dual-language
> editing in Emacs, especially if we can improve the general facilities
> so as to make such modes easier to write.
>
> I urge people to help you in this project.

To illustrate: here is an extract from ly/music-functions-init.ly:

compoundMeter =
#(define-music-function (args) (pair?)
  (_i "Create compound time signatures. The argument is a Scheme list of
lists. Each list describes one fraction, with the last entry being the
denominator, while the first entries describe the summands in the
enumerator. If the time signature consists of just one fraction,
the list can be given directly, i.e. not as a list containing a single list.
For example, a time signature of (3+1)/8 + 2/4 would be created as
@code{\\compoundMeter #'((3 1 8) (2 4))}, and a time signature of (3+2)/8
as @code{\\compoundMeter #'((3 2 8))} or shorter
@code{\\compoundMeter #'(3 2 8)}.")
  (let* ((mlen (calculate-compound-measure-length args))
         (beat (calculate-compound-base-beat args))
         (beatGrouping (calculate-compound-beat-grouping args))
         (timesig (cons (ly:moment-main-numerator mlen)
                        (ly:moment-main-denominator mlen))))
  #{
    \once \override Timing.TimeSignature.stencil = #(lambda (grob)
      (grob-interpret-markup grob (make-compound-meter-markup args)))
    \set Timing.timeSignatureFraction = #timesig
    \set Timing.baseMoment = #beat
    \set Timing.beatStructure = #beatGrouping
    \set Timing.beamExceptions = #'()
    \set Timing.measureLength = #mlen
  #} ))

It defines a command \compoundMeter that can be used in LilyPond
passages according to the instructions in the gettext-enabled DOC
string.  At the first # the parser is thrown into Scheme mode and reads
one sexp (incidentally ending at the end of the quoted passage).  The
body of the let* is a "music expression" in LilyPond syntax bracketed in
#{...#}.  It contains various Scheme expressions again, namely
#(lambda...), #beat, #beatGrouping, #'() and #mlen.  Again, following
any of the # one sexp is read and then syntax returns to Lilypond.

For something like SMIE, one would likely regard all of #sexp as a
single token, but this token is Scheme syntax internally and should
(apart from any included #{...#} of course) ideally be totally the same
as Emacs' Scheme mode.  In LilyPond mode itself, however, ( and ) are
not matched delimiters.

When used, \compoundMeter is followed by one LilyPond expression obeying
the predicate pair?.  That can be something like #'(...) (list or dotted
pair/list), but it can also be something like 3/4 (which is LilyPond
shordhand for #'(3 . 4)).  3/4 cannot be represented as Scheme #3/4
since that would make it indistinguishable from 6/8 which is a different
musical meter altogether.  There are similar equivalences all around:
instead of \once \override Timing.TimeSignature.stencil = ##f you could
write #(once (property-override '(Timing TimeSignature stencil) #f))
for the equivalent effect.

So a typical LilyPond file is going back and forth between Scheme and
LilyPond a whole lot: most numeric expressions are entered in Scheme
mode, and pretty much any control structure or expression while any
music content inside of such structures is then delivered via #{...#} in
LilyPond mode.

As a result, there are a whole lot of Scheme/LilyPond syntax transitions
in a typical file.  And it would be really nice to use scheme-mode for
the Scheme parts without incurring a large overhead for switching
between the principal modes.

-- 
David Kastrup



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-09-13 17:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-10 16:09 How to find someone working on a (mixed) major mode for LilyPond? David Kastrup
2015-09-13 15:21 ` Richard Stallman
2015-09-13 17:06   ` David Kastrup

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.