emms.git - EMMS, The Emacs Multimedia System.

index : emms.git
EMMS, The Emacs Multimedia System.
summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat
-rw-r--r--doc/emms.texinfo 10
-rw-r--r--emms-source-playlist.el 9
-rw-r--r--emms-tag-editor.el 48
3 files changed, 49 insertions, 18 deletions
diff --git a/doc/emms.texinfo b/doc/emms.texinfo
index 1730de3..8813597 100644
--- a/doc/emms.texinfo
+++ b/doc/emms.texinfo
@@ -2996,7 +2996,7 @@ respective factories, and under this new menu item 'Tango'.
They are not recreated, but simply listed by their names to be chosen.
@lisp
-(emms-filters-add-filter-menu-from-filter-list "Tango" tango-filters)
+(emms-filters-add-to-filter-menu-from-filter-list "Tango" tango-filters)
@end lisp
Here is the easiest way to make the filter ring as used by the Browser.
@@ -3381,7 +3381,6 @@ variable.
@end defvr
@heading Renaming Files
-
The tag editor is also capable to rename the file of the track at point
or all files of the marked tracks according to the value this variable.
@@ -3399,6 +3398,13 @@ The default value is "%a - %l - %n - %t", so that files are named
after renaming.
@end defopt
+@defopt emms-tag-editor-file-rename-alist
+For each pair in this alist, the first string will replaced by the
+second. This can be used to replace filename elements, spaces, or
+other unwanted strings or characters automatically whenever renaming a
+file.
+@end defopt
+
To perform the renaming put point on the track you want to rename or
mark some tracks. Then hit @kbd{R} which calls this function:
diff --git a/emms-source-playlist.el b/emms-source-playlist.el
index fd1036d..d61dbf0 100644
--- a/emms-source-playlist.el
+++ b/emms-source-playlist.el
@@ -213,10 +213,11 @@ See `emms-source-playlist-formats' for a list of supported formats."
(goto-char (point-min))
(read (current-buffer)))))
(mapc (lambda (track)
- (funcall emms-cache-set-function
- (emms-track-type track)
- (emms-track-name track)
- track))
+ (when (fboundp emms-cache-set-function)
+ (funcall emms-cache-set-function
+ (emms-track-type track)
+ (emms-track-name track)
+ track)))
tracks)
tracks))
diff --git a/emms-tag-editor.el b/emms-tag-editor.el
index 401bca7..a294948 100644
--- a/emms-tag-editor.el
+++ b/emms-tag-editor.el
@@ -343,6 +343,16 @@ 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
+ '(("/" "⁄") ;; avoid characters reserved for filenames
+ ;; (" " "_") ;; example of another substitution
+ )
+ "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
@@ -487,21 +497,21 @@ C-u M-x emms-tag-editor-guess-tag-filename RET
(let ((map (make-sparse-keymap)))
(set-keymap-parent map minibuffer-local-map)
(define-key map "\C-h"
- (lambda ()
- (interactive)
- (with-output-to-temp-buffer "*Help*"
- (princ
- "A pattern is a string like \"%a-%t-%y\" which stand for
+ (lambda ()
+ (interactive)
+ (with-output-to-temp-buffer "*Help*"
+ (princ
+ "A pattern is a string like \"%a-%t-%y\" which stand for
the file name is constructed by artist, title, year with seperator '-'.
see `emms-tag-editor-compile-pattern' for detail about pattern syntax.
Available tags are:
")
- (mapc (lambda (tag)
- (princ (format "\t%s - %S\n" (cdr tag) (car tag))))
- emms-tag-editor-tags)
- (with-current-buffer standard-output
- (help-mode)))))
+ (mapc (lambda (tag)
+ (princ (format "\t%s - %S\n" (cdr tag) (car tag))))
+ emms-tag-editor-tags)
+ (with-current-buffer standard-output
+ (help-mode)))))
map))
current-prefix-arg))
(setq pattern (emms-tag-editor-compile-pattern pattern))
@@ -775,6 +785,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 then 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 +817,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)
generated by cgit v1.2.3 (git 2.25.1) at 2025年09月07日 14:52:45 +0000

AltStyle によって変換されたページ (->オリジナル) /