From e63f143cce434aa17076ed6f437ed5bfd5db6d9d Mon Sep 17 00:00:00 2001 From: Yoni Rabkin Date: Mon, 1 Aug 2016 11:43:48 -0400 Subject: * lisp/emms-tag-editor.el: Make cons cell usable. Make cons cell usable when replacing a tag. Patch by Daniel Dehennin . --- lisp/emms-tag-editor.el | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'lisp') diff --git a/lisp/emms-tag-editor.el b/lisp/emms-tag-editor.el index 23e45f9..85baf7d 100644 --- a/lisp/emms-tag-editor.el +++ b/lisp/emms-tag-editor.el @@ -355,21 +355,34 @@ changes will only take effect on the tracks in the region." (map-y-or-n-p (lambda (match) (move-overlay overlay (match-beginning 0) (match-end 0)) - (format "Replace %s to %s" match to)) + (format "Replace %s to %s" (car match) (cadr match))) (lambda (match) - (delete-region (- (point) (length match)) (point)) - (insert to)) + (delete-region (- (point) (length (car match))) (point)) + (insert (cadr match))) (lambda () (if (and (save-excursion (re-search-backward tag (line-beginning-position) t)) + (not (= (point) (line-end-position))) (re-search-forward from (line-end-position) t)) - (match-string 0) + (list (match-string 0) (cond + ((and (listp to) + (fboundp (car to)) (funcall (car to) (cdr to) 0))) + ((string-match-p "\\\\[&[:digit:]]" to) + (match-substitute-replacement to nil nil)) + ((stringp to) to) + (t (error "Wrong type argument: string or cons cell, %s" to)))) (let (found) (while (and (not found) (re-search-forward tag nil t)) (if (re-search-forward from (line-end-position) t) (setq found t))) - (and found (match-string 0)))))))) + (and found (list (match-string 0) (cond + ((and (listp to) + (fboundp (car to)) (funcall (car to) (cdr to) 0))) + ((string-match-p "\\\\[&[:digit:]]" to) + (match-substitute-replacement to nil nil)) + ((stringp to) to) + (t (error "Wrong type argument: string or cons cell, %s" to))))))))))) (delete-overlay overlay)))) (defun emms-tag-editor-transpose-tag (tag1 tag2) -- cgit v1.2.3