all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: David Kastrup <dak@gnu.org>
To: Richard Stallman <rms@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: How to find someone working on a (mixed) major mode for LilyPond?
Date: Sun, 13 Sep 2015 19:06:52 +0200	[thread overview]
Message-ID: <878u8axn83.fsf@fencepost.gnu.org> (raw)
In-Reply-To: <E1Zb95Z-0008E4-HM@fencepost.gnu.org> (Richard Stallman's message of "Sun, 13 Sep 2015 11:21:09 -0400")

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



      reply	other threads:[~2015-09-13 17:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878u8axn83.fsf@fencepost.gnu.org \
    --to=dak@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=rms@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.