[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Some thoughts on narrowing, was Re: How to compile Lilypond files using
From: |
David Wright |
Subject: |
Some thoughts on narrowing, was Re: How to compile Lilypond files using Emacs? |
Date: |
Mon, 27 Jul 2020 21:19:18 -0500 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
On Mon 27 Jul 2020 at 17:02:15 (+1000), Andrew Bernard wrote:
> The issue is not WIndows specific. You need to add a line similar to
> this in your emacs init file to get the compile to work:
>
> ;; lilypond
> (setq LilyPond-lilypond-command "lilypond -I ~/lib/lilypond
> -I~/lib/openlilylib/snippets")
>
> I also add the following:
>
> (autoload 'LilyPond-mode "lilypond-mode" "LilyPond Editing Mode" t)
> (add-to-list 'auto-mode-alist '("\\.ly$" . LilyPond-mode))
> (add-to-list 'auto-mode-alist '("\\.ily$" . LilyPond-mode))
>
> But as said, you will run into issues with narrowing, and nested
> tuplets smash the formatting badly.
I can't say I agree with every indentation decision that LP/emacs
makes, but personally, the effects tend to be very shortlived,
ie lasting just a few lines. (My scores are much simpler than yours.)
As for narrowing, I wrote in 2015 that I'd not met the problem for
years, and that would be compatible with my installing Debian/squeeze
in March 2011. There's a note in lisp/simple.el that the default
value of blink-matching-paren-distance was increased from 25 to
100k with emacs version 23.2. At that time, none of my scores were
as big as 100kB.
Looking at site-lisp/lilypond-indent.el (which has changes quite
recently, though not in this area), it does appear that the
narrow-to-region call should be protected. My guess would be
that the call should be written as:
(save-excursion
(save-restriction
(when blink-matching-paren-distance ← line 501/502
(narrow-to-region
(max (point-min) (- (point) blink-matching-paren-distance))
(min (point-max) (+ (point) blink-matching-paren-distance))))))
I've based that on the corresponding part of lisp/simple.el's:
(save-excursion ← line 7571
(save-restriction
(if blink-matching-paren-distance
(narrow-to-region
(max (minibuffer-prompt-end) ;(point-min) unless minibuf.
(- (point) blink-matching-paren-distance))
oldpos))
… … ))
(AFAICT the section marked … … does not exist in site-lisp/lilypond-indent.el.)
> As mentioned, search the archives of this list. There is quite a lot
> of discussion about this topic. I'd love to fix the issues, but my
> elisp-fu is not powerful enough I'm afraid.
Assuming that LP is getting its default value for blink-matching-paren-distance
from /usr/share/emacs/26.1/lisp/simple.el.gz (Debian/buster), I would
imagine that the definition could be overwritten in one's own startup
file. This could be as simple as inserting these lines, with a greater
value in place of 100.
(defcustom blink-matching-paren-distance (* 100 1024)
"If non-nil, maximum distance to search backwards for matching open-paren.
If nil, search stops at the beginning of the accessible portion of the buffer."
:version "23.2" ; 25->100k
:type '(choice (const nil) integer)
:group 'paren-blinking)
Apologies for my similar lack of elisp-fu.
Cheers,
David.