From e0b17407ea225b558ad595f2bff248681669da56 Mon Sep 17 00:00:00 2001 From: Valentin Villenave Date: Fri, 18 Dec 2015 10:53:31 +0100 Subject: [PATCH] Output redirection now handles symlinks This only works for basic cases where only one PDF file is generated. It will make things noticeably nicer when editing scores using Frescobaldi, for example. --- etc/ly.conf | 1 + lib/90-makescore.scm | 37 +++++++++++++++++++++++++++---------- lib/include.ly | 1 + 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/etc/ly.conf b/etc/ly.conf index 9352de0..e62ea13 100644 --- a/etc/ly.conf +++ b/etc/ly.conf @@ -30,6 +30,7 @@ themes-dir = "share/themes" fonts-dir = "share/fonts" img-dir = "share/images" output-dir = "out" +main-file = "main" ## Variables conf-prefix = "conf" diff --git a/lib/90-makescore.scm b/lib/90-makescore.scm index b860b94..6645734 100644 --- a/lib/90-makescore.scm +++ b/lib/90-makescore.scm @@ -63,18 +63,35 @@ current-part music." ;; the output-dir directory. If book-filename has already ;; been defined by the user, just keep it, otherwise it ;; will be named after the score directory's name in scores/." - (set! output-filename - (let* ((orig-filename (if (defined-string? 'output-filename) - output-filename - (ly:parser-output-name))) - (prefix (if (defined-string? 'conf:output-dir) - (string-append conf:output-dir "/") - #f)) - (new-filename (car (reverse - (string-split (*current-score*) #\/))))) + (let* ((orig-filename (if (defined-string? 'output-filename) + output-filename + (ly:parser-output-name))) + (prefix (if (defined-string? 'conf:output-dir) + (string-append conf:output-dir "/") + #f)) + (suffix (if (eq? (ly:get-option 'backend) 'ps) + ".pdf" + #f)) + (new-filename (car (reverse (string-split (*current-score*) #\/)))) + (new-filepath (string-append prefix new-filename)) + (main-filepath (string-append conf:main-file suffix)) + (long-filepath (string-append new-filepath suffix)) + (main-symlink (if (access? main-filepath 0) + (readlink main-filepath) + #f))) + (if suffix + (if (and main-symlink (string=? main-symlink long-filepath)) + (ly:debug + "Output file ~a already points to ~a, not making a new symlink." + main-filepath + long-filepath) + (begin + (if main-symlink (delete-file main-filepath)) + (symlink long-filepath main-filepath)))) + (set! output-filename (if (not prefix) orig-filename - (string-append prefix new-filename))))) + new-filepath)))) (define make ;; "This is where the score is put together and all functions diff --git a/lib/include.ly b/lib/include.ly index 9bf766b..ad72bf9 100644 --- a/lib/include.ly +++ b/lib/include.ly @@ -21,6 +21,7 @@ %% FIXME: relative includes don't work in Scheme -- Issue 1078. #(ly:set-option 'relative-includes #f) +#(ly:set-option 'delete-intermediate-files #t) %#(ly:set-option 'ignore-output-dir #t) %#(ly:set-option 'use-variable-names #t) %#(ly:set-option 'allow-suffixless-varnames #t) -- 2.11.4.GIT