-(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)
- 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))))