+2005-11-10 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+ * Documentation/user/point-and-click.itely: simplify p&c
+ instruction: don't configure firefox. Put lilypond-invoke-editor
+ in front of the browser.
+
+ * scripts/lilypond-invoke-editor.scm (run-editor): new function.
+ (run-browser): new function.
+
+ * lily/parser.yy (Lily_lexer): recognize Book
+
+ * lily/book.cc (clone): new function
+
+ * lily/parser.yy (book_body): allow BOOK_IDENTIFIER.
+
2005-11-10 Jürgen Reuter <reuter@ipd.uka.de>
* lily/vaticana-ligature.cc, lily/vaticana-ligature-engraver.cc:
file. These hyperlinks are sent to the web-browser, which opens a
text-editor with the cursor in the right place.
-To make this chain work, the following should done:
-
-@itemize @bullet
-
-@item
-The PDF viewer must be configured for following hyperlinks, preferably
-using Mozilla Firefox.
+To make this chain work, you should configure your PDF viewer to
+follow hyperlinks using the @file{lilypond-invoke-editor} script
+supplied with LilyPond.
For Xpdf on Unix, the following should be present in
@file{xpdfrc}@footnote{On unix, this file is found either in
@file{/etc/xpdfrc} or as @file{.xpdfrc} in your home directory.}
@example
-urlCommand "firefox -remote 'OpenURL(%s)'"
+urlCommand "lilypond-invoke-editor %s"
@end example
-@item Your web-browser must be configured for the @code{textedit}
-protocol,
-
-For Mozilla and Mozilla Firefox, this is done by adding following
-lines to the @file{user.js}@footnote{On a typical unix system, this
-file exists or must be created in your home-directory as
-@file{.mozilla/firefox/default.trn/user.js} or
-@file{.firefox/default/xxxxxxxx.xxx/user.js},
-see @uref{http://@/www@/.mozilla@/.org@/support@/firefox@/edit#user,location}
-and
-@uref{http://@/www@/.mozilla@/.org@/support@/firefox@/edit#profile,profile}.}
-
-@ignore
-mozilla wants us do store this in user.js:
-
-location on different systems:
-
-@end ignore
-
-@example
-user_pref("network.protocol-handler.app.textedit", "lilypond-invoke-editor");
-user_pref("network.protocol-handler.warn-external.textedit", false);
-@end example
-
-@end itemize
-
-The program @file{lilypond-invoke-editor} is a small helper program.
-It tests the environment variable @code{EDITOR} for the following
-patterns,
+The program @file{lilypond-invoke-editor} is a small helper
+program. It will invoke an editor for the special @code{textedit}
+URIs, and run a web browser for others. It tests the environment
+variable @code{EDITOR} for the following patterns,
@table @code
@item emacs
Thomas Bushnell BSG
Trevor Bača
Vicente Solsona Dellá
-Vicenzo Colonnella
+Vincenzo Colonnella
Release 2.6
***********
smobify_self ();
}
+Book*
+Book::clone () const
+{
+ return new Book (*this);
+}
+
Book::~Book ()
{
}
scm_remember_upto_here_1 (scm_key);
return paper_book;
}
+
Output_def *paper_;
SCM scores_;
+ Book *clone () const;
Book ();
void add_score (SCM);
Paper_book *process (Output_def *def_paper,
%token <i> E_UNSIGNED
%token <i> UNSIGNED
-%token <id> IDENTIFIER
-
+%token <scm> BOOK_IDENTIFIER
%token <scm> CHORDMODIFIER_PITCH
%token <scm> CHORD_MODIFIER
%token <scm> CONTEXT_DEF_IDENTIFIER
$$ = $1->self_scm ();
$1->unprotect ();
}
+ | book_block {
+ $$ = $1->self_scm ();
+ $1->unprotect ();
+ }
| output_def {
$$ = $1->self_scm ();
$1->unprotect ();
$$->paper_->unprotect ();
$$->header_ = THIS->lexer_->lookup_identifier ("$defaultheader");
}
+ | BOOK_IDENTIFIER {
+ $$ = unsmob_book ($1);
+ $$->set_spot (@$);
+ }
| book_body paper_block {
$$->paper_ = $2;
$2->unprotect ();
if (scm_is_string (sid)) {
*destination = sid;
return STRING_IDENTIFIER;
+ } else if (unsmob_book (sid)) {
+ *destination = unsmob_book (sid)->clone ()->self_scm ();
+ return BOOK_IDENTIFIER;
} else if (scm_is_number (sid)) {
*destination = sid;
return NUMBER_IDENTIFIER;
(format #f "~a/lilypond/~a" DATADIR TOPLEVEL-VERSION))
;; argv0 relocation -- do in wrapper?
+
+
(define LILYPONDPREFIX
- (or (getenv "LILYPONDPREFIX")
- (let* ((bindir (dirname (car (command-line))))
- (prefix (dirname bindir))
- (lilypond-prefix
- (if (eq? prefix (dirname DATADIR)) COMPILE-TIME-PREFIX
- (format #f "~a/share/lilypond/~a"
- prefix TOPLEVEL-VERSION))))
- lilypond-prefix)))
+ (let* ((prefix
+ (or (getenv "LILYPONDPREFIX")
+ (dirname (dirname (car (command-line)))))))
+
+
+ (if (eq? prefix (dirname DATADIR)) COMPILE-TIME-PREFIX
+ (format #f "~a/share/lilypond/~a"
+ prefix TOPLEVEL-VERSION))))
+
+
;; gettext wrapper for guile < 1.7.2
(if (defined? 'gettext)
(define (re-sub re sub string)
(regexp-substitute/global #f re string 'pre sub 'post))
-;; FIXME: I'm going slowly but certainly mad, I really cannot find the
+;; FIXME: I'm going slowly but certainly mad; I really cannot find the
;; scm library function for this.
(define (unquote-uri uri)
(re-sub "%([A-Fa-f0-9]{2})"
(lambda (m)
(string (integer->char (string->number (match:substring m 1) 16))))
uri))
+
+(define (is-textedit-uri? uri)
+ (string-match "^textedit://" uri))
+
(define (dissect-uri uri)
- (let* ((ri "textedit://")
- (file-name:line:char:column (re-sub ri "" uri))
- (match (string-match "(.*):([^:]+):([^:]+):(.*)$" file-name:line:char:column)))
+ (let* ((match (string-match "textedit://(.*):([^:]+):([^:]+):(.*)$" uri)))
(if match
(list (unquote-uri (match:substring match 1))
(match:substring match 2)
(match:substring match 3)
(match:substring match 4))
(begin
- ;; FIXME: why be so strict wrt :LINE:COLUMN,
- ;; esp. considering omitting textedit:// is explicitly
- ;; allowed.
- (format (current-error-port) (_ "invalid URI: ~a") uri)
+ (format (current-error-port) (_ "invalid textedit URI: ~a") uri)
(newline (current-error-port))
- (format (current-error-port) (_ "expect: ~aFILE:LINE:CHAR:COLUMN") ri)
+ (format (current-error-port) (_ "expect: textedit://FILE:LINE:CHAR:COLUMN"))
(newline (current-error-port))
(exit 1)))))
;; If no TTY and not using safe, assume running from GUI.
(not have-tty?)))
+(define (run-editor uri)
+ (let*
+ ((command (apply get-editor-command (dissect-uri uri)))
+ (status (system command)))
+ (if (not (= status 0))
+ (begin
+ (format (current-error-port)
+ (_ "failed to invoke editor: ~a") command)
+ (exit 1)))))
+
+(define (run-browser uri)
+
+ ;; TODO: make educated guess which browser to run.
+ (system (format #f "firefox -remote 'OpenURL(~a,new-tab)'" uri)))
+
(define (main args)
(let ((files (parse-options args)))
(if (running-from-gui?)
(exit 2)))
(set! %load-path (cons LILYPONDPREFIX %load-path))
(primitive-eval '(use-modules (scm editor)))
- (let* ((uri (car files))
- (command (apply get-editor-command (dissect-uri uri)))
- (status (system command)))
- (if (not (= status 0))
- (begin
- (format (current-error-port)
- (_ "failed to invoke editor: ~a") command)
- (exit 1))))))
+
+ (let* ((uri (car files)))
+ (if (is-textedit-uri? uri)
+ (run-editor uri)
+ (run-browser uri)))))
+