Daniel Dehennin
2016-07-22 23:01:41 UTC
The following changes since commit bec63d3ea62dafc4158c35abdf7e9180419a3f78:
* Makefile: add .info suffix. (2016-07-09 12:33:04 -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 a7654a328e17a42cb555a80f681fc21818fd5786:
Make cons cell usable when replacing a tag (2016-07-22 23:43:09 +0200)
----------------------------------------------------------------
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 query-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
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 6ed23f2..28785f3 100644
--- a/lisp/emms-tag-editor.el
+++ b/lisp/emms-tag-editor.el
@@ -349,21 +349,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)
* Makefile: add .info suffix. (2016-07-09 12:33:04 -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 a7654a328e17a42cb555a80f681fc21818fd5786:
Make cons cell usable when replacing a tag (2016-07-22 23:43:09 +0200)
----------------------------------------------------------------
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 query-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
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 6ed23f2..28785f3 100644
--- a/lisp/emms-tag-editor.el
+++ b/lisp/emms-tag-editor.el
@@ -349,21 +349,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 --recv-keys 0xCC1E9E5B7A6FE2DF
Fingerprint: 3E69 014E 5C23 50E8 9ED6 2AAD CC1E 9E5B 7A6F E2DF
Daniel Dehennin
Récupérer ma clef GPG: gpg --recv-keys 0xCC1E9E5B7A6FE2DF
Fingerprint: 3E69 014E 5C23 50E8 9ED6 2AAD CC1E 9E5B 7A6F E2DF