emms-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emms-patches] [PATCH] Make cons cell usable when replacing a tag


From: Daniel Dehennin
Subject: [Emms-patches] [PATCH] Make cons cell usable when replacing a tag
Date: Thu, 02 Jan 2014 10:50:40 +0100
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (gnu/linux)

The following changes since commit c10e28076ccec49828bd544fb2dda67c55bcdbc9:

  * lisp/emms-info-libtag.el: Added mp4, m4a to the extensions handled by 
emms-info-libtag (2013-10-16 12:32:47 -0400)

are available in the git repository at:

  git://git.baby-gnu.net/emms.git 
tags/feature/make-cons-cell-usable-in-emms-tag-editor-replace-in-tag

for you to fetch changes up to 436b2091acf9b8522419c0600a7952aa1a35c50d:

  Make cons cell usable when replacing a tag and fix an end-of-line match loop. 
(2014-01-02 10:26:10 +0100)

----------------------------------------------------------------
Rebased on latest master:

As reported on the mailing list[1][2], it's not possible to use a cons
cell like "\,(downcase \1)" in emms-tag-editor-replace-in-tag.

After looking at how quer-replace-regexp handle this case, I patch
emms-tag-editor-replace-in-tag.

I also fix a bug when using a catch all regexp like  "\(.*\)", the
generator will first try to match on the current line, to replace
multiple occurrences in the same string.

But '(re-search-forward "\\(.*\\)" (line-end-position) t)' will match
the end-of-line, making the replacement looping on the same line.

Footnotes:
[1]  http://lists.gnu.org/archive/html/emms-help/2005-07/msg00010.html

[2]  https://lists.gnu.org/archive/html/emms-help/2012-01/msg00002.html

----------------------------------------------------------------
Daniel Dehennin (1):
      Make cons cell usable when replacing a tag and fix an end-of-line match 
loop.

 lisp/emms-tag-editor.el | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/lisp/emms-tag-editor.el b/lisp/emms-tag-editor.el
index 06041c5..52196ca 100644
--- a/lisp/emms-tag-editor.el
+++ b/lisp/emms-tag-editor.el
@@ -350,21 +350,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" test))))
                  (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" test)))))))))))
       (delete-overlay overlay))))
 
 (defun emms-tag-editor-transpose-tag (tag1 tag2)

-- 
Daniel Dehennin
Récupérer ma clef GPG:
gpg --keyserver pgp.mit.edu --recv-keys 0x7A6FE2DF

Attachment: pgpkpVGFJKBV1.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]