diff options
-rw-r--r-- | emms-lyrics.el | 2 | ||||
-rw-r--r-- | emms-tageditor.el | 18 | ||||
-rw-r--r-- | emms.el | 16 |
3 files changed, 23 insertions, 13 deletions
diff --git a/emms-lyrics.el b/emms-lyrics.el index ebbfc12..3ed5a66 100644 --- a/emms-lyrics.el +++ b/emms-lyrics.el @@ -141,7 +141,7 @@ To find FILE, will look up in current directory and `emms-lyrics-dir'." (time 0) (lyric "")) (setq lyric - (replace-regexp-in-string ".*\\]" "" lyric-string)) + (emms-replace-regexp-in-string ".*\\]" "" lyric-string)) (while (string-match "\\[[0-9:.]+\\]" lyric-string) (let* ((time-string (match-string 0 lyric-string)) (semi-pos (string-match ":" time-string))) diff --git a/emms-tageditor.el b/emms-tageditor.el index f093d85..4afe4e3 100644 --- a/emms-tageditor.el +++ b/emms-tageditor.el @@ -235,20 +235,14 @@ (setq emms-tageditor-widgets nil) (kill-buffer (get-buffer-create emms-tageditor-buffer-name))) -(defun emms-tageditor-replace-regexp (regexp rep string &optional fixedcase literal subexp start) - "Compatibility wrapper for replace-regexp-in-string/replace-in-string." - (if (featurep 'xemacs) - (replace-in-string regexp rep string fixedcase literal subexp start) - (replace-regexp-in-string regexp rep string fixedcase literal subexp start))) - (defun emms-tageditor-replace-create-replacement (replace-with trackidx) (let ((info (aref emms-tageditor-current-infos trackidx)) (track (aref emms-tageditor-current-tracks trackidx))) - (setq replace-with (emms-tageditor-replace-regexp "$TITLE" (emms-info-title info) replace-with)) - (setq replace-with (emms-tageditor-replace-regexp "$ALBUM" (emms-info-album info) replace-with)) - (setq replace-with (emms-tageditor-replace-regexp "$ARTIST" (emms-info-artist info) replace-with)) - (setq replace-with (emms-tageditor-replace-regexp "$NOTE" (emms-info-note info) replace-with)) - (setq replace-with (emms-tageditor-replace-regexp "$TRACKNAME" (emms-track-name track) replace-with))) + (setq replace-with (emms-replace-regexp-in-string "$TITLE" (emms-info-title info) replace-with)) + (setq replace-with (emms-replace-regexp-in-string "$ALBUM" (emms-info-album info) replace-with)) + (setq replace-with (emms-replace-regexp-in-string "$ARTIST" (emms-info-artist info) replace-with)) + (setq replace-with (emms-replace-regexp-in-string "$NOTE" (emms-info-note info) replace-with)) + (setq replace-with (emms-replace-regexp-in-string "$TRACKNAME" (emms-track-name track) replace-with))) replace-with) (defun emms-tageditor-replace-tag (field regexp replace-with) @@ -258,7 +252,7 @@ ;; Find the widget for the current track (let ((widget (emms-tageditor-get-widget idx field))) (let* ((str (widget-value widget)) - (str (emms-tageditor-replace-regexp regexp replace-with str))) + (str (emms-replace-regexp-in-string regexp replace-with str))) (if (string= "$SET" regexp) (widget-value-set widget @@ -1186,5 +1186,21 @@ or negative to seek backwards." ((fboundp 'delete-itimer) (delete-itimer timer))))) +(defun emms-replace-regexp-in-string (regexp replacement text &optional fixedcase literal) + "Replace REGEXP with REPLACEMENT in TEXT. +If fourth arg FIXEDCASE is non-nil, do not alter case of replacement text. +If fifth arg LITERAL is non-nil, insert REPLACEMENT literally." + (cond + ((fboundp 'replace-regexp-in-string) + (replace-regexp-in-string regexp replacement text fixedcase literal)) + ((fboundp 'replace-in-string) + (replace-in-string text regexp replacement literal)) + (t (let ((repl-len (length replacement)) + start) + (while (setq start (string-match regexp text start)) + (setq start (+ start repl-len) + text (replace-match replacement fixedcase literal text)))) + text))) + (provide 'emms) ;;; emms.el ends here |