;;;; lilypond-mode.el -- Major mode for editing GNU LilyPond music scores
;;;; This file is part of LilyPond, the GNU music typesetter.
;;;;
-;;;; Copyright (C) 1999--2011 Jan Nieuwenhuizen <janneke@gnu.org>
+;;;; Copyright (C) 1999--2015 Jan Nieuwenhuizen <janneke@gnu.org>
;;;; Changed 2001--2003 Heikki Junes <heikki.junes@hut.fi>
;;;; * Add PS-compilation, PS-viewing and MIDI-play (29th Aug 2001)
;;;; * Keyboard shortcuts (12th Sep 2001)
(defun LilyPond-compile-file (command name)
;; We maybe should know what we run here (Lily, lilypond, tex)
;; and adjust our error-matching regex ?
- (compile-internal
+ (compilation-start
(if (eq LilyPond-command-current 'LilyPond-command-master)
command
;; use temporary directory for Commands on Buffer/Region
;; hm.. the directory is set twice, first to default-dir
- (concat "cd " (LilyPond-temp-directory) "; " command))
- "No more errors" name))
+ (concat "cd " (LilyPond-temp-directory) "; " command))))
-;; do we still need this, now that we're using compile-internal?
+;; do we still need this, now that we're using compilation-start?
(defun LilyPond-save-buffer ()
"Save buffer and set default command for compiling."
(interactive)
(defcustom LilyPond-command-alist
;; Should expand this to include possible keyboard shortcuts which
;; could then be mapped to define-key and menu.
- `(
- ("LilyPond" . (,(concat LilyPond-lilypond-command " %s") "%s" "%l" "View"))
- ("2PS" . (,(concat LilyPond-lilypond-command " -f ps %s") "%s" "%p" "ViewPS"))
- ("2Gnome" . (,(concat LilyPond-lilypond-command " -b gnome %s")))
-
+ '(
+ ("LilyPond" . ((LilyPond-lilypond-command " %s") "%s" "%l" "View"))
+ ("2PS" . ((LilyPond-lilypond-command " -f ps %s") "%s" "%p" "ViewPS"))
("Book" . ("lilypond-book %x" "%x" "%l" "LaTeX"))
("LaTeX" . ("latex '\\nonstopmode\\input %l'" "%l" "%d" "ViewDVI"))
;; refreshes when kicked USR1
- ("View" . (,(concat LilyPond-pdf-command " %f")))
- ("ViewPDF" . (,(concat LilyPond-pdf-command " %f")))
- ("ViewPS" . (,(concat LilyPond-ps-command " %p")))
+ ("View" . ((LilyPond-pdf-command " %f")))
+ ("ViewPDF" . ((LilyPond-pdf-command " %f")))
+ ("ViewPS" . ((LilyPond-ps-command " %p")))
;; The following are refreshed in LilyPond-command:
;; - current-midi depends on cursor position and
(LilyPond-command (LilyPond-command-menu "2PS") 'LilyPond-get-master-file)
)
-(defun LilyPond-command-formatgnome ()
- "Format the gnome output of the current document."
- (interactive)
- (LilyPond-command (LilyPond-command-menu "2Gnome") 'LilyPond-get-master-file))
-
(defun LilyPond-command-formatmidi ()
"Format the midi output of the current document."
(interactive)
(LilyPond-command-select-buffer)
(LilyPond-command-region (point-min) (point-max)))
-(defun LilyPond-command-expand (string file)
- (let ((case-fold-search nil))
- (if (string-match "%" string)
- (let* ((b (match-beginning 0))
- (e (+ b 2))
- (l (split-file-name file))
- (dir (car l))
- (base (cadr l)))
- (LilyPond-command-expand
- (concat (substring string 0 b)
- (shell-quote-argument (concat dir base))
- (let ((entry (assoc (substring string b e)
- LilyPond-expand-alist)))
- (if entry (cdr entry) ""))
- (substring string e))
- file))
- string)))
+(defun LilyPond-command-expand (arg file)
+ (cond
+ ((listp arg)
+ (mapconcat (lambda (arg) (LilyPond-command-expand arg file))
+ arg
+ ""))
+ ((and (symbolp arg) (boundp arg)
+ ;; Avoid self-quoting symbols
+ (not (eq (symbol-value arg) arg)))
+ (LilyPond-command-expand (symbol-value arg) file))
+ ((stringp arg)
+ (let ((case-fold-search nil))
+ (if (string-match "%" arg)
+ (let* ((b (match-beginning 0))
+ (e (+ b 2))
+ (l (split-file-name file))
+ (dir (car l))
+ (base (cadr l)))
+ (concat (substring arg 0 b)
+ (shell-quote-argument (concat dir base))
+ (LilyPond-command-expand
+ (concat
+ (let ((entry (assoc (substring arg b e)
+ LilyPond-expand-alist)))
+ (if entry (cdr entry) ""))
+ (substring arg e))
+ file)))
+ arg)))
+ (t (error "Bad expansion `%S'" arg))))
(defun LilyPond-shell-process (name buffer command)
(let ((old (current-buffer)))
(define-key LilyPond-mode-map "\C-c\C-c" 'LilyPond-command-master)
(define-key LilyPond-mode-map "\C-cm" 'LilyPond-command-formatmidi)
(define-key LilyPond-mode-map "\C-c\C-f" 'LilyPond-command-formatps)
- (define-key LilyPond-mode-map "\C-c\C-g" 'LilyPond-command-formatgnome)
(define-key LilyPond-mode-map "\C-c\C-s" 'LilyPond-command-view)
(define-key LilyPond-mode-map "\C-c\C-p" 'LilyPond-command-viewps)
(define-key LilyPond-mode-map [(control c) return] 'LilyPond-command-current-midi)