diff options
author | David Kastrup <dak@gnu.org> | 2015-10-13 15:06:18 +0200 |
---|---|---|
committer | David Kastrup <dak@gnu.org> | 2015-10-14 11:29:23 +0200 |
commit | 05bb156d62a3193989f56039906ab9f23d071660 (patch) | |
tree | 8fe751b56a95b047ad1442bc63a50829e0272e1e | |
parent | 611c175ae2cceebfc8f0dccf695b4ff5593e763c (diff) |
Issue 4636: lilypond-mode.el: consult LilyPond-lilypond-command et al at runtime
Previously, they were entered into LilyPond-command-alist only at load
time, making them unchangeable via dir-local variables or within a
session.
This works by letting `LilyPond-command-expand' interpret symbols and
lists as well, dereferencing and concatenating, respectively.
-rw-r--r-- | elisp/lilypond-mode.el | 59 |
1 files changed, 35 insertions, 24 deletions
diff --git a/elisp/lilypond-mode.el b/elisp/lilypond-mode.el index 98b9401150..0bf05408e2 100644 --- a/elisp/lilypond-mode.el +++ b/elisp/lilypond-mode.el @@ -432,16 +432,16 @@ in LilyPond-include-path." (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")) + '( + ("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 @@ -616,24 +616,35 @@ Must be the car of an entry in `LilyPond-command-alist'." (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))) - (concat (substring string 0 b) - (shell-quote-argument (concat dir base)) - (LilyPond-command-expand - (concat - (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))) |