几年前的文章,从sql搬出来
emms介绍看emacswikihttp://www.emacswiki.org/
一开始使用的是emacs中文网中的http://emacser.com/emms.htm这里面的播放列表配置,由于我使用的字体不同导致播放列表很乱。第一列显示的是artist,可以左对齐,第二列是title,不能左对齐,从第二列开始后面的都不能对齐,代码如下

;; my customizable playlist format
(defun kid-emms-info-track-description (track)
"Return a description of the current track."
(let ((artist (emms-track-get track 'info-artist))
(title (emms-track-get track 'info-title))
(album (emms-track-get track 'info-album))
(ptime (emms-track-get track 'info-playing-time)))
(if title
(format
"%-35s %-40s %-35s %5s:%-5s"
(if artist artist "")
(if title title "")
(if album album "")
(/ ptime 60)
(% ptime 60)))))
(setq emms-track-description-function
'kid-emms-info-track-description)[/php]

之后在emacswiki中看到init-emms.el,然后开始折腾,效果不错。可以看到在init-emms.el中有这么两行代码

;; 设置播放列表显示
(setq emms-track-description-function
'lazycat/emms-info-track-description)[/php]

这里表明其显示调用的是lazycat/emms-info-track-description,这个函数是emms-extension.el里定义的,代码如下

(defun lazycat/emms-info-track-description (track)
"Return a description of the current track."
(let* ((name (emms-track-name track))
(type (emms-track-type track))
(short-name (file-name-nondirectory name))
(play-count (or (emms-track-get track 'play-count) 0))
(last-played (or (emms-track-get track 'last-played) '(0 0 0)))
(empty "..."))
(prog1
(case (emms-track-type track)
((file url)
(let* ((artist (or (emms-track-get track 'info-artist) empty))
(year (emms-track-get track 'info-year))
(playing-time (or (emms-track-get track 'info-playing-time) 0))
(min (/ playing-time 60))
(sec (% playing-time 60))
(album (or (emms-track-get track 'info-album) empty))
(tracknumber (emms-track-get track 'info-tracknumber))
(short-name (file-name-sans-extension
(file-name-nondirectory name)))
(title (or (emms-track-get track 'info-title) short-name))
)
(format "%10s %3d │ %-23s %-40s │ %-45s %-4s %-6s %7s"
(emms-last-played-format-date last-played)
;; play-count
(prettyfy-string artist 18)
(prettyfy-string title 30)
;; album
(prettyfy-string
(cond ((string= album empty) "")
(t album)) 40)
;; tracknumber
(prettyfy-string
(if (and tracknumber
(not (zerop (string-to-number tracknumber))))
(format "%3d" (string-to-number tracknumber))
"") 10)
;; year
(or year "....")
;; time
(if (or (> min 0) (> sec 0))
(format "%02d:%02d" min sec)
"....."))))
((url)
(concat (symbol-name type) ":" name))
(t
(format "%-3d%s"
play-count
(concat (symbol-name type) ":" name))))
)))

但是后来改了下emacs的字体设置,没想到之前对齐的palylist变得不能对齐,就是从第二列开始不能左对齐,通过各种尝试后发现每行的第一列都能自动对齐,于是把上面代码中format改成如下,同时我不需要显示album,所以我就把与album相关的行注释掉,这样就完美了

(format "%10s %3d │ %-23s
%s
%14s %16s %20s"

上面的format中第二行也就是显示title格式前面的空格数可以根据自己的需要控制,第三行的格式也可以自己根据需要配置

最后由 oucb 编辑于2016年04月13日 19:10