teeoius <[email protected]> writes:
>> It would be much easier to simply replace the forward slash in the
>> artist/album name with the Unicode visual equivalent of a forward slash
>> such as DIVISION SLASH U+2215 or FRACTION SLASH U+2044. This way we
>> preserve this feature for people who actually want Emms to help them
>> create a directory structure for their music collection.
>
> I select '_' as a replacement of '/', because:
>
> 1. It's a ascii char which should have a good display in all platform (I
> guess?).
> 2. It's just a connect character, I mean it has not obvious meaning, not like
> '&' can mean 'and', '+' can mean plus, etc.
>
> I found some alternative char of '/' such as U+2215 you mentioned, but
> I'm not good at font. If those unicode charactors can behave correctly
> with most fonts, I think they are good replace for '/' too.
>
> Maybe we can add a new var called 'emms-tag-editor-rename-replace-list'?
> which has a format like
> (('/' '_') ('\' some_unicode_char) (':' some_unicode_char))
> It can handle any chars such as '/', '\', '<', '>' (windows has many
> forbidden chars in filename). So emms can have a good work on windows.
Sorry for the delay, I was travelling.
Do you mean something like this?
diff --git a/emms-tag-editor.el b/emms-tag-editor.el
index 401bca7..51dad30 100644
--- a/emms-tag-editor.el
+++ b/emms-tag-editor.el
@@ -343,6 +343,15 @@ program for writing tags to the specified track or tracks."
"Major mode to edit track tags.
\\{emms-tag-editor-mode-map}")
+(defvar emms-tag-editor-file-rename-alist
+ '(("/" "⁄")
+ (" " "_"))
+ "Alist with replacement pairs for filename renaming.
+
+For each pair the first element is the string to be replaced, and the
+second element is the replacement string.")
+
+
(defun emms-tag-editor-set-all (tag value)
"Set TAG to VALUE in all tracks.
If transient-mark-mode is turned on, you can apply the command to
@@ -775,6 +784,18 @@ tracks according to the value of
(emms-tag-editor-rename-marked-tracks)
(emms-tag-editor-rename-track (emms-tag-editor-track-at))))
+(defun emms-tag-editor-filename-replace-strings (str)
+ "Replace substrings of STR and return STR.
+
+Replacement is done according to `emms-tag-editor-file-rename-alist'."
+ (mapc
+ (lambda (pair)
+ (let ((from (car pair))
+ (to (cadr pair)))
+ (setq str (string-replace from to str))))
+ emms-tag-editor-file-rename-alist)
+ str)
+
(defun emms-tag-editor-rename-track (track &optional dont-apply)
"Rename TRACK's file according `emms-tag-editor-rename-format's
value.
@@ -795,8 +816,10 @@ Then it's the callers job to apply them afterwards with
(mapcar
(lambda (tag)
(list (string-to-char (cdr tag))
- (or (emms-track-get track (car tag))
- "")))
+ (let ((filename-element (emms-track-get track (car tag))))
+ (if filename-element
+ (emms-tag-editor-filename-replace-strings filename-element)
+ ""))))
emms-tag-editor-tags))))
"." suffix)))
(emms-track-set track 'newname new-file)
--
"Cut your own wood and it will warm you twice"